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

sidecarSet support namespace selector #1178

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

zmberg
Copy link
Member

@zmberg zmberg commented Feb 15, 2023

Ⅰ. Describe what this PR does

sidecarSet support namespace selector

#948

@kruise-bot kruise-bot added the size/XL size/XL: 500-999 label Feb 15, 2023
nsObj, err := c.CoreV1().Namespaces().Get(context.TODO(), ns, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
nsObj.Labels["inject"] = "sidecar"
nsObj, err = c.CoreV1().Namespaces().Update(context.TODO(), nsObj, metav1.UpdateOptions{})
Copy link

Choose a reason for hiding this comment

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

48% of developers fix this issue

SA4006: this value of nsObj is never used


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@zmberg zmberg force-pushed the sidecarset_ns_selector branch from 98b4e8d to e818909 Compare February 16, 2023 03:27
@zmberg zmberg added this to the v1.4 milestone Feb 16, 2023
@zmberg zmberg added the kind/enhancement New feature or request label Feb 16, 2023
@zmberg zmberg force-pushed the sidecarset_ns_selector branch from e818909 to 4480de4 Compare February 16, 2023 05:56
@zmberg zmberg modified the milestone: v1.4 Feb 16, 2023
@@ -41,6 +41,10 @@ type SidecarSetSpec struct {
// otherwise, match pods in all namespaces(in cluster)
Namespace string `json:"namespace,omitempty"`

// NamespaceSelector selector which namespaces inject sidecar containers.
Copy link
Member

Choose a reason for hiding this comment

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

NamespaceSelector select which namespaces to inject sidecar containers.

}
if (originNamespace != "" && otherSelector != nil) ||
(otherNamespace != "" && originSelector != nil) {
return true
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 check other namesapce Selector can select the origin namespace before return true ?

@zmberg zmberg force-pushed the sidecarset_ns_selector branch from 4480de4 to 425d018 Compare February 27, 2023 08:10
@@ -325,7 +330,7 @@ func validateSidecarConflict(sidecarSets *appsv1alpha1.SidecarSetList, sidecarSe
matchedList := make([]*appsv1alpha1.SidecarSet, 0)
for i := range sidecarSets.Items {
obj := &sidecarSets.Items[i]
if !isSidecarSetNamespaceDiff(sidecarSet, obj) && util.IsSelectorOverlapping(sidecarSet.Spec.Selector, obj.Spec.Selector) {
if !isSidecarSetNamespaceDiff(c, sidecarSet, obj) && util.IsSelectorOverlapping(sidecarSet.Spec.Selector, obj.Spec.Selector) {
Copy link
Member

Choose a reason for hiding this comment

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

isSidecarSetNamespaceDiff -> isSidecarSetNamespaceOverlapping?

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
@zmberg zmberg force-pushed the sidecarset_ns_selector branch from 425d018 to 330e364 Compare February 27, 2023 08:33
@furykerry
Copy link
Member

/lgtm

@zmberg
Copy link
Member Author

zmberg commented Feb 28, 2023

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

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

@kruise-bot kruise-bot merged commit 1b3641d into openkruise:master Feb 28, 2023
ppbits pushed a commit to ppbits/kruise that referenced this pull request Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved kind/enhancement New feature or request lgtm size/XL size/XL: 500-999
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants