Skip to content

Commit

Permalink
add resourceError conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Richerson <[email protected]>
  • Loading branch information
matthew-richerson committed Nov 13, 2024
1 parent eae4bc8 commit e808be8
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 40 deletions.
56 changes: 42 additions & 14 deletions api/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 51 additions & 15 deletions api/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/controller/dws_storage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (r *DWSStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request)

if err := r.Get(ctx, client.ObjectKeyFromObject(nnfNode), nnfNode); err != nil {
if apierrors.IsNotFound(err) {
storage.Status.Status = dwsv1alpha2.NotPresentStatus
storage.Status.Status = dwsv1alpha3.NotPresentStatus
return ctrl.Result{}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/nnf_storage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (r *NnfStorageReconciler) addPersistentStorageReference(ctx context.Context
}

if persistentStorage.Status.State != dwsv1alpha3.PSIStateEnabled || persistentStorage.Status.Ready != true {
return dwsv1alpha2.NewResourceError("").WithUserMessage("PersistentStorage is not enabled").WithFatal()
return dwsv1alpha3.NewResourceError("").WithUserMessage("PersistentStorage is not enabled").WithFatal()
}

// Add a consumer reference to the persistent storage for this directive
Expand Down
16 changes: 8 additions & 8 deletions internal/controller/nnf_workflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,22 @@ func (r *NnfWorkflowReconciler) startSetupState(ctx context.Context, workflow *d
persistentStorage, err := r.findPersistentInstance(ctx, workflow, dwArgs["name"])
if err != nil {
if !apierrors.IsNotFound(err) {
return nil, dwsv1alpha2.NewResourceError("").WithError(err).WithFatal().WithUser().WithUserMessage("could not find peristent storage %v", dwArgs["name"])
return nil, dwsv1alpha3.NewResourceError("").WithError(err).WithFatal().WithUser().WithUserMessage("could not find peristent storage %v", dwArgs["name"])
}

return nil, nil
}

if persistentStorage.Spec.UserID != workflow.Spec.UserID {
return nil, dwsv1alpha2.NewResourceError("Existing persistent storage user ID %v does not match user ID %v", persistentStorage.Spec.UserID, workflow.Spec.UserID).WithError(err).WithUserMessage("user ID does not match existing persistent storage").WithFatal().WithUser()
return nil, dwsv1alpha3.NewResourceError("Existing persistent storage user ID %v does not match user ID %v", persistentStorage.Spec.UserID, workflow.Spec.UserID).WithError(err).WithUserMessage("user ID does not match existing persistent storage").WithFatal().WithUser()
}

if persistentStorage.Spec.State != dwsv1alpha2.PSIStateDisabled {
persistentStorage.Spec.State = dwsv1alpha2.PSIStateDisabled
if persistentStorage.Spec.State != dwsv1alpha3.PSIStateDisabled {
persistentStorage.Spec.State = dwsv1alpha3.PSIStateDisabled

err = r.Update(ctx, persistentStorage)
if err != nil {
return nil, dwsv1alpha2.NewResourceError("could not update PersistentInstance: %v", client.ObjectKeyFromObject(persistentStorage)).WithError(err).WithUserMessage("could not delete persistent storage %v", dwArgs["name"])
return nil, dwsv1alpha3.NewResourceError("could not update PersistentInstance: %v", client.ObjectKeyFromObject(persistentStorage)).WithError(err).WithUserMessage("could not delete persistent storage %v", dwArgs["name"])
}
}
}
Expand All @@ -473,13 +473,13 @@ func (r *NnfWorkflowReconciler) finishSetupState(ctx context.Context, workflow *
persistentStorage, err := r.findPersistentInstance(ctx, workflow, dwArgs["name"])
if err != nil {
if !apierrors.IsNotFound(err) {
return nil, dwsv1alpha2.NewResourceError("").WithError(err).WithFatal().WithUserMessage("could not find peristent storage %v", dwArgs["name"])
return nil, dwsv1alpha3.NewResourceError("").WithError(err).WithFatal().WithUserMessage("could not find peristent storage %v", dwArgs["name"])
}

return nil, nil
}

if persistentStorage.Status.State != dwsv1alpha2.PSIStateDisabled || persistentStorage.Status.Ready == false {
if persistentStorage.Status.State != dwsv1alpha3.PSIStateDisabled || persistentStorage.Status.Ready == false {
return Requeue("draining persistent storage").withObject(persistentStorage), nil
}
default:
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func (r *NnfWorkflowReconciler) finishTeardownState(ctx context.Context, workflo
return Requeue("persistent storage owner add").after(2 * time.Second).withObject(persistentStorage), nil
}

if persistentStorage.Status.State != dwsv1alpha2.PSIStateDisabled || persistentStorage.Status.Ready != true {
if persistentStorage.Status.State != dwsv1alpha3.PSIStateDisabled || persistentStorage.Status.Ready != true {
return Requeue("persistent storage ready disabled").after(2 * time.Second).withObject(persistentStorage), nil
}
case "persistentdw":
Expand Down
Loading

0 comments on commit e808be8

Please sign in to comment.