Skip to content

Commit

Permalink
update to proper message on a successful fence op
Browse files Browse the repository at this point in the history
Signed-off-by: rakeshgm <[email protected]>
  • Loading branch information
rakeshgm committed Nov 15, 2023
1 parent 2336074 commit 0fdf27e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions apis/csiaddons/v1alpha1/networkfence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ const (
FencingOperationResultFailed FencingOperationResult = "Failed"
)

const (
// FenceOperationSuccessfulMessage represents successful message on fence operation
FenceOperationSuccessfulMessage = "fencing operation successful"

// UnFenceOperationSuccessfulMessage represents successful message on unfence operation
UnFenceOperationSuccessfulMessage = "unfencing operation successful"
)

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="secret is immutable"
// SecretSpec defines the secrets to be used for the network fencing operation.
type SecretSpec struct {
Expand Down
10 changes: 9 additions & 1 deletion controllers/csiaddons/networkfence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ func (r *NetworkFenceReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, err
}

err = nf.updateStatus(ctx, csiaddonsv1alpha1.FencingOperationResultSucceeded, "fencing operation successful")
var successMsg string
switch nf.instance.Spec.FenceState {
case csiaddonsv1alpha1.Fenced:
successMsg = csiaddonsv1alpha1.FenceOperationSuccessfulMessage
case csiaddonsv1alpha1.Unfenced:
successMsg = csiaddonsv1alpha1.UnFenceOperationSuccessfulMessage
}

err = nf.updateStatus(ctx, csiaddonsv1alpha1.FencingOperationResultSucceeded, successMsg)
if err != nil {
logger.Error(err, "failed to update status")
return ctrl.Result{}, err
Expand Down

0 comments on commit 0fdf27e

Please sign in to comment.