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

Fix go module requirements for semantic versioning #232

Merged
merged 4 commits into from
Nov 4, 2019

Conversation

Ntr0
Copy link
Contributor

@Ntr0 Ntr0 commented Oct 28, 2019

As stated in this post:
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
modules that released a version higher than 1 need to put the version
into the package path.

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug

/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
When 2.3.0 introduced go modules, the package paths where not updated. Therefore
this module cannot be imported as version 2.3.0 since go mod will complain:

go.mod:12: require github.com/kubernetes-csi/csi-test: version "v2.3.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

Which issue(s) this PR fixes:

Fixes #231

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Update package path to v3. Vendoring with dep depends on https://github.com/golang/dep/pull/1963 or the workaround described in v3/README.md.

As stated in this blog post:
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
modules that release a version higher than 1 need to put the version
into the package path.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 28, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @Ntr0. Thanks for your PR.

I'm waiting for a kubernetes-csi or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 28, 2019
@Ntr0 Ntr0 mentioned this pull request Oct 28, 2019
pohly added a commit to pohly/pmem-CSI that referenced this pull request Oct 29, 2019
v3.0.0 fixed "go mod" support by adding the /v3 suffix to import paths
(kubernetes-csi/csi-test#232). dep currently
does not support that
(golang/dep#1962 (comment)) and
can only import that with symlink workarounds in csi-test and by
disabling pruning.
Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

This breaks vendoring csi-test with dep because of golang/dep#1962.

I don't want to force all consumers of csi-test to switch to go mod. I don't like the proposal with "Major subdirectory" from https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher either because it is so intrusive for the git history.

I came up with another solution based on symlinks, see pohly@2bc889d. I verified that this then can be imported with dep (pohly/pmem-CSI@79b03e9), albeit only with a small trick (disabling pruning for csi-test).

@Ntr0: what do you think of that approach? Can you verify that 'go modignores this new/v3` sub-directory?

If you agree that this is acceptable and works, please cherry-pick my commit into your branch.

These symlinks ensure that "dep" can still import v3.0.0. Without
them, importing fails when it encounters the
github.com/kubernetes-csi/csi-test/v3 because there's no code under
that path without the symlinks. Symlinks work for files, but not for
directories (probably due to a check in dep which expects directories
for packages).

Upstream suggests to move the code itself ("Major subdirectory",
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher). But
that messes with git history. Symlinks are simpler, but have the
disadvantage of only working on Unix. Users on Windows will have to
use "go mod" for importing.
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 29, 2019
@Ntr0
Copy link
Contributor Author

Ntr0 commented Oct 29, 2019

@pohly It looks like it works. This approach seems reasonable to me, as I won't expect csi-test to maintain different versions of the package. So keeping the semantic version in the main go.mod and having these symlinks looks good to me.

@msau42
Copy link
Collaborator

msau42 commented Oct 29, 2019

it is so intrusive for the git history

Doesn't git mv retain history?

@msau42
Copy link
Collaborator

msau42 commented Oct 29, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 29, 2019
@pohly
Copy link
Contributor

pohly commented Oct 29, 2019 via email

@msau42
Copy link
Collaborator

msau42 commented Oct 29, 2019

Seems fine to me if the file still retains history. We rename files in k/k often. I think it's kind of messy and confusing to have symlinks

@pohly
Copy link
Contributor

pohly commented Oct 29, 2019

Seems fine to me if the file still retains history.

There are other drawbacks, like having to maintain the go.mod file also in the v3 directory. I don't know what it means for vendoring. Probably breaks our tooling and/or requires special casing.

I think it's kind of messy and confusing to have symlinks

It's an interim solution until either "dep" gets enhanced (PR is pending) or we can convince ourselves that supporting "dep" isn't necessary anymore. I prefer symlinks over messing with the directory structure.

@pohly
Copy link
Contributor

pohly commented Oct 30, 2019

If there's no consensus on how to support "dep", then I propose that we simply don't do anything special to support it, i.e. remove 0163355 from this PR again.

Then "dep" users either have to switch to "go mod" or use a patched dep version (golang/dep#1963).

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2019
@pohly
Copy link
Contributor

pohly commented Oct 30, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2019
@msau42
Copy link
Collaborator

msau42 commented Oct 30, 2019

Can you also add a release note indicating the potential future version of dep that will be needed?

@pohly
Copy link
Contributor

pohly commented Oct 30, 2019

Can you also add a release note indicating the potential future version of dep that will be needed?

It seems uncertain which version of dep will have golang/dep#1963 included; might be a patch or a major release. Better link to the PR.

@Ntr0
Copy link
Contributor Author

Ntr0 commented Oct 31, 2019

@pohly Updated Release Notes to point out the breaking change for dep users

@pohly
Copy link
Contributor

pohly commented Oct 31, 2019

Updated Release Notes to point out the breaking change for dep users

Sorry for the back and forth, but when we discussed this yesterday in the Kubernetes-CSI standup meeting, @msau42 said that we should continue to support importing with normal dep. We settled on the approach with symlinks as the lesser evil.

Can you remove the revert commit from your branch and augment my commit with the following v3/README.md?

This directory mirrors the source code via symlinks.
This makes it possible to vendor v3.x releases of
csi-test with `dep` versions that do not support
semantic imports. Support for that is currently
[pending in dep](https://github.com/golang/dep/pull/1963).

If users of dep have enabled pruning, they must disable if
for csi-test in their Gopk.toml, like this:

    [prune]
      go-tests = true
      unused-packages = true

      [[prune.project]]
        name = "github.com/kubernetes-csi/csi-test"
        unused-packages = false

Can you also adapt the release note accordingly?

Thanks!

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 31, 2019
@pohly
Copy link
Contributor

pohly commented Oct 31, 2019

The double revert looks a bit weird, personally I would use git rebase -i and just drop both commits. Other than that this looks good. I'll leave the final decision to @msau42 .

@pohly
Copy link
Contributor

pohly commented Oct 31, 2019

Wait, the release note still needs to be updated:

Update package path to v3. Vendoring with dep is not supported anymore, at least until https://github.com/golang/dep/pull/1963 has been merged.

=>

Update package path to v3. Vendoring with dep depends on https://github.com/golang/dep/pull/1963 or the workaround described in v3/README.md.

@pohly
Copy link
Contributor

pohly commented Nov 4, 2019

/lgtm

There's a minor spelling nit in the README.md (my bad): "must enable it", but I propose to merge as-is to get this done.

Leaving the approval to @msau42.

/assign @msau42

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 4, 2019
@msau42
Copy link
Collaborator

msau42 commented Nov 4, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msau42, Ntr0

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

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Go mod breaks importing
4 participants