Skip to content
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

update to proper message on a successful fence op #488

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[🎩︎]mrajanna@li-2cfbef4c-22d9-11b2-a85c-a3e4a93c405f kubernetes-csi-addons $]go fmt ./...
apis/csiaddons/v1alpha1/networkfence_types.go
[🎩︎]mrajanna@li-2cfbef4c-22d9-11b2-a85c-a3e4a93c405f kubernetes-csi-addons $]git diff
diff --git a/apis/csiaddons/v1alpha1/networkfence_types.go b/apis/csiaddons/v1alpha1/networkfence_types.go
index 2a532e92..71b891c3 100644
--- a/apis/csiaddons/v1alpha1/networkfence_types.go
+++ b/apis/csiaddons/v1alpha1/networkfence_types.go
@@ -41,10 +41,10 @@ const (
 )
 
 const (
-       // FenceOperationSuccessfulMessage represents successful message on fence operation 
+       // FenceOperationSuccessfulMessage represents successful message on fence operation
        FenceOperationSuccessfulMessage = "fencing operation successful"
-       
-       // UnFenceOperationSuccessfulMessage represents successful message on unfence operation 
+
+       // UnFenceOperationSuccessfulMessage represents successful message on unfence operation
        UnFenceOperationSuccessfulMessage = "unfencing operation successful"
 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see, go fmt changed the lines and hence the uncommitted changes, I have updated the patch

// 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