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

🐛 Adding metrics container port in tilt-prepare only if it's missing #9308

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

prometherion
Copy link
Contributor

What this PR does / why we need it:
tilt-prepare should add the metrics port to add-on workload containers only if it's missing to prevent API validation errors since ports must be unique.

Which issue(s) this PR fixes:
Fixes #9306

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 25, 2023
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 25, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @prometherion. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -848,6 +851,16 @@ func prepareWorkload(name, prefix, binaryName, containerName string, objs []unst
})
}

func containerHasMetricsPort(ports []corev1.ContainerPort) bool {
for _, port := range ports {
if port.ContainerPort == 8080 && port.Name == "metrics" && port.Protocol == corev1.ProtocolTCP {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if port.ContainerPort == 8080 && port.Name == "metrics" && port.Protocol == corev1.ProtocolTCP {
if port.Name == "metrics" {

With the current check we would still run into errors right?

Copy link
Member

Choose a reason for hiding this comment

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

Or would we want to update existing metrics ports to 8080? (so it makes sense together with l.831?)

Copy link
Member

Choose a reason for hiding this comment

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

Btw I was planning to get rid of this entire section with #9289

Copy link
Member

Choose a reason for hiding this comment

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

If we would get rid of it with #9289 I'm fine with a pragmatic stopgap solution to unblock you in the meantime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I would avoid at all adding the metrics port, since if the addon is not exposing it there's nothing to scrape from.

Copy link
Member

Choose a reason for hiding this comment

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

Yup. That is my plan for #9289. I would just like to preserve the functionality until then (should take 1-2 weeks for me to get #9289 in shape)

Copy link
Member

Choose a reason for hiding this comment

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

So maybe for now let's go with if port.Name == "metrics" {?

This should cover your case and also some others where folks would still get errors if they have a metrics containerPort with a different port

Copy link
Member

@sbueringer sbueringer Aug 25, 2023

Choose a reason for hiding this comment

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

The reason why we currently have this logic is because per default we don't want to expose an insecure metrics port, but for development we would like to be able to work with metrics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So maybe for now let's go with if port.Name == "metrics" {?

Thanks, force pushed with be68373

Copy link
Member

Choose a reason for hiding this comment

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

Ah ups, the port has to be unique not the name :) My bad

@sbueringer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 25, 2023
@sbueringer sbueringer added the area/devtools Issues or PRs related to devtools label Aug 25, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Aug 25, 2023
@sbueringer
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 25, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 173ee1eb0c91113c0fa8ada22987fc5e11901215

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2023
@k8s-ci-robot k8s-ci-robot merged commit fd60888 into kubernetes-sigs:main Aug 25, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Aug 25, 2023
@prometherion prometherion deleted the issues/9306 branch August 25, 2023 15:38
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. area/devtools Issues or PRs related to devtools cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tilt-prepare command doesn't check if the addons provider has already metrics port exposed
3 participants