From 9a7a7091a973be35f453751fe9bcb36592a1cd82 Mon Sep 17 00:00:00 2001 From: Liang Deng <283304489@qq.com> Date: Thu, 30 Nov 2023 21:25:48 +0800 Subject: [PATCH] fix: yurtadm join ignorePreflightErrors could not set all Signed-off-by: Liang Deng <283304489@qq.com> --- pkg/yurtadm/cmd/config/config.go | 2 +- pkg/yurtadm/cmd/join/join.go | 3 +++ pkg/yurtadm/constants/constants.go | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/yurtadm/cmd/config/config.go b/pkg/yurtadm/cmd/config/config.go index 1780c7cd060..7fe7d23db10 100644 --- a/pkg/yurtadm/cmd/config/config.go +++ b/pkg/yurtadm/cmd/config/config.go @@ -90,7 +90,7 @@ func runConfigPrintActionDefaults(out io.Writer, configBytesProc func() (string, func getDefaultNodeConfigBytes() (string, error) { KubeadmJoinDiscoveryFilePath := filepath.Join(constants.KubeletWorkdir, constants.KubeadmJoinDiscoveryFileName) - ignoreErrors := sets.String{} + ignoreErrors := sets.NewString(constants.KubeletConfFileAvailableError, constants.ManifestsDirAvailableError) name, err := edgenode.GetHostname("") if err != nil { return "", err diff --git a/pkg/yurtadm/cmd/join/join.go b/pkg/yurtadm/cmd/join/join.go index bc388dd84aa..d05b9323e0a 100644 --- a/pkg/yurtadm/cmd/join/join.go +++ b/pkg/yurtadm/cmd/join/join.go @@ -279,6 +279,9 @@ func newJoinData(args []string, opt *joinOptions) (*joinData, error) { for i := range opt.ignorePreflightErrors { ignoreErrors.Insert(opt.ignorePreflightErrors[i]) } + if !ignoreErrors.Has("all") { + ignoreErrors.Insert(yurtconstants.KubeletConfFileAvailableError, yurtconstants.ManifestsDirAvailableError) + } // Either use specified nodename or get hostname from OS envs name, err := edgenode.GetHostname(opt.nodeName) diff --git a/pkg/yurtadm/constants/constants.go b/pkg/yurtadm/constants/constants.go index 2aa21459c4e..3db86db21f5 100644 --- a/pkg/yurtadm/constants/constants.go +++ b/pkg/yurtadm/constants/constants.go @@ -116,6 +116,9 @@ const ( // StaticPods flag set the specified static pods on this node want to install StaticPods = "static-pods" + KubeletConfFileAvailableError = "FileAvailable--etc-kubernetes-kubelet.conf" + ManifestsDirAvailableError = "DirAvailable--etc-kubernetes-manifests" + DefaultServerAddr = "https://127.0.0.1:6443" ServerHealthzServer = "127.0.0.1:10267" ServerHealthzURLPath = "/v1/healthz" @@ -178,8 +181,6 @@ nodeRegistration: criSocket: {{.criSocket}} name: {{.name}} ignorePreflightErrors: - - FileAvailable--etc-kubernetes-kubelet.conf - - DirAvailable--etc-kubernetes-manifests {{- range $index, $value := .ignorePreflightErrors}} - {{$value}} {{- end}}