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

metallb controller: improve visibility on metallb status, add logs, and fix bug #362

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

liornoy
Copy link
Contributor

@liornoy liornoy commented Jul 23, 2023

This PR batches together 3 small commits to solve issues with the metallb-operator controller.

@liornoy liornoy changed the title metallb controller: improve visibility on metallb status, add logs, and fix bug. metallb controller: improve visibility on metallb status, add logs, and fix bug Jul 23, 2023
@liornoy liornoy force-pushed the add-controller-logs branch from 0ef7d81 to a77519b Compare July 23, 2023 14:39
@@ -111,9 +113,11 @@ func (r *MetalLBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}
if err := status.Update(context.TODO(), r.Client, instance, condition, errorMsg, wrappedErrMsg); err != nil {
logger.Error(err, "Failed to update metallb status", "Desired status", status.ConditionAvailable)
return result, err
Copy link
Member

Choose a reason for hiding this comment

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

does it make sense to return ctrl.Result{} here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, fixed

@liornoy liornoy force-pushed the add-controller-logs branch from a77519b to d753420 Compare July 24, 2023 09:31
liornoy added 3 commits July 25, 2023 10:30
IsMetalLBAvailable is the function that checks if metallb is deployed
and available, which results in the update of the metallb resource condition.

Currently, we only check the CurrentNumberScheduled, but this is doesn't take
into account a situation when the speaker pods are scheduled but are not
in the "Ready" state.
Therefore, here we add a check against ds.Status.NumberReady.

Signed-off-by: liornoy <[email protected]>
Add log to a successfuly metallb resource condition update, example of output:

1.690101009667401e+09	INFO	controllers.MetalLB	updated metallb status successfully
{"metallb": "metallb-system/metallb", "condition": "Available", "resource name": "metallb"}

Signed-off-by: liornoy <[email protected]>
Change errorMsg value to "internal error" because previously,
assigning it the error message string resulted in failure to update the condition
having the following error:

status.conditions[3].reason in body should match '^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$'",
"errorVerbose": "MetalLB.metallb.io \"metallb\" is invalid: status.conditions[3].reason: Invalid value:

i.e. the error message includes invalid characters.
we do print the error message under the status.conditions.message.

Example of the error message that includes invalid characters:

"FailedToSyncMetalLBResources: could not apply (apps/v1, Kind=Deployment) openshift-metallb-system/controller:
could not update object (apps/v1, Kind=Deployment) openshift-metallb-system/controller: Operation cannot be
fulfilled on deployments.apps \\\"controller\\\": the object has been modified; please apply your changes to the
latest version and try again\"

Signed-off-by: liornoy <[email protected]>
@liornoy liornoy force-pushed the add-controller-logs branch from d753420 to 1769567 Compare July 25, 2023 07:33
@fedepaol fedepaol merged commit 262c965 into metallb:main Jul 26, 2023
@liornoy liornoy deleted the add-controller-logs branch July 26, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants