Skip to content

Conversation

@BenTheElder
Copy link
Member

@BenTheElder BenTheElder commented Mar 25, 2021

What type of PR is this?

/kind bug
(we should have been enforcing this, the previous solution was lost in #99561)

What this PR does / why we need it:

Efficiently ensures that prometheus imports remain restricted per #89267 following the removal of bazel and visibility rules.

Which issue(s) this PR fixes:

Fixes #99876

Special notes for your reviewer:

We do have multiple other tools for validating imports, unfortunately none of them are suitable for this task, there's more on this in the script comments.

The short version: verify-imports is not capable of handling for this use case and is intended to restrict the imports within a package while verify-import-boss can technically express this but is far too expensive to run over the entire source tree and only checks specific directories.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/issues/2420

/sig testing instrumentation
/triage accepted

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. triage/accepted Indicates an issue or PR is ready to be actively worked on. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 25, 2021
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 25, 2021
@BenTheElder BenTheElder requested review from dims and spiffxp and removed request for fejta March 25, 2021 06:19
@BenTheElder
Copy link
Member Author

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the current list of importers.
It also matches the previous visibility rule, though is more specific for component-base/metrics.

package_group(
name = "vendor_githubcom_prometheus_CONSUMERS",
packages = [
"//cluster/images/etcd-version-monitor",
"//pkg/volume/util/operationexecutor",
"//staging/src/k8s.io/apiserver/pkg/admission/metrics",
"//staging/src/k8s.io/component-base/metrics/...",
"//test/e2e/apimachinery",
"//test/e2e_node",
"//test/integration/apiserver/flowcontrol",
"//test/integration/metrics",
"//vendor/...",
],
)

@BenTheElder
Copy link
Member Author

/retest

@BenTheElder
Copy link
Member Author

/retest
Integration flake

@palnabarun
Copy link
Member

@BenTheElder -- do you want this PR to be in the milestone? asking since the issue is in milestone. :)

@BenTheElder
Copy link
Member Author

Yes, let me fix that.

We want to prevent regressions here after dropping bazel, the test is very cheap, and the changes are contained to make verify / should not be flaky.

@BenTheElder BenTheElder added this to the v1.21 milestone Mar 25, 2021
Copy link
Member

Choose a reason for hiding this comment

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

replace . with $KUBE_ROOT just to be sure?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks. Will do 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, I cd'ed within this subshell instead. because then we don't need to do more path mangling to get package paths instead of absolute paths.

Copy link
Member

Choose a reason for hiding this comment

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

do all these options work well whether GNU grep or BSD grep is used?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. this doesn't use any GNU extensions, I tested this on mac first (2.5.1-FreeBSD) and then ~debian (GNU grep 3.6)

@BenTheElder BenTheElder force-pushed the prometheus-visibility branch 2 times, most recently from 83b769c to d4c4ed3 Compare March 25, 2021 17:51
@logicalhan
Copy link
Member

/assign

Copy link
Contributor

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

Non-blocking suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could xargs dirname and uniq to avoid the array logic above but not a blocker

Copy link
Member Author

Choose a reason for hiding this comment

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

dirname only accepts a single argument on darwin, so it's not really going to help, we still need to do it serially.

I think we're going to switch to filepaths anyhow though, after discussing what is desired with @logicalhan elsewhere.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, spiffxp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@BenTheElder BenTheElder force-pushed the prometheus-visibility branch from d4c4ed3 to 7ede8a2 Compare March 25, 2021 21:42
Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 25, 2021
@BenTheElder
Copy link
Member Author

Changes:

  • this now has a list of specific files instead of packages
  • this now does not use go list, so we don't miss anything behind build tags
  • this now fails if files in the allow-list are not actually failing anymore and should be removed from the allow-list

@k8s-ci-robot k8s-ci-robot merged commit 447e338 into kubernetes:master Mar 25, 2021
@BenTheElder BenTheElder deleted the prometheus-visibility branch March 25, 2021 23:20
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bazel visibility rules need porting to make verify

6 participants