-
Notifications
You must be signed in to change notification settings - Fork 107
✨ support wildcard in ManifestConfigs #703
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 wildcard in ManifestConfigs #703
Conversation
168baec
to
56b15f7
Compare
/assign @qiujian16 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #703 +/- ##
==========================================
+ Coverage 63.37% 63.41% +0.04%
==========================================
Files 185 185
Lines 17771 17800 +29
==========================================
+ Hits 11262 11288 +26
- Misses 5578 5580 +2
- Partials 931 932 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
1384011
to
a85a74f
Compare
@@ -195,7 +195,7 @@ func (m *manifestworkReconciler) applyOneManifest( | |||
requiredOwner := manageOwnerRef(ownedByTheWork, owner) | |||
|
|||
// find update strategy option. | |||
option := helper.FindManifestConiguration(resMeta, workSpec.ManifestConfigs) | |||
option := helper.FindManifestConfiguration(resMeta, workSpec.ManifestConfigs) |
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.
I would want updateStrategy also support wildcard match. I think we should have helper.FindManifestConfigurations(resMeta, workSpec.ManifestConfigs) returns a list. For updateStrategy, we pick the first or latest item in the list, while for feedback rules, we pick every item.
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.
returned a list of options .
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.
while for feedback rules, we pick every item.
@zhiweiyin318 want to confirm for the current implementation, do we only pick up the first one?
// only handle the first option if the resource matches more than one option
// need avoid a resource from being matched to more options.
option := options[0]
if len(option.FeedbackRules) == 0 {
return values, metav1.Condition{
Type: statusFeedbackConditionType,
Reason: "NoStatusFeedbackSynced",
Status: metav1.ConditionTrue,
}
}
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.
fixed. for feedbackRule, will pick all matched options.
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.
changed to only pick up the first one for feedbackRule and installStrategy.
Namespace: commOptions.SpokeClusterName, | ||
Name: "deploy1", | ||
Namespace: "*", | ||
Name: "*1", |
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.
we should have some more tests for wildcard case.
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.
added
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.
We should also have another test with multiple matched options.
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.
done
a85a74f
to
df0c872
Compare
44ef2b0
to
1979c48
Compare
7f6b264
to
1749db2
Compare
added more integration tests in feedBackRule and upgradeStrategy :
|
// need avoid a resource from being matched to more options. | ||
option := workapiv1.ManifestConfigOption{} | ||
if len(options) > 0 { | ||
option = options[0] |
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.
If we only handle the first option, can we break the iteration when the first option found at https://github.com/open-cluster-management-io/ocm/pull/703/files#diff-1eb19addc11cd8fecd6bf310d649d8799c6676d69366230d21916e497f547f77R377, and set the default update strategy there also.
this may make the statusfeedback controller simpler as well.
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.
fixed. for feedbackRule, will pick all matched options.
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.
I am not sure it works. Each feedback result have a unique name, and it should not be overlapped.
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.
changed to only pick up the first one for feedbackRule and installStrategy.
f90bc3d
to
cc7a77a
Compare
/lgtm |
cc7a77a
to
6d66ad5
Compare
41f5d77
to
17a6d0c
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiujian16, zhiweiyin318 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 |
@zhujian7 @qiujian16 please take a look again. |
pkg/work/helper/helpers.go
Outdated
resourceMeta.Resource == option.ResourceIdentifier.Resource && | ||
wildcardMatch(resourceMeta.Namespace, option.ResourceIdentifier.Namespace) && | ||
wildcardMatch(resourceMeta.Name, option.ResourceIdentifier.Name) { | ||
return &option |
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.
- If two options matched, the first configured the FeedbackRules but no UpdateStrategy, and the second configured the UpdateStrategy but no FeedbackRules, will returning the first option cause the FeedbackRules to be lost?
- I am still considering if we should make the word-by-word matching take precedence over wildcard matching?
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.
good catch.
The old logic still has this issue.
Let me split FindManifestConfiguration to 2 functions for feedbackRule and UpdateStrategy, and check if there is feedbackRule and UpdateStrategy.
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.
If two options matched, the first configured the FeedbackRules but no UpdateStrategy, and the second configured the UpdateStrategy but no FeedbackRules, will returning the first option cause the FeedbackRules to be lost?
fixed by splitting the FindManifestConfiguration into 2 functions.
I am still considering if we should make the word-by-word matching take precedence over wildcard matching?
I think the users only use the first option to filter resources in the most cases, so word-by-word matching is the same level as wildcard matching.
@qiujian16 WDYT?
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.
could we just build a new option finding the first available rule and the first updateStrategy in the FindManifestConfiguration?
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.
done. changed to one FindManifestConfiguration and return an option with the first matched updateStrategy and feedbackRule.
17a6d0c
to
36a5d8b
Compare
296487b
to
a34b86c
Compare
Signed-off-by: Zhiwei Yin <[email protected]>
a34b86c
to
669d798
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.
/lgtm
/unhold |
fa3a30b
into
open-cluster-management-io:main
Summary
Support wildcard in the name and namespace of ManifestConfigs.ResourceIdentifier for feedbackRule and updateStrategy.
if the a resource matches more than 1 options, only the first one works.
Related issue(s)
#705
Fixes #