Skip to content

Commit

Permalink
Change VPC CR Conditions
Browse files Browse the repository at this point in the history
For IPAddressAllocation, SecurityPolicy, StaticRoute, SubnetPort CR,
change to use "reason" for simplified message and "message" for details messages.
according to https://github.com/kubernetes/apimachinery/blob/d4f471b82f0a17cda946aeba446770563f92114d/pkg/apis/meta/v1/types.go#L1407
Reason : reason contains a programmatic identifier indicating the reason for the condition
Message : message is a human readable message indicating details about the transition
  • Loading branch information
lxiaopei committed Oct 2, 2024
1 parent 2183145 commit c9d12c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func updateFail(r *IPAddressAllocationReconciler, c context.Context, o *v1alpha1
func (r *IPAddressAllocationReconciler) setReadyStatusFalse(ctx context.Context, ipaddressallocation *v1alpha1.IPAddressAllocation, transitionTime metav1.Time, err *error) {
conditions := []v1alpha1.Condition{
{
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: "NSX IPAddressAllocation could not be created or updated",
Reason: fmt.Sprintf(
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: fmt.Sprintf(
"error occurred while processing the IPAddressAllocation CR. Error: %v",
*err,
),
Reason: "NSX IPAddressAllocation could not be created or updated",
LastTransitionTime: transitionTime,
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/securitypolicy/securitypolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ func (r *SecurityPolicyReconciler) setSecurityPolicyReadyStatusTrue(ctx context.
func (r *SecurityPolicyReconciler) setSecurityPolicyReadyStatusFalse(ctx context.Context, secPolicy *v1alpha1.SecurityPolicy, transitionTime metav1.Time, err *error) {
newConditions := []v1alpha1.Condition{
{
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: "NSX Security Policy could not be created/updated",
Reason: fmt.Sprintf(
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: fmt.Sprintf(
"error occurred while processing the SecurityPolicy CR. Error: %v",
*err,
),
Reason: "NSX Security Policy could not be created/updated",
LastTransitionTime: transitionTime,
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/staticroute/staticroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (r *StaticRouteReconciler) setStaticRouteReadyStatusTrue(ctx context.Contex
{
Type: v1alpha1.Ready,
Status: v1.ConditionTrue,
Message: "NSX Static Route has been successfully created/updated",
Reason: "NSX API returned 200 response code for PATCH",
Message: "NSX API returned 200 response code for PATCH",
Reason: "NSX Static Route has been successfully created/updated",
LastTransitionTime: transitionTime,
},
}
Expand All @@ -147,8 +147,8 @@ func (r *StaticRouteReconciler) setStaticRouteReadyStatusFalse(ctx context.Conte
{
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: "NSX Static Route could not be created/updated/deleted",
Reason: fmt.Sprintf("Error occurred while processing the Static Route CR. Please check the config and try again. Error: %v", *err),
Message: fmt.Sprintf("Error occurred while processing the Static Route CR. Please check the config and try again. Error: %v", *err),
Reason: "NSX Static Route could not be created/updated/deleted",
LastTransitionTime: transitionTime,
},
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/controllers/subnetport/subnetport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *SubnetPortReconciler) Reconcile(ctx context.Context, req ctrl.Request)

nsxSubnet, err := r.SubnetService.GetSubnetByPath(nsxSubnetPath)
if err != nil {
updateFail(r, ctx, subnetPort, &err)
c(r, ctx, subnetPort, &err)

Check failure on line 115 in pkg/controllers/subnetport/subnetport_controller.go

View workflow job for this annotation

GitHub Actions / build

undefined: c) (typecheck)

Check failure on line 115 in pkg/controllers/subnetport/subnetport_controller.go

View workflow job for this annotation

GitHub Actions / build

undefined: c (typecheck)
return common.ResultRequeue, err
}
nsxSubnetPortState, err := r.SubnetPortService.CreateOrUpdateSubnetPort(subnetPort, nsxSubnet, "", labels)
Expand Down Expand Up @@ -332,13 +332,13 @@ func (r *SubnetPortReconciler) setSubnetPortReadyStatusTrue(ctx context.Context,
func (r *SubnetPortReconciler) setSubnetPortReadyStatusFalse(ctx context.Context, subnetPort *v1alpha1.SubnetPort, transitionTime metav1.Time, err *error) {
newConditions := []v1alpha1.Condition{
{
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: "NSX subnet port could not be created/updated",
Reason: fmt.Sprintf(
Type: v1alpha1.Ready,
Status: v1.ConditionFalse,
Message: fmt.Sprintf(
"error occurred while processing the SubnetPort CR. Error: %v",
*err,
),
Reason: "NSX subnet port could not be created/updated",
LastTransitionTime: transitionTime,
},
}
Expand Down

0 comments on commit c9d12c6

Please sign in to comment.