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 inject sidecar container to all Pods in some namespaces #1369

Closed

Conversation

xiangpingjiang
Copy link
Contributor

Ⅰ. Describe what this PR does

Ⅱ. Does this pull request fix one issue?

fixes #1368

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fillzpp for approval by writing /assign @fillzpp in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 added the size/M size/M: 30-99 label Aug 15, 2023
Signed-off-by: pingjiang <xiangpingjiang1998@gmail.com>
@@ -1244,6 +1244,32 @@ func TestPodMatchedSidecarSet(t *testing.T) {
},
expect: false,
},
{
Copy link
Member

Choose a reason for hiding this comment

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

You need modidy the sidecarSet webhook and controller.

And you must add e2e for this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, please review my latest pr, thanks

Signed-off-by: pingjiang <xiangpingjiang1998@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.21%. Comparing base (321c991) to head (c7959cc).
Report is 52 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1369      +/-   ##
==========================================
- Coverage   48.25%   48.21%   -0.04%     
==========================================
  Files         152      152              
  Lines       21469    21476       +7     
==========================================
- Hits        10359    10354       -5     
- Misses       9973     9981       +8     
- Partials     1137     1141       +4     
Flag Coverage Δ
unittests 48.21% <100.00%> (-0.04%) ⬇️

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.

@@ -103,6 +103,10 @@ func PodMatchedSidecarSet(c client.Client, pod *corev1.Pod, sidecarSet *appsv1al
if err != nil {
return false, err
}
// if no selector set, return true
if selector.String() == "" {
Copy link
Member

Choose a reason for hiding this comment

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

if selector.Empty() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

selector.Empty() return false when no selector set, so I turned to selector.String() == ""

// if no selector set, return true
if selector.String() == "" {
return true, nil
}

if !selector.Empty() && selector.Matches(labels.Set(pod.Labels)) {
Copy link
Member

Choose a reason for hiding this comment

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

remove the !selector.Empty()

@@ -310,6 +310,9 @@ func (p *Processor) getMatchingPods(s *appsv1alpha1.SidecarSet) ([]*corev1.Pod,
func (p *Processor) getSelectedPods(namespaces sets.String, selector labels.Selector) (relatedPods []*corev1.Pod, err error) {
// DisableDeepCopy:true, indicates must be deep copy before update pod objection
listOpts := &client.ListOptions{LabelSelector: selector}
if selector.String() == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Remove the If, and i think it will be ok.

Copy link
Contributor Author

@xiangpingjiang xiangpingjiang Sep 6, 2023

Choose a reason for hiding this comment

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

It won't work,
Because if we remove

	if selector.String() == "" {
		listOpts = &client.ListOptions{}
	}

when sidecarSet.Spec.Selector = nil , p.Client.List(context.TODO(), allPods, listOpts, utilclient.DisableDeepCopy) get always allPods.Items = 0.

Copy link

stale bot commented Dec 6, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 6, 2023
@xiangpingjiang
Copy link
Contributor Author

/hold

@stale stale bot removed the wontfix This will not be worked on label Dec 6, 2023
Copy link

stale bot commented Mar 6, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 6, 2024
@stale stale bot closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold size/M size/M: 30-99 wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] SidecarSet inject sidecar container to all Pods in some namespaces.
4 participants