-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
@@ -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 { |
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.
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).
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.
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.
e516c98
to
d89938a
Compare
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.
Overall this looks good, great work @anik120!
I do have some comments:
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 |
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.
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"} |
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.
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?
api/optional/doc.go
Outdated
@@ -0,0 +1,21 @@ | |||
/* | |||
Copyright 2022. |
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.
Nit: Copyright year should be 2023 (should apply for all the added files)
Copyright 2022. | |
Copyright 2023. |
- apiGroups: | ||
- optional.catalogd.operatorframework.io | ||
resources: | ||
- catalogmetadatas |
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.
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 { |
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.
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 { |
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.
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.
98e60c4
to
f9c3157
Compare
Closes operator-framework#39 Signed-off-by: Anik <[email protected]>
f9c3157
to
0de33f4
Compare
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. |
Shall we close this PR? |
Closes #39