Skip to content

Commit

Permalink
fix reconciliation with multiple nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
voigt committed Jan 30, 2024
1 parent 50af7eb commit 93b488f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/controller/shim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,13 @@ func (sr *ShimReconciler) handleDeployJob(ctx context.Context, shim *kwasmv1.Shi
return ctrl.Result{}, err
}

// if err = sr.Create(ctx, job); err != nil {
// log.Err(err).Msg("Failed to create new Job " + req.Namespace + " Job.Name " + req.Name)
// return ctrl.Result{}, fmt.Errorf("failed to create new job: %w", err)
// }

// We want to use server-side apply https://kubernetes.io/docs/reference/using-api/server-side-apply
patchMethod := client.Apply
patchOptions := &client.PatchOptions{
Force: ptr(true), // Force b/c any fields we are setting need to be owned by the spin-operator
FieldManager: "shim-operator",
}

log.Error().Msgf("JOB %v", job)
// Note that we reconcile even if the deployment is in a good state. We rely on controller-runtime to rate limit us.
if err := sr.Client.Patch(ctx, job, patchMethod, patchOptions); err != nil {
log.Error().Msgf("Unable to reconcile Job %s", err)
Expand All @@ -179,7 +173,7 @@ func (sr *ShimReconciler) handleDeployJob(ctx context.Context, shim *kwasmv1.Shi

func (sr *ShimReconciler) createJobManifest(shim *kwasmv1.Shim, node *corev1.Node, req ctrl.Request) (*batchv1.Job, error) {
priv := true
name := shim.Name + "-provisioner"
name := node.Name + "." + shim.Name
nameMax := int(math.Min(float64(len(name)), 63))

job := &batchv1.Job{
Expand Down Expand Up @@ -221,7 +215,11 @@ func (sr *ShimReconciler) createJobManifest(shim *kwasmv1.Shim, node *corev1.Nod
Value: shim.Spec.FetchStrategy.AnonHttp.Location,
},
{
Name: "SHIM_HANDLER",
Name: "RUNTIMECLASS_NAME",
Value: shim.Spec.RuntimeClass.Name,
},
{
Name: "RUNTIMECLASS_HANDLER",
Value: shim.Spec.RuntimeClass.Handler,
},
{
Expand Down

0 comments on commit 93b488f

Please sign in to comment.