Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#1526 from ncdc/0.4/post-encryption…
Browse files Browse the repository at this point in the history
…-fixes

🏃 Post encryption fixes
  • Loading branch information
k8s-ci-robot committed Feb 5, 2020
2 parents c1c646d + b721ce4 commit b4addc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Expand Up @@ -22,3 +22,5 @@ linters:
issue:
max-same-issues: 0
max-per-linter: 0
run:
deadline: 5m
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion controllers/awsmachine_controller.go
Expand Up @@ -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.
Expand Down
10 changes: 2 additions & 8 deletions pkg/cloud/scope/machine.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand Down

0 comments on commit b4addc2

Please sign in to comment.