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

Simplify update-vendor script #3566

Closed
wants to merge 3 commits into from

Conversation

benmoss
Copy link
Member

@benmoss benmoss commented Sep 30, 2020

Change our update-vendor script so we use go modules in a normal-ish way, avoiding all the /tmp staging folder stuff. I split up the commits just so that we can backport the script changes independently.

/area dependency
/area cluster-autoscaler

@k8s-ci-robot k8s-ci-robot added the area/dependency Issues or PRs related to dependency changes label Sep 30, 2020
@k8s-ci-robot
Copy link
Contributor

@benmoss: The label(s) area/cluster-autoscaler cannot be applied, because the repository doesn't have them

In response to this:

Change our update-vendor script so we use go modules in a normal-ish way, avoiding all the /tmp staging folder stuff.

I don't know if this totally eliminates our ability to vendor a specific commit of k/k, but I think it might, so that might be a blocker. We can still bump to alpha releases, as I did as part of this PR. I split up the commits just so that we can backport the script changes independently.

/area dependency
/area cluster-autoscaler

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 30, 2020
@MaciekPytel
Copy link
Contributor

I think every other k8s release we end up having to make some last-minute fix in scheduler that has to be cherry-picked on release branch just before the release is cut. Until we figure out a process solution to this, I think I'd prefer to at least keep the old script around so we can use it in emergency.

Maybe for now we can just have both scrips and use the new one when we can and the old one when we have to?

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

i tried out the script with the 1.20.0-alpha.1 tag and everything worked as expected. i have one small question, but it's not a blocker for me.
/lgtm

cluster-autoscaler/hack/update-vendor.sh Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 2, 2020
@feiskyer
Copy link
Member

feiskyer commented Oct 3, 2020

Is it possible to make it also work for a k8s commit ID?

@MaciekPytel
Copy link
Contributor

@feiskyer I don't think so. Technically I think you can have go mod target a commit hash in kubernetes/kubernetes, but the problem is with other k8s repos (ex. client-go). The source of truth for those is staging/ directory in kubernetes repo and, absent tag, it's hard to be sure which commit should be used across those repos to be in consistent state. This is exactly the reason for the old script vendoring in the contents of the staging/ directory instead of the actual content of those repos (via local commits).

@benmoss
Copy link
Member Author

benmoss commented Oct 5, 2020

You can develop against it locally with replace directives (https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/) but that wouldn't be something we'd want to commit

@benmoss
Copy link
Member Author

benmoss commented Oct 5, 2020

We discussed on Slack some potential solutions if we need to switch back to an unreleased version of k8s:

@MaciekPytel
Copy link
Contributor

I'm strongly against second option - I think it is very risky to let different k8s repos get out of sync. Also the actual scheduler logic is in kubernetes/kubernetes repo (pkg/scheduler directory mostly), I don't think there is any particular need to submodule kube-scheduler repo (which I think is just scheduler-related APIs).

