-
Notifications
You must be signed in to change notification settings - Fork 0
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
[BOP-85][BOP-87] Add events and status for Addon and Manifest CRs #16
Conversation
1c7a20b
to
e527127
Compare
api/v1alpha1/addon_types.go
Outdated
ComponentProgressing StatusConditionType = "Progressing" | ||
|
||
// ComponentDegraded means the component is not operating as desired and user action is required. | ||
ComponentDegraded StatusConditionType = "Degraded" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Degraded sounds a bit confusing. Can we change it to something else?
It can be easily misinterpreted as the addon is degraded to a lower version. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add Unhealthy
also. Degraded
is used for something running slow or in a lower version (as Sakshi mentioned). Unhealthy
is for something not running at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since these are standard k8s status terms, are we sure they aren't available in a library so we don't have to duplicate them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find these defined anywhere in at least the k8s standard libraries.
I'm not against adding Unhealthy
status, I didn't see it being used in kubebuilder anywhere or in calico operator where I got most of these definitions from. I think having both is fine so will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@tppolkow Would it make sense to wait for the manifest update support as well? I don't intend to delay this PR. Just wanted to bring to your notice so that we don't miss it. |
I think we can just merge whichever is ready first, I can do a second pass for events/status updates related to manifest updates together with the PR I will put up for HelmChart events/statuses once your PR is merged. |
controllers/addon_controller.go
Outdated
@@ -63,6 +69,11 @@ func (r *AddonReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
// only update the status to progressing if its not already set to not trigger infinite reconciliations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is this something that you ran into while developing? According to the kubebuilder documentation, updates to status
should not trigger a reconcile as this does not update the generation of the object.
suggestion: If the reconcile is still triggered, we should use the following predicate to filter changes where generation has not been changed:
// SetupWithManager sets up the controller with the Manager.
func (r *AddonReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&boundlessv1alpha1.Addon{}).
WithEventFilter(predicate.GenerationChangedPredicate{}).
Complete(r)
}
Reference:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is an issue I discovered during development. I tested it again now to double check and the operator is infinitely reconciling without this condition. Essentially each status update triggers a reconcile , which in turn updates the status, which results in another reconcile thus the infinite loop. I will look into the event filter option, agree it seems much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The predicate works to prevent the reconciliation issue. I've added it for now, but think we will need to update it when we implement the approach you suggested in your other comment since we will want reconciliation triggered from updates to child manifests/helmcharts.
controllers/addon_controller.go
Outdated
@@ -63,6 +70,11 @@ func (r *AddonReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
// only update the status to progressing if its not already set to not trigger infinite reconciliations | |||
if instance.Status.Type == "" { | |||
r.updateStatus(ctx, logger, req.NamespacedName, boundlessv1alpha1.TypeComponentProgressing, "Creating Addon") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: I think we should avoid updating status at this (and other such stages). Controller should only do one status update at the end.
To implement the same behavior, controller should watch the the resources it needs to update its Status
field. So, AddonController
should watch HelmChart
and Manifest
CRD. And then check for their statuses to populate its own status.
I think HelmChart
and Manifest
should be owned by AddonController
(https://book.kubebuilder.io/reference/watching-resources/operator-managed). Then it will get called for those objects too.
Or alternatively, this can Watch
HelmChart.Status
and Manifest.Status
(if that is possible).
References:
- https://cloud.redhat.com/blog/kubernetes-operators-best-practices
- https://medium.com/@gallettilance/10-things-you-should-know-before-writing-a-kubernetes-controller-83de8f86d659
This does not need to prevent merging this PR, but we should create a followup task or @todo to look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach makes sense to me for Addons - essentially we have the Addon react to changes in status from child Helmcharts and Manifests. Are you thinking this approach be limited to AddonController
... whereas HelmChart
and Manifest
do statuses more explicitly ? Since for Manifest and HelmCharts we don't know beforehand what resources are created.
Added a @todo, will take this up in follow up PR once helmchart statuses are figured out and we have updates for manifest working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Refactor AddonStatus & ManifestStatus to use common Status; Add unhealthy status type BOP-85/BOP-87 Cleanup imports Add predicate to prevent infinite reconcilations Improve manifest event messages; Add delay for requeues due to issues reaching manifest url
Add events & status to
Addon
&Manifest
Objects.The events are also annotated with
Addon
label. We can tie all events for addon with below command. This will be useful by the CLI to get events for a specific addon.Status fields for both
manifest
andaddon
objects is also reported when we get the resource. Status is specific to the specific CR, status of child CRs does not affect the parent Addon status.