Skip to content

Commit 2bb9225

Browse files
authored
fix: requeue if the pool is created after the node (#100)
* fix: requeue if the pool is created after the node * fix: requeue if the gpunode is not generated and remove createorupdate
1 parent 1d4a6a1 commit 2bb9225

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

internal/controller/node_controller.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
110110
ObjectMeta: metav1.ObjectMeta{
111111
Name: node.Name,
112112
},
113-
}); err != nil && !errors.IsNotFound(err) {
113+
}); err != nil {
114+
// requeue if the gpunode is not generated
115+
if errors.IsNotFound(err) {
116+
return ctrl.Result{RequeueAfter: constants.PendingRequeueDuration}, nil
117+
}
114118
return ctrl.Result{}, fmt.Errorf("can not delete gpuNode(%s) : %w", node.Name, err)
115119
}
116120
return ctrl.Result{}, nil
@@ -121,9 +125,8 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
121125
if err := r.Client.Get(ctx, client.ObjectKey{Name: node.Name}, gpuNode); err != nil {
122126
if errors.IsNotFound(err) {
123127
gpuNode = r.generateGPUNode(node, pool)
124-
_, e := controllerutil.CreateOrUpdate(ctx, r.Client, gpuNode, func() error { return nil })
125-
if e != nil {
126-
return ctrl.Result{}, fmt.Errorf("failed to create or patch GPUNode: %w", e)
128+
if e := r.Client.Create(ctx, gpuNode); e != nil {
129+
return ctrl.Result{}, fmt.Errorf("failed to create GPUNode: %w", e)
127130
}
128131
}
129132
} else {

0 commit comments

Comments
 (0)