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

Make use of sidecar inject label across repos #41163

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

hzxuzhonghu
Copy link
Member

Please provide a description of this PR:

To help us figure out who should review this PR, please put an X in all the areas that this PR affects.

  • Ambient
  • Configuration Infrastructure
  • Docs
  • Installation
  • Networking
  • Performance and Scalability
  • Policies and Telemetry
  • Security
  • Test and Release
  • User Experience
  • Developer Infrastructure

Please check any characteristics that apply to this pull request.

  • Does not have any user-facing changes. This may include CLI changes, API changes, behavior changes, performance improvements, etc.

@hzxuzhonghu hzxuzhonghu requested review from a team as code owners September 26, 2022 09:26
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 26, 2022
// If pod has the sidecar container set, then, the pod is in the mesh
if hasIstioProxy(containers) {
return true
}

// If Pod has labels, return the injection label value
Copy link
Member

Choose a reason for hiding this comment

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

The check on L55 is more robust

Copy link
Member Author

Choose a reason for hiding this comment

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

Confused, shouldn't labels be respected over annotations

Copy link
Member

Choose a reason for hiding this comment

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

I misunderstood

// enabled is true when deployment d PodSpec has either the annotation 'sidecar.istio.io/inject: "true"'
// ok is true when the PodSpec doesn't have the 'sidecar.istio.io/inject' annotation present.
// enabled is true when deployment d PodSpec has either the label/annotation 'sidecar.istio.io/inject: "true"'
// ok is true when the PodSpec doesn't have the 'sidecar.istio.io/inject' label/annotation present.
func getPodSidecarInjectionStatus(annos map[string]string) (enabled bool, ok bool) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: annos is not a great name anymore

v, ok := annos[annotation.SidecarInject.Name]
return v == "true", ok
v, ok := annos[label.SidecarInject.Name]
return strings.EqualFold(v, "true"), ok
Copy link
Member

Choose a reason for hiding this comment

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

TRUE is not valid

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 am not sure, actually in some other places we compare with EqualFold.

Can you confirm?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also ParseBool is used

@howardjohn
Copy link
Member

howardjohn commented Sep 27, 2022 via email

@hzxuzhonghu hzxuzhonghu added the release-notes-none Indicates a PR that does not require release notes. label Sep 27, 2022
@hzxuzhonghu
Copy link
Member Author

@istio/wg-user-experience-maintainers

@hzxuzhonghu
Copy link
Member Author

/retest

// If pod has the sidecar container set, then, the pod is in the mesh
if hasIstioProxy(containers) {
return true
}

// If Pod has labels, return the injection label value
Copy link
Member

Choose a reason for hiding this comment

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

I misunderstood

@hzxuzhonghu
Copy link
Member Author

kindly ping @istio/wg-user-experience-maintainers

Copy link
Member

@hanxiaop hanxiaop left a comment

Choose a reason for hiding this comment

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

LGTM

@istio-testing istio-testing merged commit 72e3587 into istio:master Sep 29, 2022
@hzxuzhonghu hzxuzhonghu deleted the sidecar-inject-label branch September 29, 2022 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. 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.

4 participants