The benefit of first approach is that most of the time we could ignore the existence of that option. But, if we ever have to use it, that particular version would end up working very differently from other versions (ex. you wouldn't be able to run unittests without GO111MODULE=off, etc).
Submodule option seems interesting. I'm trying to figure out if there are any non-obvious downsides to it.

@vivekbagade @towca - I think you have quite a bit of experience in this area. I wonder if you have any opinions on this?

@RainbowMango
Copy link
Member

Indeed it's hard to get all staging repo's pseudo version by a k/k commit ID. Given we don't always depend on a k/k's commit ID, once there is a need, we can get the staging repo's pseudo version and update go.mod manually. (each staging repo merge commit message contains the k/k commit ID, e.g. kubernetes/api@2c3c141)

It's not just CA has this problem, people discussed a lot at this issue. Seems using a tagged version can solve most of the cases.

@RainbowMango
Copy link
Member

Hey folks, I want to add a new SDK for Huawei Cloud, can we make a quick decision and push forward?

Can we merge this PR first and create a new issue for a follow-up?
If not, can we merge #3593 which just modified the go.mod file and vendor directory? so that we can keep discussing the hack/update-vendor.sh thing by current PR.

How do you think? @feiskyer @benmoss @MaciekPytel

@MaciekPytel
Copy link
Contributor

Good point on kubernetes commit hashes in commit messages. Seems like it would be possible to write a script that goes through each repo and checks if the latest commit in that repo is also the last commit to a given subdirectory of staging. It seems like it may be a bit messy, but it seems like a reasonable solution for vendoring specific commit id.

I think vendoring kubernetes in a way that doesn't break go mod and vendoring provider specific dependencies are a completely separate issue though. The problem with latter is how to avoid non-core dependencies when compiling CA with just one provider or when maintaining provider in a fork (AFAIK there are still more forked providers than in-repo ones). I don't really have any good ideas for how to deal with that, but I'd be very happy to discuss any proposals.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 12, 2020
@RainbowMango
Copy link
Member

Seems like it would be possible to write a script that goes through each repo and checks if the latest commit in that repo is also the last commit to a given subdirectory of staging.

Yes. To be precise, the script should get commit ID from the staging repo for any Kubernetes commit, not only the latest.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2020
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 13, 2020
@RainbowMango
Copy link
Member

I think we need more than one scripts, just like k/k does:

  • pin-dependency.sh // pin specific version of dependency.
  • update-vendor.sh // update vendor.
  • verify-vendor.sh // make sure vendor has been updated.

And another script takes responsibility to retrieve commit ID from all staging repo according to k/k commit ID.
e.g. pin-kubernetes-dependency.sh which will invok pin-dependency.sh.

@MaciekPytel
Copy link
Contributor

I'm not sure about pin-dependency.sh as I'm not sure if we currently have any dependency that is not already a dependency of kubernetes (in which case we probably want to use whatever version they use). Otherwise I agree.

@benmoss
Copy link
Member Author

benmoss commented Oct 14, 2020

I just added the hack/submodule-k8s.sh script and tested to make sure they work together, ie that we can switch back and forth with little friction. They both will update the vendor directory so I don't think we need a separate update-vendor script unless I'm misunderstanding something.

I think verify-vendor seems nice but considering it's not trivial to add can we push that off to a separate issue?

@RainbowMango
Copy link
Member

@benmoss
Maybe we don't need a submodule here. How do you think about the ideas mentioned by @MaciekPytel ?

Seems like it would be possible to write a script that goes through each repo and checks if the latest commit in that repo is also the last commit to a given subdirectory of staging. It seems like it may be a bit messy, but it seems like a reasonable solution for vendoring specific commit id.

I think verify-vendor seems nice but considering it's not trivial to add can we push that off to a separate issue?

SGTM. I love iteration.

@benmoss
Copy link
Member Author

benmoss commented Oct 15, 2020

I don't think I understand, there's no way to have go.mod point to a specific commit. I think submoduling is the only way that works.

@MaciekPytel
Copy link
Contributor

there's no way to have go.mod point to a specific commit

I think you can do it using v0.0.0-<commit_timestamp>-<commit_hash> syntax. This is mentioned in https://github.com/golang/go/wiki/Modules#can-a-module-consume-a-package-that-has-not-opted-in-to-modules and we already have some examples of that in our go.mod: https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/go.mod#L42). Or is there a problem with this approach that I'm not aware of?

@benmoss
Copy link
Member Author

benmoss commented Oct 15, 2020

Ah, yeah that's true. I still don't see why it's preferable, it seems a lot more complicated than submodules.

@RainbowMango
Copy link
Member

I still don't see why it's preferable, it seems a lot more complicated than submodules.

In my opinion, submodule way is git-ish, and we'd prefer go-ish, right?

@benmoss
Copy link
Member Author

benmoss commented Oct 16, 2020

I don't think that's a fair way to contrast them. Submodules solve the problem more simply in my opinion, you point to a specific SHA of k/k and then all the staging repos will be pulled from inside of there.

With the proposed bash script solution we have to correlate the Git commit inside k/k to the commits in each of the staging repos. This isn't trivial.

Either way though, both solutions work, and I don't really know why we're debating it endlessly. If people really want to go with that approach, then by all means let's write that script and go with it. It seems like a mostly hypothetical problem at this point, considering we don't need to be on an unreleased commit of k/k right now as far as I know. I wish we could just move forward on this and iterate as we encounter problems.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2020
@RainbowMango
Copy link
Member

If people really want to go with that approach, then by all means let's write that script and go with it. It seems like a mostly hypothetical problem at this point, considering we don't need to be on an unreleased commit of k/k right now as far as I know. I wish we could just move forward on this and iterate as we encounter problems.

+1
@MaciekPytel How do you say?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 29, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: benmoss, elmiko
To complete the pull request process, please assign feiskyer after the PR has been reviewed.
You can assign the PR to them by writing /assign @feiskyer in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@benmoss benmoss mentioned this pull request Oct 29, 2020
Copy link
Collaborator

@towca towca left a comment

Choose a reason for hiding this comment

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

The changes to the scripts LGTM, one question to the Makefile. The vendor update got out of sync because we had to do an update using the old script in the meantime. Could you change the PR to use a newer tag for the update, or just remove that commit altogether and only leave the script changes?

cluster-autoscaler/Makefile Show resolved Hide resolved
@towca
Copy link
Collaborator

towca commented Jan 26, 2021

Hey @benmoss! This is a very valuable contribution, would you consider reopening the PR and rebasing? If not, would you mind if I copied the changes and merged them myself?

@k8s-ci-robot
Copy link
Contributor

@benmoss: 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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2021
@elmiko
Copy link
Contributor

elmiko commented Jan 27, 2021

@towca i don't want to speak for @benmoss , but i know he has been focusing in other areas recently. i think if you opened a new PR with a rebase that would be fine.

@RainbowMango
Copy link
Member

Glad to see this PR could move forward. @MaciekPytel How do you say?

@towca
Copy link
Collaborator

towca commented Mar 4, 2021

@elmiko @benmoss @RainbowMango The changes have been merged in #3915.

@RainbowMango
Copy link
Member

Fantastic!! Thanks, @towca for your hard work.

@elmiko
Copy link
Contributor

elmiko commented Mar 4, 2021

Fantastic!! Thanks, @towca for your hard work.

+1, thanks @towca !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dependency Issues or PRs related to dependency changes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants