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

Detect and prevent new vendor cycles #45176

Merged
merged 1 commit into from
May 15, 2017

Conversation

lavalamp
Copy link
Member

@lavalamp lavalamp commented May 1, 2017

I see that we have added a dependency with a cyclic reference to
kubernetes. This makes life much harder, we should not do it. This
script should prevent any more offenders while we fix the existing one.

@k8s-reviewable
Copy link

This change is Reviewable

@lavalamp lavalamp added the release-note-none Denotes a PR that doesn't merit a release note. label May 1, 2017
@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 1, 2017
echo "Skipping known violator $i"
continue
fi
deps=$(go list -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' ./$i 2> /dev/null | grep -v "k8s.io/kubernetes/vendor/" | grep "k8s.io/kubernetes" || echo "")
Copy link
Member

Choose a reason for hiding this comment

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

Apart from k8s.io/kubernetes, they shouldn't depend on other staging repos either.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's only problematic if the staging repo itself depends on kubernetes, which this should catch. It should be safe to depend on something in staging, do you have a counter example?

Copy link
Member

Choose a reason for hiding this comment

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

vendor/k8s.io/metrics depends on client-go/pkg/api. It's impossible to remove client-go/pkg/api.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's just a regular dependency management problem (main repo and metrics want different versions of client-go), it's not a cycle problem.

Copy link
Member

Choose a reason for hiding this comment

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

I disagree. It is a cycle problem because the source of the staging code is still in kubernetes.


failed=false
for i in $(find vendor/ -type d); do
if [ -n "$(echo ${exceptions} | grep "^${i}\$")" ]; then
Copy link
Member

@ixdy ixdy May 2, 2017

Choose a reason for hiding this comment

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

style nit: prefer [[ ]] over [ ] in bash scripts.

also if we expect exceptions to be a list of more than one item, the conditional should probably be

if echo "${exceptions[@]}" | grep -q "\(^\| \)$i\( \|$\)"; then

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 will take your word that the grep line actually works ;)

Copy link
Member

@ixdy ixdy May 12, 2017

Choose a reason for hiding this comment

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

yeah, basically, ${exceptions[@]} will be printed as a list of space-separated items.
we want to match if it's the first item, somewhere in the middle, or the last item.
backslashes necessary because bash.

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 that grep line didn't seem to work for me so I did something more obvious. PTAL

@ixdy
Copy link
Member

ixdy commented May 2, 2017

looks fine besides that one comment

@piosz piosz mentioned this pull request May 8, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 12, 2017
failed=false
for i in $(find vendor/ -type d); do
exceptionFound=false
for e in ${exceptions}; do
Copy link
Member

Choose a reason for hiding this comment

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

I think this should still be ${exceptions[@]} - without the [@] this is just the first element of the array.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, right you are. fixed.

@caesarxuchao
Copy link
Member

I'll send a PR to remove the exception.

I see that we have added a dependency with a cyclic reference to
kubernetes. This makes life much harder, we should not do it. This
script should prevent any more offenders while we fix the existing one.

Change-Id: Iabc22ee7a2c7c54697991d2f8c24e80acb0281e4
@ixdy
Copy link
Member

ixdy commented May 12, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 12, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ixdy, lavalamp

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@caesarxuchao
Copy link
Member

#45758 will remove the exception.

@caesarxuchao
Copy link
Member

@k8s-bot gce etcd3 e2e test this

continue
fi

deps=$(go list -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' ./$i 2> /dev/null | grep -v "k8s.io/kubernetes/vendor/" | grep "k8s.io/kubernetes" || echo "")
Copy link
Member

Choose a reason for hiding this comment

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

seems like this should also include packages whose authoritative source is still in this repo (like apimachinery, apiserver)? c.f. discussion in #45665 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I agree, see #45176 (comment).

Copy link
Member Author

Choose a reason for hiding this comment

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

The whole point of this is to break the repo into chunks that people are allowed to import?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's the point. But now since we have staging, we have the cycle.

Copy link
Member

Choose a reason for hiding this comment

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

Sent #49252.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 41331, 45591, 45600, 45176, 45658)

@k8s-github-robot k8s-github-robot merged commit cb26eb6 into kubernetes:master May 15, 2017
k8s-github-robot pushed a commit that referenced this pull request May 16, 2017
…alpha1

Automatic merge from submit-queue (batch tested with PRs 44337, 45775, 45832, 45574, 45758)

Stop vendoring heapster v1alpha1

Changes to use the one in staging/metrics.

TODO: remove the exception in #45176

Implementing #45498 (comment).
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

None yet

7 participants