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

(server) Serve CatalogMetadata resource with aggregated server #107

Closed

Conversation

anik120
Copy link
Collaborator

@anik120 anik120 commented Jul 2, 2023

Closes #39

@@ -461,7 +463,7 @@ func (r *CatalogReconciler) syncCatalogMetadata(ctx context.Context, fsys fs.FS,
ordered := sets.List(sets.KeySet(newCatalogMetadataObjs))
for _, catalogMetadataName := range ordered {
newcatalogMetadata := newCatalogMetadataObjs[catalogMetadataName]
if err := r.Client.Patch(ctx, newcatalogMetadata, client.Apply, &client.PatchOptions{Force: pointer.Bool(true), FieldManager: "catalog-controller"}); err != nil {
if err := r.Client.Create(ctx, newcatalogMetadata); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: The generic storage that the etcd storage implementation is based on that is used by the server only has three interfaces, I.e it supports Create, Update and Delete, but doesn't understand Patch. Switched this out to Create for now, since we're anyway deleting the existing matching resources in L453-L459 above, so Patching seems redundant anyway. Eventually we do have to figure out Patching for any store we use though (see this comment for more details).

Copy link
Collaborator

Choose a reason for hiding this comment

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

So I think we might actually run into an issue with this - the delete above is specifically deleting CatalogMetadata resources that should no longer exist based on the reconciliation of a Catalog resource. I.e if a Catalog resource is updated and is reconciled again it only deletes CatalogMetadata resources that should no longer exist based on the unpacking of the Catalog contents. This PATCH request is making sure that we update any CatalogMetadata resources that should still exist but may need to be updated and updates them using server-side apply.

@anik120 anik120 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 3, 2023
Copy link
Collaborator

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

Overall this looks good, great work @anik120!

I do have some comments:

Comment on lines +170 to +173
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager --timeout=60s
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-cainjector --timeout=60s
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the weird spacing here just a GH thing or are these intentionally tabbed over?


var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "optional.catalogd.operatorframework.io", Version: "v1alpha1"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: The Group name containing optional seems like it could be confusing. In reality these apis aren't "optional" in the sense that you can just choose to not use them right? Maybe something like storage.catalogd.operatorframework.io would be better?

Dockerfile Outdated Show resolved Hide resolved
@@ -0,0 +1,21 @@
/*
Copyright 2022.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Copyright year should be 2023 (should apply for all the added files)

Suggested change
Copyright 2022.
Copyright 2023.

api/optional/v1alpha1/groupversion_info.go Outdated Show resolved Hide resolved
- apiGroups:
- optional.catalogd.operatorframework.io
resources:
- catalogmetadatas
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Is the additional "s" at the end of the name intentional? I know the Kubernetes pluralization logic isn't the greatest but I think catalogmetadata works as both singular and plural and because of that is, IMO, more intuitive and easier to remember than catalogmetadatas

@@ -444,7 +446,7 @@ func (r *CatalogReconciler) syncCatalogMetadata(ctx context.Context, fsys fs.FS,
return fmt.Errorf("unable to parse declarative config into CatalogMetadata API: %w", err)
}

var existingCatalogMetadataObjs v1alpha1.CatalogMetadataList
var existingCatalogMetadataObjs optionalv1alpha1.CatalogMetadataList
if err := r.List(ctx, &existingCatalogMetadataObjs); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not for this PR but something I just noticed - we should add some list options here to ensure that we are only fetching CatalogMetadata resources for the Catalog being reconciled. Right now I think this list call results in all CatalogMetadata being fetched which could result in the deletion of CatalogMetadata resources not owned by this Catalog resource

@@ -461,7 +463,7 @@ func (r *CatalogReconciler) syncCatalogMetadata(ctx context.Context, fsys fs.FS,
ordered := sets.List(sets.KeySet(newCatalogMetadataObjs))
for _, catalogMetadataName := range ordered {
newcatalogMetadata := newCatalogMetadataObjs[catalogMetadataName]
if err := r.Client.Patch(ctx, newcatalogMetadata, client.Apply, &client.PatchOptions{Force: pointer.Bool(true), FieldManager: "catalog-controller"}); err != nil {
if err := r.Client.Create(ctx, newcatalogMetadata); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So I think we might actually run into an issue with this - the delete above is specifically deleting CatalogMetadata resources that should no longer exist based on the reconciliation of a Catalog resource. I.e if a Catalog resource is updated and is reconciled again it only deletes CatalogMetadata resources that should no longer exist based on the unpacking of the Catalog contents. This PATCH request is making sure that we update any CatalogMetadata resources that should still exist but may need to be updated and updates them using server-side apply.

@anik120 anik120 force-pushed the catalogmetadata-server branch 2 times, most recently from 98e60c4 to f9c3157 Compare July 3, 2023 16:50
Closes operator-framework#39

Signed-off-by: Anik <anikbhattacharya93@gmail.com>
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2023
@openshift-merge-robot
Copy link

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@joelanford
Copy link
Member

Shall we close this PR?

@joelanford joelanford closed this Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Catalogmetadata CRD and serve CatalogMetadata with aggregated apiserver
4 participants