Skip to content

Commit

Permalink
need to requeue if bootstrap data not ready, secret must be b64encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Jan 31, 2024
1 parent bfb05a4 commit 5df9f02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scope

import (
"context"
b64 "encoding/base64"
"errors"
"fmt"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -101,5 +102,5 @@ func (m *MachineScope) GetBootstrapData() (string, error) {
m.LinodeMachine.Name,
)
}
return string(value), nil
return b64.StdEncoding.EncodeToString(value), nil

Check failure on line 105 in cloud/scope/machine.go

View workflow job for this annotation

GitHub Actions / go-analyse

return with no blank line before (nlreturn)
}
15 changes: 7 additions & 8 deletions controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (r *LinodeMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reques

return ctrl.Result{}, nil
case skippedMachinePhases[machine.Status.Phase]:
log.Info("Machine phase is not the one we are looking for, skipping reconciliation", "phase", machine.Status.Phase)

return ctrl.Result{}, nil
default:
Expand Down Expand Up @@ -213,12 +212,6 @@ func (r *LinodeMachineReconciler) reconcile(
// Add the finalizer if not already there
controllerutil.AddFinalizer(machineScope.LinodeMachine, infrav1.GroupVersion.String())

// Make sure bootstrap data is available and populated.
if machineScope.Machine.Spec.Bootstrap.DataSecretName == nil {
logger.Info("Bootstrap data secret is not yet available")
return res, nil
}

// Delete
if !machineScope.LinodeMachine.ObjectMeta.DeletionTimestamp.IsZero() {
failureReason = cerrs.DeleteMachineError
Expand Down Expand Up @@ -249,7 +242,11 @@ func (r *LinodeMachineReconciler) reconcile(

// Create
failureReason = cerrs.CreateMachineError

// Make sure bootstrap data is available and populated.
if machineScope.Machine.Spec.Bootstrap.DataSecretName == nil {
logger.Info("Bootstrap data secret is not yet available")
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil

Check failure on line 248 in controller/linodemachine_controller.go

View workflow job for this annotation

GitHub Actions / go-analyse

mnd: Magic number: 5, in <assign> detected (gomnd)
}
linodeInstance, err = r.reconcileCreate(ctx, machineScope, logger)

return
Expand Down Expand Up @@ -292,6 +289,8 @@ func (*LinodeMachineReconciler) reconcileCreate(ctx context.Context, machineScop
// get the bootstrap data for the Linode instance and set it for create config
bootstrapData, err := machineScope.GetBootstrapData()

Check failure on line 290 in controller/linodemachine_controller.go

View workflow job for this annotation

GitHub Actions / go-analyse

Function `GetBootstrapData` should pass the context parameter (contextcheck)
if err != nil {
logger.Info("Failed to get bootstrap data", "error", err.Error())

return nil, err
}
createConfig.Metadata = &linodego.InstanceMetadataOptions{
Expand Down

0 comments on commit 5df9f02

Please sign in to comment.