Merge pull request #114455 from SataQiu/fix-kubeadm-2022121302

kubeadm: fix the bug that kubeadm always do CRI detection even if it is not required by phase subcommand
This commit is contained in:
Kubernetes Prow Robot 2022-12-19 00:51:44 -08:00 committed by GitHub
commit 03bfbdd8aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 1 deletions

View File

@ -149,6 +149,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

View File

@ -220,6 +220,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

View File

@ -46,6 +46,7 @@ func NewPreflightPhase() workflow.Phase {
Run: runPreflight,
InheritFlags: []string{
options.CfgPath,
options.NodeCRISocket,
options.IgnorePreflightErrors,
options.DryRun,
},

View File

@ -36,7 +36,6 @@ func NewUploadCertsPhase() workflow.Phase {
Run: runUploadCerts,
InheritFlags: []string{
options.CfgPath,
options.NodeCRISocket,
options.KubeconfigPath,
options.UploadCerts,
options.CertificateKey,

View File

@ -96,6 +96,7 @@ func NewUploadConfigPhase() workflow.Phase {
func getUploadConfigPhaseFlags() []string {
return []string{
options.CfgPath,
options.NodeCRISocket,
options.KubeconfigPath,
options.DryRun,
}

View File

@ -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)
})