Skip to content

Commit e4e45e0

Browse files
committed
Merge branch 'main' into KUBE-996
2 parents f4688bc + f8321b7 commit e4e45e0

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TOOLS_DIR=bin
77
ROOT_DIR=$(abspath .)
88
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
99

10-
GOLANGCI_LINT_VER := v1.62.2
10+
GOLANGCI_LINT_VER := v1.64.8
1111
GOLANGCI_LINT_BIN := golangci-lint
1212
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
1313

cmd/controller/run.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/bombsimon/logrusr/v4"
1313
"github.com/google/uuid"
1414
"github.com/sirupsen/logrus"
15+
apierrors "k8s.io/apimachinery/pkg/api/errors"
1516
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1617
"k8s.io/apiserver/pkg/server/healthz"
1718
"k8s.io/client-go/dynamic"
@@ -206,6 +207,8 @@ func runController(
206207
log.Fatalf("failed to determine if running on GKE: %v", err)
207208
}
208209

210+
log.Infof("Running on GKE is: %v", isGKE)
211+
209212
if isGKE {
210213
csrMgr := csr.NewApprovalManager(log, clientset)
211214
if err := csrMgr.Start(ctx); err != nil {
@@ -321,9 +324,14 @@ func (e *logContextError) Unwrap() error {
321324
}
322325

323326
func runningOnGKE(clientset *kubernetes.Clientset, cfg config.Config) (isGKE bool, err error) {
327+
// When running locally, there is no node.
328+
if cfg.SelfPod.Node == "" {
329+
return false, nil
330+
}
331+
324332
err = waitext.Retry(context.Background(), waitext.DefaultExponentialBackoff(), 3, func(ctx context.Context) (bool, error) {
325333
node, err := clientset.CoreV1().Nodes().Get(ctx, cfg.SelfPod.Node, metav1.GetOptions{})
326-
if err != nil {
334+
if err != nil && !apierrors.IsNotFound(err) {
327335
return true, fmt.Errorf("getting node: %w", err)
328336
}
329337

internal/config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ func Get() Config {
127127
}
128128

129129
if cfg.SelfPod.Namespace == "" {
130-
required("LEADER_ELECTION_NAMESPACE")
130+
// LEADER_ELECTION_NAMESPACE exists for backwards compatibility.
131+
// But we use the namespace even without leader election so it's required.
132+
required("self_pod.namespace or LEADER_ELECTION_NAMESPACE")
131133
}
132134

133135
if cfg.LeaderElection.Enabled {

internal/controller/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ func (s *Controller) handleActions(ctx context.Context, clusterActions []*castai
154154

155155
go func(action *castai.ClusterAction) {
156156
defer s.finishProcessing(action.ID)
157-
157+
if action.Data() == nil {
158+
s.log.WithField(actions.ActionIDLogField, action.ID).Error("unknown action type, try upgrading to the latest version")
159+
return
160+
}
158161
var err error
159162
handleErr := s.handleAction(ctx, action)
160163
if errors.Is(handleErr, context.Canceled) {

0 commit comments

Comments
 (0)