-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Updation of import-restrictions file #115296
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
Welcome @yashsingh74! |
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @yashsingh74. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
@pohly Please review the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comments explaining why you are making these changes and why these (and just these entries) are correct? Start commenting the file and then add further information in the commit message.
Assume that I don't have a clue how import-boss works (because I don't...).
Also note that there is a TODO in the file. Can that be resolved?
@@ -1,116 +1,454 @@ | |||
rules: | |||
- selectorRegexp: k8s[.]io/kubernetes/pkg/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a rule for k8s[.]io/kubernetes/pkg/
in test/e2e/framework/.import-restrictions
? Does that limit which code may be used inside k8s.io/kubernetes/pkg
? If yes, it doesn't seem like it belongs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import boss checks the packages in place using this format. Since just the packages used by the framework are being imported, not all of the k/k packages.
Also, we are using the defined path to import the pkg and test path instead of the 'k8s[.]io' parent path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking just at this file and PR, it's still not clear to me what is being matched and what the effect is. Can you perhaps add comments to the file?
I probably also have to read up on how import boss works, but even then having those comments in the file will help the next person reading it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated which packages are used in the test and fixes the external Packages which are used in the test.
Also, the packages only includes the allowed prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked https://pkg.go.dev/k8s.io/gengo/examples/import-boss, but I am still trying to wrap my head around it.
So here we make a statement about importing some package under k8s[.]io/kubernetes/pkg: only the packages listed explicitly are allowed?
This is a surprisingly long list - much too long IMHO. I suspect this is a result of using this .import-restrictions
file for the core framework and for the domain-specific sub-packages.
I believe what we want is a fairly tight list here and then individual .import-restrictions
files in the sub-package were we allow additional packages on a per-sub-package basis.
When you extended this list, how did you decide which packages to list? Are all of them really needed somewhere or did you list everything that currently exists?
406c654
to
707fc60
Compare
…s that exist in the k/k path. Signed-off-by: Yash Singh <syash@vmware.com>
707fc60
to
cc98e2a
Compare
@@ -1,116 +1,454 @@ | |||
rules: | |||
- selectorRegexp: k8s[.]io/kubernetes/pkg/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked https://pkg.go.dev/k8s.io/gengo/examples/import-boss, but I am still trying to wrap my head around it.
So here we make a statement about importing some package under k8s[.]io/kubernetes/pkg: only the packages listed explicitly are allowed?
This is a surprisingly long list - much too long IMHO. I suspect this is a result of using this .import-restrictions
file for the core framework and for the domain-specific sub-packages.
I believe what we want is a fairly tight list here and then individual .import-restrictions
files in the sub-package were we allow additional packages on a per-sub-package basis.
When you extended this list, how did you decide which packages to list? Are all of them really needed somewhere or did you list everything that currently exists?
- selectorRegexp: k8s[.]io/kubernetes/test/ | ||
allowedPrefixes: | ||
- k8s.io/kubernetes/test/conformance/testdata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to (and shouldn't) list every single package here.
What we want to say is "anything under test/e2e/framework may import anything under test". Or at least I can't think of something that shouldn't be allowed.
If that is the goal, then can't we just use this:
# Everything under k8s.io/kubernetes/test/ may be used.
- selectorRegexp: k8s[.]io/kubernetes/test/
allowedPrefixes:
- ""
Or even leave the rule out entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the first comment, I have listed down all the packages which are being used in the test package. Yes, the list is too long so it is better to only keep prefix which are being used.
Second, in the */test package we can use the suggested changes as most of the import are used.
I will make the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I have only keep those packages which are only imported and used in the k8s.io/kubernetes/test/e2e/framework
.
- selectorRegexp: k8s[.]io/kubernetes/third_party/ | ||
allowedPrefixes: | ||
- k8s.io/kubernetes/third_party/forked/golang/expansion | ||
- k8s.io/kubernetes/third_party/forked/golang/net |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to my comment above, this would belong into test/e2e/network/.import-restrictions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out hack/verify-import-boss.sh
with your branch and it is failing for me:
E0207 17:25:02.971904 76898 main.go:41] Error: Failed executing generator: some packages had errors:
errors in package "k8s.io/kubernetes/test/e2e/framework/providers/aws":
the following imports did not match any allowed prefix:
k8s.io/kubernetes/pkg/api/legacyscheme
k8s.io/kubernetes/pkg/apis/apps
k8s.io/kubernetes/pkg/apis/autoscaling
...
Same for several sub-packages.
I think we need to override the restrictions for k8s.io/kubernetes/pkg for sub-packages.
If I add the following file to several directories, the check passes:
rules:
# Allow full usage of the entire k8s.io/kubernetes/pkg.
# This is probably too broad and could be restricted further,
# but that isn't important. What matters are the restrictions
# of the core framework: those need to be overridden here
# due to how the E2E packages are structured.
- selectorRegexp: k8s[.]io/kubernetes/pkg/
allowedPrefixes:
- ""
test/e2e/framework/daemonset/.import-restrictions
test/e2e/framework/kubelet/.import-restrictions
test/e2e/framework/perf/.import-restrictions
test/e2e/framework/providers/aws/.import-restrictions
test/e2e/framework/providers/gce/.import-restrictions
test/e2e/framework/providers/kubemark/.import-restrictions
test/e2e/framework/pv/.import-restrictions
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yashsingh74 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 |
@pohly I have updated the file and ran the |
/ok-to-test |
This is still not what I was aimining at:
Now that I understand how import-boss works, it's easier for me to spell it out with code than with words 😢 Sorry, but I think I'll solve #115234 myself. Can you perhaps review #115710? |
Thank you @pohly I will look up for your open PR. |
PR needs rebase. 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. |
/close #115710 was merged. |
@pohly: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
The import-boss script file requires the
.import-restrictions
file. This will help the maintainers keep the dependencies clean. It is described as a YAML or JSON format. This file is not included in the CI runs. When it is added, the list of directories and subdirectories is also added.As there is a list of directories and subdirectories that do not exist in the k/k repo. This PR helps to clean up the path to those directories and adds a list of directories that exist in the k/k path.
Ref: import-boss
Which issue(s) this PR fixes:
Fixes #115234