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

fix that the InterpretDependency operation is absent in the validatin… #3052

Merged

Conversation

whitewindmills
Copy link
Member

The following error occurred when registering the InterpretDependency operation.

webhook.go:189] failed to register the ResourceInterpreterWebhookConfiguration to Karmada: admission webhook "resourceinterpreter.config.karmada.io" denied the request: webhooks[0].rules[0].operations[5]: Unsupported value: "InterpretDependency": supported values: "*", "AggregateStatus", "InterpretHealth", "InterpretReplica", "InterpretReplicaRequirement", "InterpretStatus", "Retain", "ReviseReplica"

Signed-off-by: hejunhua jayfantasyhjh@gmail.com

What type of PR is this?
/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

karmada-webhook: Fixed the issue that the InterpretDependency operation can't be registered.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 14, 2023
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2023

Codecov Report

Merging #3052 (4bce472) into master (aa5868a) will increase coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3052      +/-   ##
==========================================
+ Coverage   38.96%   38.99%   +0.02%     
==========================================
  Files         207      207              
  Lines       19365    19365              
==========================================
+ Hits         7546     7551       +5     
+ Misses      11362    11358       -4     
+ Partials      457      456       -1     
Flag Coverage Δ
unittests 38.99% <ø> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
pkg/webhook/configuration/validating.go 71.42% <ø> (ø)
pkg/search/proxy/store/util.go 94.31% <0.00%> (+0.94%) ⬆️
pkg/search/proxy/store/store.go 68.42% <0.00%> (+3.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@whitewindmills whitewindmills marked this pull request as draft January 14, 2023 10:06
@karmada-bot karmada-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 14, 2023
@whitewindmills whitewindmills marked this pull request as ready for review January 14, 2023 12:21
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 14, 2023
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

Leave approve to @XiShanYongYe-Chang

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 15, 2023
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot~

Comment on lines 289 to 318
gomega.Eventually(func(g gomega.Gomega) (int, error) {
resourceBinding, err := karmadaClient.WorkV1alpha2().ResourceBindings(configMapNamespace).Get(context.TODO(), resourceBindingName, metav1.GetOptions{})
g.Expect(err).NotTo(gomega.HaveOccurred())

klog.Infof("Attached ResourceBinding(%s/%s)'s schedule result is %v, existing schedule result is expected.",
resourceBinding.Namespace, resourceBinding.Name, resourceBinding.Spec.RequiredBy)
return len(resourceBinding.Spec.RequiredBy), nil
}, pollTimeout, pollInterval).ShouldNot(gomega.BeZero())
})
})
})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can directly determine whether the cm is distributed to the target member cluster.

Copy link
Member Author

Choose a reason for hiding this comment

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

Strictly speaking, we only need to check whether the dependent configmap is correctly interpreted, as for whether it is distributed to the relevant member clusters, I don't think it does care because the configmap is distributed is not the responsibility of the InterpretDependency operation. Maybe there is wrong with the execution_controller or binding_controller?

Copy link
Member

Choose a reason for hiding this comment

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

For other operations, propagating cm is unnecessary because it consumes extra resources and may affect our analysis of e2e when it goes wrong.

Copy link
Member

Choose a reason for hiding this comment

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

We should clearly judge the resources that follow the distribution.

Maybe we can directly determine whether the cm is distributed to the target member cluster.

It's just a suggestion. The feature dependency distribute is dependent on the two controllers you mentioned, so I think it's reasonable to test the entire process.

@@ -271,6 +280,23 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
})
})
})

