From 06d7fa01aeb26b4e1e9bb293bcf54a0e9a49bf74 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 6 Nov 2020 15:39:25 -0800 Subject: [PATCH] Fix startup with missing etcd static pod manifest Seems like the intent was to ignore the file not found error, but apparently someone forgot that a bare return would use the err value returned by ReadFile, not the default nil from the named return. Signed-off-by: Brad Davidson --- pkg/podexecutor/staticpod.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/podexecutor/staticpod.go b/pkg/podexecutor/staticpod.go index a0188971da..9cf8b3c320 100644 --- a/pkg/podexecutor/staticpod.go +++ b/pkg/podexecutor/staticpod.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "io/ioutil" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "net/http" "os" "os/exec" @@ -21,6 +20,7 @@ import ( "github.com/rancher/rke2/pkg/staticpod" "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" auditv1 "k8s.io/apiserver/pkg/apis/audit/v1" "k8s.io/apiserver/pkg/authentication/authenticator" "sigs.k8s.io/yaml" @@ -187,7 +187,7 @@ func (s *StaticPodConfig) ControllerManager(apiReady <-chan struct{}, args []str func (s *StaticPodConfig) CurrentETCDOptions() (opts executor.InitialOptions, err error) { bytes, err := ioutil.ReadFile(filepath.Join(s.ManifestsDir, "etcd.yaml")) if os.IsNotExist(err) { - return + return opts, nil } pod := &v1.Pod{} @@ -200,7 +200,7 @@ func (s *StaticPodConfig) CurrentETCDOptions() (opts executor.InitialOptions, er return opts, json.NewDecoder(strings.NewReader(v)).Decode(&opts) } - return + return opts, nil } // ETCD starts the etcd static pod.