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

Add Go module support for pipelines. #1607

Merged
merged 1 commit into from
Dec 13, 2019
Merged

Conversation

wlynch
Copy link
Member

@wlynch wlynch commented Nov 22, 2019

Changes

This enables Go modules and removes the vendor directory from the
repository.

NOTE: highly recommend viewing this change with
git diff master -- ':!third_party' ':!vendor'

Notable changes:

  • Removes use of dep in favor of Go modules.
  • Removes vendor directory. As a result, switches license notice
    generation to go-license.
  • Forks code generation scripts from respective k8s/knative sources to
    allow module aware imports. (I want to fix this upstream sometime in
    the future, but for now this is as best as we can do).

This should not result in any change of functionality.

Fixes #1315, #1538

This change is dependent on tektoncd/plumbing#121. The only difference is the removal of the replace line in go.mod. Otherwise this should be good to go.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Update project to use Go modules.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Nov 22, 2019
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 22, 2019
@wlynch
Copy link
Member Author

wlynch commented Nov 22, 2019

/hold
tektoncd/plumbing#121

@vdemeester
Copy link
Member

vdemeester commented Nov 26, 2019

Looks really good. The only "question"/"worry" I've got is on the removal of the vendor folder (at least for now). On cli we did keep the vendor folder for several reason (that may need to be re-discussed 😛)

  • Allows to do go build -mod=vendor … to build tkn without needing anything more that a git clone
  • On the same note as above, if for some reason I'm off the network or have a slow network, or github is messed-up (or my GOPROXY), I can still build it
  • Whenever we had problems with go mod (from 1.12 to 1.13), contributor could still work and hack on the cli as long as they didn't change dependencies
  • Allows "older" version to build (this is a bit weird as.. depending on what we are using from the standard library it might not be true anymore but..)
  • and a totally stupid reason : it makes the diff smaller 😹

All that said, I am fine with whatever we choose, but we should probably do the same on all project then.

/cc @chmouel @bobcatfish @imjasonh @dibyom

PS: I feel I am a bit biased when talking about go modules 😝

@mnuttall
Copy link
Contributor

mnuttall commented Nov 27, 2019

@vdemeester

On the same note as above, if for some reason I'm off the network or have a slow network, or github is messed-up (or my GOPROXY), I can still build it

Do you need to be online for every go build, or just the first one?

In general this looks like it should be 'better than dep on balance'. I'd be happy to move dashboard and webhooks over to go modules after a few weeks of waiting for pipeline to iron out any major gotchas. A cautious +1 from me.

@wlynch
Copy link
Member Author

wlynch commented Nov 27, 2019

@vdemeester

On the same note as above, if for some reason I'm off the network or have a slow network, or github is messed-up (or my GOPROXY), I can still build it

Do you need to be online for every go build, or just the first one?

Just the first. Modules are cached locally at $GOPATH/pkg/mod. One thing to note though is that modules are fetched lazily, so if you do a clone then disconnect you may not have all dependencies locally. You would need to do something like go build ./... or go get ./... to have the go tool resolve and cache the dependencies.

@imjasonh
Copy link
Member

I have a slight preference for keeping vendor/ as well for the reasons Vincent outlined. They also must be included in the released images, so having them all the time makes that easier.

@wlynch
Copy link
Member Author

wlynch commented Nov 27, 2019

/test pull-tekton-pipeline-build-tests

@wlynch
Copy link
Member Author

wlynch commented Nov 27, 2019

I have a slight preference for keeping vendor/ as well for the reasons Vincent outlined. They also must be included in the released images, so having them all the time makes that easier.

Is this for reciprocal licenses? If so, go-license takes care of this and puts code into third_party. We should verify even in the vendorless case this folder is exported properly though.


My preference is to omit the vendor directory.

  • it makes PR sizes more representative of the changes being made (e.g. no XXL PRs because a new dep was added)
  • it prevents future repo size creep from transitive dependencies. vendor is ~92% (53/58MB) of the on disk size of the pipelines repository. Although we can't remove this from the history, we can curb additional growth (as a somewhat exaggerated comparision, kubernetes/kubernetes vendor is 110MB). Not compelling, since CI tools would need to fetch all source anyway, perhaps this is a small optimization to not have to have 2 identical versions of the same dependency, but likely not critical.
  • you don't need to remember to pass in / export -mod=vendor to use the vendor directory.

The most compelling argument to keep vendor for me is compatibility with older Go versions, but vendor support exists since 1.11 (released 2018/08). I'm not sure about pipelines, but triggers requires Go >= 1.13, so I don't think we really need to worry about this too much.

@imjasonh
Copy link
Member

Is this for reciprocal licenses? If so, go-license takes care of this and puts code into third_party. We should verify even in the vendorless case this folder is exported properly though.

Some dependencies (hashicorp/lru) require us to include the source code, not just the licenses.

@wlynch
Copy link
Member Author

wlynch commented Dec 2, 2019

Is this for reciprocal licenses? If so, go-license takes care of this and puts code into third_party. We should verify even in the vendorless case this folder is exported properly though.

Some dependencies (hashicorp/lru) require us to include the source code, not just the licenses.

Yup! We're on the same page. =] go-licenses copies anything that is identified as reciprocal to third_party/.

@ghost
Copy link

ghost commented Dec 5, 2019

