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

✨ Support override addon images by the cluster's annotation #231

Merged

Conversation

zhujian7
Copy link
Member

@zhujian7 zhujian7 commented Jul 25, 2023

Summary

Make the addon manger support override addon agents' images by the cluster's annotation.
If the managedCluster has annotation open-cluster-management.io/image-registries in format:

{
   "registries":[
      {
         "mirror":"quay.io/ocm/addon-examples",
         "source":"quay.io/open-cluster-management/addon-examples"
      }
   ]
}

For example:

apiVersion: cluster.open-cluster-management.io/v1
kind: ManagedCluster
metadata:
  annotations:
    open-cluster-management.io/image-registries: '{"registries":[{"mirror":"quay.io/ocm/addon-examples","source":"quay.io/open-cluster-management/addon-examples"}]}'

The addon-manager will override agent images for all the template-type addons whose images can match the source field.

Related issue(s)

Fixes #

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Patch coverage: 92.85% and project coverage change: +0.09% 🎉

Comparison is base (720ae29) 60.28% compared to head (e0e0545) 60.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #231      +/-   ##
==========================================
+ Coverage   60.28%   60.37%   +0.09%     
==========================================
  Files         132      132              
  Lines       13563    13590      +27     
==========================================
+ Hits         8176     8205      +29     
+ Misses       4632     4631       -1     
+ Partials      755      754       -1     
Flag Coverage Δ
unit 60.37% <92.85%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
pkg/addon/templateagent/template_agent.go 55.33% <0.00%> (-0.55%) ⬇️
pkg/addon/templateagent/values.go 80.64% <96.00%> (+4.64%) ⬆️
pkg/addon/controllers/addontemplate/controller.go 67.21% <100.00%> (+0.54%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhujian7
Copy link
Member Author

/hold

}

imageRegistries := ImageRegistries{}
err := json.Unmarshal([]byte(annotations[ClusterImageRegistriesAnnotation]), &imageRegistries)
Copy link
Member

Choose a reason for hiding this comment

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

can it be unmarshalled correctly if there is pullSecret filed in the annotation?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

@zhujian7
Copy link
Member Author

/unhold
cc @qiujian16

@zhujian7
Copy link
Member Author

zhujian7 commented Aug 1, 2023

Signed-off-by: zhujian <jiazhu@redhat.com>
Signed-off-by: zhujian <jiazhu@redhat.com>
Signed-off-by: zhujian <jiazhu@redhat.com>
Signed-off-by: zhujian <jiazhu@redhat.com>
@zhujian7 zhujian7 force-pushed the image-override branch 2 times, most recently from 89ed336 to e966eba Compare August 1, 2023 14:57
@zhujian7
Copy link
Member Author

zhujian7 commented Aug 2, 2023

/unhold
@qiujian16 ptal

@@ -116,6 +117,9 @@ func (a *CRDTemplateAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions {
CSRApproveCheck: a.TemplateCSRApproveCheckFunc(),
CSRSign: a.TemplateCSRSignFunc(),
},
AgentDeployTriggerClusterFilter: func(old, new *clusterv1.ManagedCluster) bool {
return !equality.Semantic.DeepEqual(old.Annotations, new.Annotations)
Copy link
Member

Choose a reason for hiding this comment

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

do you think we should only check the change of certain key? to reduce the reconcile call.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, PTAL

@zhujian7 zhujian7 force-pushed the image-override branch 2 times, most recently from ef22e4e to eae9def Compare August 3, 2023 01:25
Signed-off-by: zhujian <jiazhu@redhat.com>
@qiujian16
Copy link
Member

/approve
/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, zhujian7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Aug 3, 2023
@openshift-merge-robot openshift-merge-robot merged commit a9dae60 into open-cluster-management-io:main Aug 3, 2023
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants