From 6012528891d72dc9c0488dc111df154b8544ccc6 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 5 Feb 2020 16:26:58 -0500 Subject: [PATCH 1/3] Re-add missing return when reconciling failed machines Signed-off-by: Andy Goldstein --- controllers/awsmachine_controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/awsmachine_controller.go b/controllers/awsmachine_controller.go index f20fd63b8e..3fa17de016 100644 --- a/controllers/awsmachine_controller.go +++ b/controllers/awsmachine_controller.go @@ -290,11 +290,14 @@ func (r *AWSMachineReconciler) reconcileNormal(ctx context.Context, machineScope // If the AWSMachine is in an error state, return early. if machineScope.HasFailed() { + machineScope.Info("Error state detected, skipping reconciliation") + // If we are in a failed state, delete the secret regardless of instance state if err := r.deleteEncryptedBootstrapDataSecret(machineScope, secretSvc); err != nil { return reconcile.Result{}, err } - machineScope.Info("Error state detected, skipping reconciliation") + + return reconcile.Result{}, nil } // If the AWSMachine doesn't have our finalizer, add it. From a8c2a2b734c73ea008026694c961b76d2c4ffc55 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 5 Feb 2020 16:31:32 -0500 Subject: [PATCH 2/3] Fix lint deadline location Signed-off-by: Andy Goldstein --- .golangci.yml | 2 ++ Makefile | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 81c6981d9d..6220bc11c6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,3 +22,5 @@ linters: issue: max-same-issues: 0 max-per-linter: 0 +run: + deadline: 5m diff --git a/Makefile b/Makefile index 9065e8946c..0bf144f905 100644 --- a/Makefile +++ b/Makefile @@ -136,10 +136,10 @@ $(RELEASE_NOTES) : $(TOOLS_DIR)/go.mod .PHONY: lint lint: $(GOLANGCI_LINT) ## Lint codebase - $(GOLANGCI_LINT) run -v --deadline=5m + $(GOLANGCI_LINT) run -v lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues - $(GOLANGCI_LINT) run -v --fast=false --deadline=5m + $(GOLANGCI_LINT) run -v --fast=false ## -------------------------------------- ## Generate From b721ce42ff2dfb039e489ffbe83e2cf71b34ca6f Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 5 Feb 2020 16:33:05 -0500 Subject: [PATCH 3/3] Correct secret comments in machine scope Signed-off-by: Andy Goldstein --- pkg/cloud/scope/machine.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/cloud/scope/machine.go b/pkg/cloud/scope/machine.go index 5888e9b298..4cf6007bcf 100644 --- a/pkg/cloud/scope/machine.go +++ b/pkg/cloud/scope/machine.go @@ -22,7 +22,6 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" - corev1 "k8s.io/api/core/v1" "k8s.io/klog/klogr" "k8s.io/utils/pointer" infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2" @@ -208,12 +207,7 @@ func (m *MachineScope) DeleteSecretARN() { m.AWSMachine.Spec.CloudInit.SecretARN = "" } -// SetAddresses sets the AWSMachine address status. -func (m *MachineScope) SetAddresses(addrs []corev1.NodeAddress) { - m.AWSMachine.Status.Addresses = addrs -} - -// GetBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName as base64. +// GetBootstrapData returns the Machine's bootstrap data, encoded as base64. func (m *MachineScope) GetBootstrapData() (string, error) { if m.Machine.Spec.Bootstrap.Data == nil { return "", errors.New("error retrieving bootstrap data: no data present") @@ -223,7 +217,7 @@ func (m *MachineScope) GetBootstrapData() (string, error) { } -// GetRawBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName. +// GetRawBootstrapData returns the Machine's bootstrap data, unencoded. func (m *MachineScope) GetRawBootstrapData() ([]byte, error) { val, err := m.GetBootstrapData() if err != nil {