Paging @wlynch @imjasonh @vdemeester have you spoken any further on this issue? As Jason mentioned offline the other day now's a good time to get moving on this since the latest release has just gone out and we're not scrambling to get a new one ready.

Given that go-licenses seems to do what we want with source code and license files I see a couple options:

  1. Go ahead with removing /vendor. If we start getting signal that we've broken something or someone we can reintroduce it.
  2. Continue ahead with the vendor directory but now using go mod instead of dep. Consider its complete removal if clearer consensus is reached.

Either way it'd be great to get on the blessed go module path.

@wlynch wlynch force-pushed the modules2 branch 3 times, most recently from b6b7744 to 2e2f77c Compare December 5, 2019 18:01
@wlynch
Copy link
Member Author

wlynch commented Dec 5, 2019

Paging @wlynch @imjasonh @vdemeester have you spoken any further on this issue? As Jason mentioned offline the other day now's a good time to get moving on this since the latest release has just gone out and we're not scrambling to get a new one ready.

Given that go-licenses seems to do what we want with source code and license files I see a couple options:

  1. Go ahead with removing /vendor. If we start getting signal that we've broken something or someone we can reintroduce it.
  2. Continue ahead with the vendor directory but now using go mod instead of dep. Consider its complete removal if clearer consensus is reached.

Either way it'd be great to get on the blessed go module path.

I'd like to submit this before more version changes/updates happen, so I'm going to proceed with #2. Like you said, we can continue discussing keeping the vendor directory after we switch to modules.

@tekton-robot
Copy link
Collaborator

@tekton-robot
Copy link
Collaborator

@vdemeester
Copy link
Member

I'd like to submit this before more version changes/updates happen, so I'm going to proceed with #2. Like you said, we can continue discussing keeping the vendor directory after we switch to modules.

Right, let's go for keeping the vendor for now.

@tekton-robot
Copy link
Collaborator

@tekton-robot
Copy link
Collaborator

@wlynch
Copy link
Member Author

wlynch commented Dec 6, 2019

/test pull-tekton-pipeline-integration-tests

@wlynch wlynch force-pushed the modules2 branch 2 times, most recently from 48ddd32 to 63a13b0 Compare December 11, 2019 00:30
@tekton-robot
Copy link
Collaborator

@tekton-robot
Copy link
Collaborator

@wlynch
Copy link
Member Author

wlynch commented Dec 11, 2019

/test pull-tekton-pipeline-build-tests

This enables Go modules and removes the vendor directory from the
repository.

NOTE: highly recommend viewing this change with
`git diff master -- ':!third_party' ':!vendor'`

Notable changes:
- Removes use of dep in favor of Go modules.
- Removes vendor directory. As a result, switches license notice
  generation to go-license.
- Forks code generation scripts from respective k8s/knative sources to
  allow module aware imports. (I want to fix this upstream sometime in
  the future, but for now this is as best as we can do).
- Unsymlinks config/300-imagecache.yaml, since go mod vendor will only
  copy package dependencies.
- Wraps `logger.Sync()` calls in func that explicitly ignores the
  returned error to make golangci-lint happy.
- Replace kodata/VENDOR-LICENSE symlinks with symlink to third_party.

This should not result in any change of functionality.

Fixes tektoncd#1315, tektoncd#1538
@tekton-robot
Copy link
Collaborator

@wlynch
Copy link
Member Author

wlynch commented Dec 11, 2019

/unhold

@wlynch
Copy link
Member Author

wlynch commented Dec 11, 2019

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 11, 2019
@vdemeester
Copy link
Member

oooohhh it is green 💚
/meow

@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

oooohhh it is green 💚
/meow

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.

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

@tekton-robot tekton-robot requested a review from a user December 12, 2019 08:41
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 12, 2019
@ghost
Copy link

ghost commented Dec 13, 2019

/lgtm

🤞

@tekton-robot tekton-robot assigned ghost Dec 13, 2019
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 13, 2019
@tekton-robot tekton-robot merged commit 5830188 into tektoncd:master Dec 13, 2019
wlynch added a commit to wlynch/pipeline that referenced this pull request Dec 26, 2019
This was something previously brought up in tektoncd#1607, but was deferred to
allow for continued discussion.

Pros of making this change:
* Reduces size of incoming PRs when new dependencies are used.
* Removes confusion around source of truth for dependencies (e.g. vendor
vs mod). This was an issue that tektoncd#1763 solved by pinning to vendor, this
will solve the same problem differently by always deferring to the
version in go.mod.
* Allows easier use of upstream and dependent types without the use of
vendor - see
https://gist.github.com/wlynch/325293bc3fbc488d3b3d319f3a93bbea for an
example of why this is difficult today.

Risks of making this change:
* Dependencies will not be present in initial clone. They will be
fetched dynamicly when needed, which may cause workflow distruptions.
* This breaks compatibility with older versions of Go (though for
certain projects like triggers, we already require Go >= 1.13).

Third-party obligations (for things like making source available in
images) have already been addressed in tektoncd#1607.

As with tektoncd#1607, this change is more easily viewed by running `git diff
master -- ':!third_party' ':!vendor'`
@wlynch wlynch mentioned this pull request Dec 26, 2019
2 tasks
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. 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.

Consider Go module adoption for beta
7 participants