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

✨ addon: add support for multiple GVK #585

Merged

Conversation

haoqing0110
Copy link
Member

Summary

Related issue(s)

Ref: #547

adds test cases

updates mergeAddonConfig function to match new multi same-gvk configs

Signed-off-by: Joao Marcal <jmarcal@redhat.com>
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 11 lines in your changes missing coverage. Please review.

Project coverage is 63.74%. Comparing base (5623a4b) to head (ca344f4).
Report is 7 commits behind head on main.

Files Patch % Lines
pkg/addon/controllers/addonconfiguration/graph.go 93.10% 3 Missing and 3 partials ⚠️
...on/controllers/cmainstallprogression/controller.go 85.71% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #585      +/-   ##
==========================================
+ Coverage   62.60%   63.74%   +1.14%     
==========================================
  Files         181      181              
  Lines       13964    14039      +75     
==========================================
+ Hits         8742     8949     +207     
+ Misses       4338     4195     -143     
- Partials      884      895      +11     
Flag Coverage Δ
unit 63.74% <92.30%> (+1.14%) ⬆️

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

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

@haoqing0110 haoqing0110 force-pushed the multiple-gvk branch 3 times, most recently from 19d6f36 to 74d73d7 Compare August 2, 2024 08:15
Signed-off-by: haoqing0110 <qhao@redhat.com>
@haoqing0110
Copy link
Member Author

/assign @qiujian16
/cc @JoaoBraveCoding

Copy link
Contributor

openshift-ci bot commented Aug 5, 2024

@haoqing0110: GitHub didn't allow me to request PR reviews from the following users: JoaoBraveCoding.

Note that only open-cluster-management-io members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/assign @qiujian16
/cc @JoaoBraveCoding

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-sigs/prow repository.

for _, config := range mcaCopy.Status.ConfigReferences {
if _, ok := desiredConfigMap[config.ConfigGroupResource]; ok {
mergedConfigs = append(mergedConfigs, config)
for _, configRef := range mcaCopy.Status.ConfigReferences {
Copy link
Member

Choose a reason for hiding this comment

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

add some comments for each for loop

Copy link
Member Author

Choose a reason for hiding this comment

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

added.

output := addonConfigMap{}
for k, v := range d {
output[k] = v
func (m addonConfigMap) copy() addonConfigMap {
Copy link
Member

Choose a reason for hiding this comment

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

is this a deepcopy?

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, update the code.

@@ -461,3 +495,53 @@ func rolloutStatusHasCluster(clusterRolloutStatus []clustersdkv1alpha1.ClusterRo
}
return false
}

func overrideConfigMapByInstallConfigRef(
Copy link
Member

Choose a reason for hiding this comment

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

comment on this func

Copy link
Member Author

Choose a reason for hiding this comment

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

added.

}
}

func overrideConfigMapByAddOnConfigs(
Copy link
Member

Choose a reason for hiding this comment

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

ditto we need more docs for matinability

Copy link
Member Author

Choose a reason for hiding this comment

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

added

addOnConfigs []addonv1alpha1.AddOnConfig,
desiredConfigs map[addonv1alpha1.ConfigGroupResource][]addonv1alpha1.ConfigReferent,
) {
gvkOverwritten := make(map[addonv1alpha1.ConfigGroupResource]struct{})
Copy link
Member

Choose a reason for hiding this comment

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

can we uset Set generic here?

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, have modified the code to use sets.

@@ -48,14 +48,14 @@ type addonNode struct {
status *clustersdkv1alpha1.ClusterRolloutStatus
}

type addonConfigMap map[addonv1alpha1.ConfigGroupResource]addonv1alpha1.ConfigReference
type addonConfigMap map[addonv1alpha1.ConfigGroupResource][]addonv1alpha1.ConfigReference
Copy link
Member

Choose a reason for hiding this comment

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

would it be easier if we use something like
type addonConfigMap map[addonv1alpha1.ConfigGroupResource]set.Set[addonv1alpha1.ConfigReference]?

Copy link
Member Author

Choose a reason for hiding this comment

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

For the ConfigReference, we use it to store ConfigGroupResource, DesiredConfig, LastObservedGeneration and LastAppliedConfig, while only use ConfigGroupResource and DesiredConfig.ConfigReferent when doing comparison, it seems not be able to use the strengths of sets, like Has().

Signed-off-by: haoqing0110 <qhao@redhat.com>
Copy link
Member

@qiujian16 qiujian16 left a comment

Choose a reason for hiding this comment

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

/approve

@haoqing0110
Copy link
Member Author

@JoaoBraveCoding could you help take a look?

Copy link

@iblancasa iblancasa left a comment

Choose a reason for hiding this comment

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

Great job!

Copy link
Contributor

openshift-ci bot commented Aug 12, 2024

@iblancasa: changing LGTM is restricted to collaborators

In response to this:

Great job!

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-sigs/prow repository.

Copy link
Contributor

openshift-ci bot commented Aug 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haoqing0110, iblancasa, qiujian16

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

@haoqing0110 haoqing0110 changed the title [WIP] ✨ addon: add support for multiple GVK ✨ addon: add support for multiple GVK Aug 13, 2024
@qiujian16
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Aug 13, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit dfa835d into open-cluster-management-io:main Aug 13, 2024
16 checks passed
@haoqing0110 haoqing0110 deleted the multiple-gvk branch August 13, 2024 01:55
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