ginkgo.Context("InterpreterOperation InterpretDependency testing", func() {
Copy link
Member

Choose a reason for hiding this comment

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

We can set the relevant cm only for operation InterpretDependency, such as:

@@ -30,7 +30,6 @@ import (
 var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
        var policyNamespace, policyName string
        var workloadNamespace, workloadName string
-       var configMapNamespace, configMapName string
        var workload *workloadv1alpha1.Workload
        var policy *policyv1alpha1.PropagationPolicy
        var cm *corev1.ConfigMap
@@ -40,10 +39,7 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
                policyName = workloadNamePrefix + rand.String(RandomStrLength)
                workloadNamespace = testNamespace
                workloadName = policyName
-               configMapNamespace = testNamespace
-               configMapName = configMapNamePrefix + rand.String(RandomStrLength)
-
-               workload = testhelper.NewWorkload(workloadNamespace, workloadName, configMapName)
+               workload = testhelper.NewWorkload(workloadNamespace, workloadName)
                policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
                        {
                                APIVersion: workload.APIVersion,
@@ -55,19 +51,14 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
                                ClusterNames: framework.ClusterNames(),
                        },
                })
-               // configmaps should be propagated automatically.
-               policy.Spec.PropagateDeps = true
-               cm = testhelper.NewConfigMap(configMapNamespace, configMapName, map[string]string{"RUN_ENV": "test"})
        })

        ginkgo.JustBeforeEach(func() {
                framework.CreatePropagationPolicy(karmadaClient, policy)
                framework.CreateWorkload(dynamicClient, workload)
-               framework.CreateConfigMap(kubeClient, cm)
                ginkgo.DeferCleanup(func() {
                        framework.RemoveWorkload(dynamicClient, workload.Namespace, workload.Name)
                        framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
-                       framework.RemoveConfigMap(kubeClient, configMapNamespace, configMapName)
                })
        })

@@ -282,6 +273,28 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
        })

        ginkgo.Context("InterpreterOperation InterpretDependency testing", func() {
+               var configMapNamespace, configMapName string
+
+               ginkgo.BeforeEach(func() {
+                       configMapNamespace = testNamespace
+                       configMapName = configMapNamePrefix + rand.String(RandomStrLength)
+
+                       workload.Spec.Template.Spec.Containers[0].EnvFrom = []corev1.EnvFromSource{
+                               {ConfigMapRef: &corev1.ConfigMapEnvSource{
+                                       LocalObjectReference: corev1.LocalObjectReference{Name: configMapName},
+                                       Optional:             pointer.Bool(true),
+                               }}}
+
+                       // configmaps should be propagated automatically.
+                       policy.Spec.PropagateDeps = true
+                       cm = testhelper.NewConfigMap(configMapNamespace, configMapName, map[string]string{"RUN_ENV": "test"})
+
+                       framework.CreateConfigMap(kubeClient, cm)
+                       ginkgo.DeferCleanup(func() {
+                               framework.RemoveConfigMap(kubeClient, configMapNamespace, configMapName)
+                       })
+               })
+
                ginkgo.It("InterpretDependency testing", 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.

You're right, but is it really necessary to tweak? maybe it will be used in the future for additional test cases, I think.

Copy link
Member

Choose a reason for hiding this comment

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

You're right, but is it really necessary to tweak? maybe it will be used in the future for additional test cases, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sorry I don't get it.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I typo the wrong words, what I want to say is:

For other operations, propagating comfigmap is unnecessary because it consumes extra resources and may affect our analysis of e2e when it goes wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your suggestions. I'll improve the test case.

@whitewindmills whitewindmills force-pushed the fix-interpretDependency-webhook branch 2 times, most recently from fbf8123 to 4bce472 Compare January 17, 2023 03:47
@whitewindmills
Copy link
Member Author

@XiShanYongYe-Chang
Hi, could you check again and approve it?

@RainbowMango
Copy link
Member

@whitewindmills Could you please squash your commits?

…g webhook

Signed-off-by: hejunhua <jayfantasyhjh@gmail.com>

fix e2e problem

Signed-off-by: hejunhua <jayfantasyhjh@gmail.com>

fix test case

Signed-off-by: hejunhua <jayfantasyhjh@gmail.com>
@XiShanYongYe-Chang
Copy link
Member

@XiShanYongYe-Chang
Hi, could you check again and approve it?

Ok, I will check it later.

@XiShanYongYe-Chang
Copy link
Member

Thanks a lot~
/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 17, 2023
@karmada-bot karmada-bot merged commit ed01303 into karmada-io:master Jan 17, 2023
@XiShanYongYe-Chang
Copy link
Member

Hi @whitewindmills, I think we need to cherry-pick it to the previous release, can you help do it?

karmada-bot added a commit that referenced this pull request Jan 29, 2023
…k-of-#3052-upstream-release-1.3

Automated cherry pick of #3052: fix that the InterpretDependency operation is absent in the
karmada-bot added a commit that referenced this pull request Jan 29, 2023
…k-of-#3052-upstream-release-1.2

Automated cherry pick of #3052: fix that the InterpretDependency operation is absent in the
@whitewindmills whitewindmills deleted the fix-interpretDependency-webhook branch February 28, 2023 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants