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

🌱 Enforce import restrictions in all API packages #9461

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

Ankitasw
Copy link
Member

What this PR does / why we need it:
This PR enforces import restrictions on API packages to prevent regression mentioned in #9011.

Which issue(s) this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 19, 2023
@Ankitasw Ankitasw changed the title Enforce import restrictions in all packages 🌱 Enforce import restrictions in all packages Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 8ce2bca to 3bafcc9 Compare September 19, 2023 13:35
@Ankitasw
Copy link
Member Author

/area api

@k8s-ci-robot k8s-ci-robot added area/api Issues or PRs related to the APIs size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 3bafcc9 to 80d9979 Compare September 19, 2023 13:36
@sbueringer
Copy link
Member

Thx!

/hold
for merging the other PRs first

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 80d9979 to 15e4f99 Compare September 19, 2023 13:53
@Ankitasw Ankitasw changed the title 🌱 Enforce import restrictions in all packages 🌱 Enforce import restrictions in all API packages Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 15e4f99 to a108edd Compare September 19, 2023 14:21
@Ankitasw Ankitasw changed the title 🌱 Enforce import restrictions in all API packages 🌱 [WIP] Enforce import restrictions in all API packages Sep 19, 2023
@sbueringer
Copy link
Member

/hold cancel

All other PRs should be merged now

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from a108edd to 0d3874d Compare September 19, 2023 16:24
@Ankitasw Ankitasw changed the title 🌱 [WIP] Enforce import restrictions in all API packages 🌱 Enforce import restrictions in all API packages Sep 19, 2023
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 0d3874d to bc2bab2 Compare September 19, 2023 16:38
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

changes seem reasonable 👍

nice work

@@ -25,6 +25,16 @@ set -o pipefail

sub_packages=(
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we can say to run it just anywhere and respect the config files? Or determine the paths to test by find -name ".import-restrictions"

Copy link
Member

Choose a reason for hiding this comment

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

Let's maybe try to optimize this in a follow up

Copy link
Member Author

Choose a reason for hiding this comment

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

Wondering if we can say to run it just anywhere and respect the config files?

I have not tested it by removing the sub package, I can see how it behaves.

Or determine the paths to test by find -name ".import-restrictions"

Otherwise it is ok to do this as well.

Copy link
Member

@sbueringer sbueringer Sep 20, 2023

Choose a reason for hiding this comment

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

I'm fine with optimizing if we find a safe way to do it and if we think it's worth the effort. I would just like to have the restrictions in place :) (so I don't want to wait on finalizing the scripting :))

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah a follow up PR sounds good. I don't have much idea about this myself 😅

Copy link
Member

Choose a reason for hiding this comment

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

I would say it's fine as is. @chrischdi feel free to open a follow-up PR if you want to improve it :)

cmd/clusterctl/api/.import-restrictions Outdated Show resolved Hide resolved
exp/addons/api/.import-restrictions Show resolved Hide resolved
exp/ipam/api/.import-restrictions Show resolved Hide resolved
exp/runtime/api/.import-restrictions Show resolved Hide resolved
@sbueringer
Copy link
Member

sbueringer commented Sep 20, 2023

@Ankitasw I realized that this might be a bit confusing :). So here is the summary what restrictions we should have:

  • ./api: block all except conversion
  • ./api/v1beta1: block all
  • ./bootstrap/kubeadm/api: block all except conversion
  • ./bootstrap/kubeadm/api/v1beta1: block all
  • ./cmd/clusterctl/api: block all
  • ./controlplane/kubeadm/api: block all except conversion
  • ./controlplane/kubeadm/api/v1beta1: block all
  • ./exp/addons/api: block all except conversion
  • ./exp/addons/api/v1beta1: block all
  • ./exp/api: block all except conversion
  • ./exp/api/v1beta1: block all
  • ./exp/ipam/api: block all except conversion
  • ./exp/ipam/api/v1alpha1: block all
  • ./exp/runtime/api: block all except conversion
  • ./exp/runtime/api/v1alpha1: block all
  • ./test/infrastructure/docker/api: block all except conversion
  • ./test/infrastructure/docker/api/v1beta1: block all
  • ./test/infrastructure/docker/exp/api: block all except conversion
  • ./test/infrastructure/docker/exp/api/v1beta1: block all
  • ./test/infrastructure/inmemory/api: block all except conversion
  • ./test/infrastructure/inmemory/api/v1alpha1: block all

@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from bc2bab2 to 471f2b5 Compare September 20, 2023 10:29
@sbueringer
Copy link
Member

import-restrictions look good. Last one: #9461 (comment)

Would be great if you can clean these up as well :)

@Ankitasw Ankitasw requested a review from sbueringer September 20, 2023 11:24
@Ankitasw Ankitasw force-pushed the add-import-restrictions branch from 471f2b5 to 615b5e6 Compare September 20, 2023 11:29
@k8s-ci-robot
Copy link
Contributor

@Ankitasw: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main 615b5e6 link false /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@sbueringer
Copy link
Member

Thank you very much!!

/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 Sep 20, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7d31de2d46af047f2c8b6f106fe71f0df509957c

@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 Sep 20, 2023
@k8s-ci-robot k8s-ci-robot merged commit 4af23e3 into kubernetes-sigs:main Sep 20, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Sep 20, 2023
@Ankitasw Ankitasw deleted the add-import-restrictions branch September 20, 2023 15:30
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/api Issues or PRs related to the APIs 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants