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

SHIP-0004: Build Environment Variables #817

Merged
merged 1 commit into from
Oct 6, 2021
Merged

SHIP-0004: Build Environment Variables #817

merged 1 commit into from
Oct 6, 2021

Conversation

coreydaley
Copy link
Contributor

@coreydaley coreydaley commented Jun 22, 2021

Changes

This pull request will give developers the abilty to add environment variables to build strategy steps. Conversely, this proposal will also give build strategy authors the ability to fix the values of environment variables in build steps or provide non-empty default values.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Developers can now add Environment Variables to the Spec section of their Builds and BuildRuns.
The Environment Variables will be added to all Steps of the chosen BuildStrategy, though any conflicts
will result in a failed TaskRun.

@openshift-ci openshift-ci bot added the release-note Label for when a PR has specified a release note label Jun 22, 2021
@coreydaley coreydaley changed the title SHIP-0004: Build Environment Variables [WIP] SHIP-0004: Build Environment Variables Jun 22, 2021
@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 22, 2021
@qu1queee
Copy link
Contributor

@coreydaley can we close this one? see shipwright-io/community#10 ( is already merged )

@coreydaley
Copy link
Contributor Author

@coreydaley can we close this one? see shipwright-io/community#10 ( is already merged )

This is the implementation for shipwright-io/community#10 ...

@qu1queee
Copy link
Contributor

@coreydaley my bad, thanks for the clarification

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2021
@coreydaley coreydaley added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 13, 2021
@coreydaley coreydaley changed the title [WIP] SHIP-0004: Build Environment Variables SHIP-0004: Build Environment Variables Sep 24, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 24, 2021
@coreydaley
Copy link
Contributor Author

/retest

@coreydaley
Copy link
Contributor Author

/assign @adambkaplan @gabemontero @otaviof
I believe that this is ready for a first round of reviews, thanks!

@coreydaley
Copy link
Contributor Author

/assign @SaschaSchwarze0

Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

Generally looks good, but given this is a substantial feature this PR needs:

  1. Doc updates for our Build and BuildRun APIs.
  2. A release note block in the PR description.

pkg/apis/build/v1alpha1/build_types.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/taskrun_test.go Outdated Show resolved Hide resolved
@coreydaley
Copy link
Contributor Author

Generally looks good, but given this is a substantial feature this PR needs:

1. Doc updates for our Build and BuildRun APIs.

2. A release note block in the PR description.

Working on the docs update already.

@coreydaley
Copy link
Contributor Author

Documentation update: shipwright-io/website#53

Copy link
Member

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

a couple of bigger macro items @coreydaley @adambkaplan that came to my mind, including perhaps missing a key element of type during the SHIP review

deploy/crds/shipwright.io_buildruns.yaml Outdated Show resolved Hide resolved
pkg/apis/build/v1alpha1/build_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Show resolved Hide resolved
pkg/reconciler/buildrun/buildrun_test.go Show resolved Hide resolved
@coreydaley
Copy link
Contributor Author

Looks like a networking issue:

error creating build container: Error reading blob sha256:e571554b15ee6f4301b3e1cf58735a1504380734dade095784e14197eea233f8: Get "https://cdn02.quay.io/sha256/e5/e571554b15ee6f4301b3e1cf58735a1504380734dade095784e14197eea233f8?Expires=1632847588&Signature=OG~knNhsUflW2XAC3MjGAicDdiEKMxMWlB4vIjF4JkI3WBp5O7sp2ffRULJHvK1H~gBzH7wH4mQe~5rRKlwhGgSNCOT1PZ-Edc3~oBCVMbwNEi2UlI~6gawEvxgcGzGN9Uj6iDj~dE1jjAzqPVL~2zh1eIjju2qUsu-~~vxzOpRoPvI9gTd8F7ynj0fj-ZFbUmrt8lKmooOjUcb82O5KQ~lQ4PitDoPtsRNt0RJx96veZG~jVHcuMfACRRZQJeYqbZawLjC4voGHBWF0DbIutUIgX6~zk1GNzviBHPpwfJi9SaeBHD6WLAe8VIgZeHNGczWW0YYywA925yUqPIsVeQ__&Key-Pair-Id=APKAJ67PQLWGCSP66DGA": net/http: TLS handshake timeout

@adambkaplan Can I get a retest?

@adambkaplan
Copy link
Member

@coreydaley for future reference I think you can mention @shipwright-io/build-reviewers, and anyone on that team will be able to rerun any GitHub action by clicking on the details.

You may be also able to re-run the GitHub action as the PR author since technically the tests run against your fork.

@coreydaley
Copy link
Contributor Author

