Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

(feat): Communicate "Ready" Status of CatalogSource CR#17

Merged
joelanford merged 6 commits intooperator-framework:mainfrom
everettraven:feature/ready-status
Apr 7, 2023
Merged

(feat): Communicate "Ready" Status of CatalogSource CR#17
joelanford merged 6 commits intooperator-framework:mainfrom
everettraven:feature/ready-status

Conversation

@everettraven
Copy link
Copy Markdown
Collaborator

Description

  • Update the CatalogSourceStatus type to include a Conditions field for communicating status conditions
  • Add some constants for communicating a status of Ready
  • Set the status to Ready at the end of the reconciliation loop (once all contents are on cluster)

Motivation

Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
Copy link
Copy Markdown
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

Looks good! We could handle others in follow up.
/lgtm

const (
TypeReady = "Ready"

ReasonContentsAvailable = "ContentsAvailable"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could do in a follow up too. But having all the conditions and reasons added to an array eventually would help in testing condition invariants as in here in future.

Comment thread pkg/apis/core/v1beta1/catalogsource_types.go Outdated
Comment thread pkg/controllers/core/catalogsource_controller.go
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Mar 30, 2023
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2023
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Mar 31, 2023

New changes are detected. LGTM label has been removed.

Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
func (r *CatalogSourceReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&corev1beta1.CatalogSource{}).
For(&corev1beta1.CatalogSource{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't do this. If someone/something changes the status out from under us, we should go back and re-reconcile.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Currently since we don't have good error handling, not having this results in the controller getting into an error state because once we update the status it requeues and then errors out when trying to create all the Packages again even though they already exist.

Would you be okay with this going in for now and fixing it along with the changes needed for #6 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure, can you add a TODO comment, summarizing that in the code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And maybe it makes sense to have a separate issue about just that particular problem?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should be resolved by 80fbb30

Comment on lines +107 to +109
if err := r.Client.Status().Update(ctx, &catalogSource); err != nil {
return ctrl.Result{}, fmt.Errorf("updating catalogsource status: %v", err)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For follow-up: we should check to see if the status changed to avoid unecessary update calls. I think this may be covered by #5

Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

For follow-up: We should go ahead and add controller Reconcile unit tests in the near future so that we get in the habit of adding/updating these tests and we update functionality.

Comment on lines +114 to +121
func updateStatusReady(catalogSource *corev1beta1.CatalogSource) {
meta.SetStatusCondition(&catalogSource.Status.Conditions, metav1.Condition{
Type: corev1beta1.TypeReady,
Reason: corev1beta1.ReasonContentsAvailable,
Status: metav1.ConditionTrue,
Message: "catalog contents have been unpacked and are available on cluster",
})
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In all of the other scenarios when we return an error from Reconcile, we need to set this condition somehow. For now, I think it's fine to always say Status: false with the error message.

But eventually we'll need to consider what happens when an old version of the catalog is available but we had a problem unpacking/syncing the new version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That is partially the goal of #6 but if we want it loosely implemented in this PR I am happy to update it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I'd propose we at least do the big picture invariant of "all conditions are updated somehow in every Reconcile pass"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should be resolved as of bf10f4f

@everettraven

This comment was marked as resolved.

Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
@joelanford joelanford merged commit d9955b3 into operator-framework:main Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signal CatalogSource Ready status

4 participants