-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat]: Set metadata for LinodeMachines, disable swap #74
Changes from 2 commits
a4be7f8
9bb835e
f7057ff
e00f4c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,13 +81,14 @@ type LinodeMachineReconciler struct { | |
ReconcileTimeout time.Duration | ||
} | ||
|
||
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines,verbs=get;list;watch;create;update;patch;delete | ||
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines/status,verbs=get;update;patch | ||
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines/finalizers,verbs=update | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines/status,verbs=get;update;patch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=linodemachines/finalizers,verbs=update | ||
|
||
//+kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=get;watch;list | ||
//+kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines,verbs=get;watch;list | ||
//+kubebuilder:rbac:groups="",resources=events,verbs=create;update;patch | ||
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=get;watch;list | ||
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines,verbs=get;watch;list | ||
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch | ||
// +kubebuilder:rbac:groups="",resources=secrets;,verbs=get;list;watch | ||
|
||
// Reconcile is part of the main kubernetes reconciliation loop which aims to | ||
// move the current state of the cluster closer to the desired state. | ||
|
@@ -118,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: | ||
|
@@ -209,6 +209,9 @@ func (r *LinodeMachineReconciler) reconcile( | |
} | ||
}() | ||
|
||
// Add the finalizer if not already there | ||
controllerutil.AddFinalizer(machineScope.LinodeMachine, infrav1.GroupVersion.String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since youre playing with this line could you add a patch like @eljohnson92 PR earlier to cluster https://github.com/linode/cluster-api-provider-linode/pull/64/files#diff-d6148d3b8d79d76ad02a5e26b74a8bbff6541058ae664f3c10e5dd97accffd76R99-R113 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, I'll get that added 👍 |
||
|
||
// Delete | ||
if !machineScope.LinodeMachine.ObjectMeta.DeletionTimestamp.IsZero() { | ||
failureReason = cerrs.DeleteMachineError | ||
|
@@ -218,8 +221,6 @@ func (r *LinodeMachineReconciler) reconcile( | |
return | ||
} | ||
|
||
controllerutil.AddFinalizer(machineScope.LinodeMachine, infrav1.GroupVersion.String()) | ||
|
||
var linodeInstance *linodego.Instance | ||
defer func() { | ||
machineScope.LinodeMachine.Status.InstanceState = util.Pointer(linodego.InstanceOffline) | ||
|
@@ -241,7 +242,12 @@ 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: reconciler.DefaultMachineControllerWaitForBootstrapDelay}, nil | ||
} | ||
linodeInstance, err = r.reconcileCreate(ctx, machineScope, logger) | ||
|
||
return | ||
|
@@ -281,6 +287,17 @@ func (*LinodeMachineReconciler) reconcileCreate(ctx context.Context, machineScop | |
} | ||
createConfig.Tags = tags | ||
|
||
// get the bootstrap data for the Linode instance and set it for create config | ||
bootstrapData, err := machineScope.GetBootstrapData(ctx) | ||
if err != nil { | ||
logger.Info("Failed to get bootstrap data", "error", err.Error()) | ||
|
||
return nil, err | ||
} | ||
createConfig.Metadata = &linodego.InstanceMetadataOptions{ | ||
UserData: bootstrapData, | ||
} | ||
|
||
if linodeInstance, err = machineScope.LinodeClient.CreateInstance(ctx, *createConfig); err != nil { | ||
logger.Info("Failed to create Linode machine instance", "error", err.Error()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the b64 encoding happen by the callee incase anyone is looking for the string? this feels like a generic function and how it's used shouldn't be determined by this func