@coreydaley for future reference I think you can mention @shipwright-io/build-reviewers, and anyone on that team will be able to rerun any GitHub action by clicking on the details.

You may be also able to re-run the GitHub action as the PR author since technically the tests run against your fork.

I will keep that in mind. I was not able to rerun the tests.

@coreydaley
Copy link
Contributor Author

I don't think that adding additional documentation to support valueFrom with the EnvVars would be an issue, and it should flow through to tekton seamlessly. Additional supporting tests should not be an issue either.
However, the shipwright/cli would not be able to support adding environment variables utilizing valueFrom to Builds or BuildRuns, I also don't think that OpenShift currently supports that through the oc cli either.

@gabemontero
Copy link
Member

I don't think that adding additional documentation to support valueFrom with the EnvVars would be an issue, and it should flow through to tekton seamlessly. Additional supporting tests should not be an issue either. However, the shipwright/cli would not be able to support adding environment variables utilizing valueFrom to Builds or BuildRuns, I also don't think that OpenShift currently supports that through the oc cli either.

the meets min for me would be doc and tests that address the various valueFrom paths with k8s env vars ... if those are added, and we are all good with supporting those scenarios, I'm good

integration into shp i.e. cli is a stretch item that could either never be addressed or addressed at a later point based on customer feedback, though the fact that openshift has k8s corev1 env vars for 7 years now and nobody has asked for cli enablement there is telling IMO

so yeah @coreydaley pending any comeback from @adambkaplan about gettnig simpler here wrt env vars, start adding the additional env var permutations and we'll go from there

docs/build.md Show resolved Hide resolved
@SaschaSchwarze0 SaschaSchwarze0 added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Oct 4, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Thanks. Good work.

docs/build.md Outdated Show resolved Hide resolved
docs/buildrun.md Outdated Show resolved Hide resolved
pkg/env/env_test.go Show resolved Hide resolved
pkg/env/env_test.go Show resolved Hide resolved
pkg/reconciler/build/build_test.go Show resolved Hide resolved
pkg/reconciler/buildrun/resources/taskrun.go Outdated Show resolved Hide resolved
pkg/validate/envvars.go Outdated Show resolved Hide resolved
@coreydaley
Copy link
Contributor Author

FYI, I am still working on the valueFrom stuff that was mentioned by @gabemontero during his review, and have not pushed those updates as of yet.

@SaschaSchwarze0
Copy link
Member

FYI, I am still working on the valueFrom stuff that was mentioned by @gabemontero during his review, and have not pushed those updates as of yet.

Thanks, was assuming something like this. You may prefix your PR title with WIP in such cases.

@gabemontero
Copy link
Member

a couple of bigger macro items @coreydaley @adambkaplan that came to my mind, including perhaps missing a key element of type during the SHIP review

ok my bigger macro items have been addressed ... I will thus

/approve

given the collaboration I see in the commits between @coreydaley @HeavyWombat @shahulsonhal, as well as the review from @SaschaSchwarze0 I am going to defer the lgtm to one of them. Aside from their in depth involvement, it allows for the cross team etc. sign off we prefer.

thanks everyone

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 5, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gabemontero

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 5, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Looks good, one mandatory item remaining regarding for which steps environment variables are set in the TaskSpec.

Beside that, two bonus items that we can also do in a later PR:

  1. In the build.md and buildrun.md, your examples for valueFrom are all working I guess, but are not covering a useful scenario, I think. A useful scenario could be to get an environment variable value for NPM_TOKEN from a secret in the context of a Buildpacks or s2i build.
  2. In the Build validation, we could add another check that verifies that an environment variable name does not colide with any step in the build strategy steps.

EDIT: and a third bonus item would be the validation of secrets and configmaps. We today validate that a referenced source secret, and output secret exist. We could validate the same for any secrets or configmaps referenced in environment variables.

pkg/reconciler/buildrun/resources/taskrun.go Outdated Show resolved Hide resolved
@adambkaplan adambkaplan added this to the release-v0.6.0 milestone Oct 6, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

My comment might be stupid, but I am coming from a decade of Java development where by-mistake-mutations-of-cached-objects was a quite often found issue and it was always a pain. Might not even apply here, so, if you tell me you're fully confident that your code is safe, I am also fine to take what you have.

pkg/reconciler/buildrun/resources/taskrun.go Outdated Show resolved Hide resolved
Co-authored-by: Sascha Schwarze <schwarzs@de.ibm.com>
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2021
@openshift-merge-robot openshift-merge-robot merged commit 3b546e7 into shipwright-io:main Oct 6, 2021
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants