Skip to content

Commit

Permalink
kubeadm: avoid CRI detection for phase subcommand when it's --cri-soc…
Browse files Browse the repository at this point in the history
…ket flag is not set
  • Loading branch information
SataQiu committed Dec 14, 2022
1 parent 6b90355 commit 2501a46
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/kubeadm/app/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ func newCmdInit(out io.Writer, initOptions *initOptions) *cobra.Command {
// sets the data builder function, that will be used by the runner
// both when running the entire workflow or single phases
initRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
if cmd.Flags().Lookup(options.NodeCRISocket) == nil {
// avoid CRI detection
// assume that the command execution does not depend on CRISocket when --cri-socket flag is not set
initOptions.externalInitCfg.NodeRegistration.CRISocket = kubeadmconstants.UnknownCRISocket
}
data, err := newInitData(cmd, args, initOptions, out)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions cmd/kubeadm/app/cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ func newCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
// sets the data builder function, that will be used by the runner
// both when running the entire workflow or single phases
joinRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
if cmd.Flags().Lookup(options.NodeCRISocket) == nil {
// avoid CRI detection
// assume that the command execution does not depend on CRISocket when --cri-socket flag is not set
joinOptions.externalcfg.NodeRegistration.CRISocket = kubeadmconstants.UnknownCRISocket
}
data, err := newJoinData(cmd, args, joinOptions, out, kubeadmconstants.GetAdminKubeConfigPath())
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions cmd/kubeadm/app/cmd/phases/init/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func NewPreflightPhase() workflow.Phase {
Run: runPreflight,
InheritFlags: []string{
options.CfgPath,
options.NodeCRISocket,
options.IgnorePreflightErrors,
options.DryRun,
},
Expand Down
1 change: 0 additions & 1 deletion cmd/kubeadm/app/cmd/phases/init/uploadcerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func NewUploadCertsPhase() workflow.Phase {
Run: runUploadCerts,
InheritFlags: []string{
options.CfgPath,
options.NodeCRISocket,
options.KubeconfigPath,
options.UploadCerts,
options.CertificateKey,
Expand Down
1 change: 1 addition & 0 deletions cmd/kubeadm/app/cmd/phases/init/uploadconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func NewUploadConfigPhase() workflow.Phase {
func getUploadConfigPhaseFlags() []string {
return []string{
options.CfgPath,
options.NodeCRISocket,
options.KubeconfigPath,
options.DryRun,
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/kubeadm/app/cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ func newCmdReset(in io.Reader, out io.Writer, resetOptions *resetOptions) *cobra
// sets the data builder function, that will be used by the runner
// both when running the entire workflow or single phases
resetRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
if cmd.Flags().Lookup(options.NodeCRISocket) == nil {
// avoid CRI detection
// assume that the command execution does not depend on CRISocket when --cri-socket flag is not set
resetOptions.criSocketPath = kubeadmconstants.UnknownCRISocket
}
return newResetData(cmd, resetOptions, in, out)
})

Expand Down

0 comments on commit 2501a46

Please sign in to comment.