-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Enable sidecars to partake in substitution #1770
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi @MLBMatt. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
/ok-to-test Thanks for this! Can you add a YAML example that demonstrates this works? This serves as a runnable sample, and as a test that this continues to work as expected. Also, please provide release notes for this user visible change. |
@imjasonh Added a yaml example to the docs, added a bit more implementation, updated more to the tests and added release notes. |
/retest |
Thanks for adding the example to the docs. If you add a working example to Something like spec:
taskSpec:
inputs:
params:
- name: value
default: default-value
sidecars:
- name: slow-sidecar
image: ubuntu
command:
- sh
- -c
- echo $(inputs.params.value) > /shared/value && sleep infinity
volumeMounts:
- name: shared
mountPath: /shared
steps:
- image: ubuntu
# The step will only succeed if the sidecar resolved the param value.
script: |
#!/usr/bin/env bash
VALUE=$(cat /shared/value)
[[ $VALUE == $(inputs.params.value) ]]
volumeMounts:
- name: shared
mountPath: /shared (I haven't tested this, but something like it should work, and prove that params are resolved in the sidecar) |
@imjasonh I added an example, however I couldn't get it working locally because of, what looks like, the noop bug associated with sidecars. I couldn't get your sidecar-ready.yaml example working either, so I'm not sure if it's me or tekton. |
@MLBMatt Can you describe a bit the problems you encountered? I was able to get your example working with the code on your branch but I'd like to understand the issue you're seeing before giving this a 👍 |
@sbwsg I was defining a command for my sidecar however it looked like the sleep was never running correctly, was being replaced by the I've seen that, in order for the sidecar to be killed correctly, the sidecar is modified to exit cleanly but for me, this looked to still be broken on my end? Maybe I don't have the latest controller version? |
Ah ok great that's actually expected behaviour! In order to stop sidecars when the task steps finish we have to replace the image of the sidecar's container. Bit wonky but it (mostly) works until k8s supports sidecar lifecycle containers natively. |
(Just to confirm - did the TaskRun end with a successful status?) |
@sbwsg Ah ok, yes the task container ended in a edit: Well the pod itself ends in a |
I get a status
This from the replaced |
Tekton ignores the failure of the sidecar container. The TaskRun ends with a condition of Succeeded / True and the step-check-value Step has an exit code of 0 with reason Completed (at least on my machine). I think we're all good here in terms of this example. Edit: sidecar pod -> sidecar container |
@sbwsg awesome! 🎉 |
/lgtm |
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func ApplyContainerReplacements(step *corev1.Container, stringReplacements map[string]string, arrayReplacements map[string][]string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this doesn't need to be exported, except to be tested in container_replacements_test.go.
Can we either test this as an unexported method, or only test the exported surface in apply_test.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imjasonh it's also used in https://github.com/tektoncd/pipeline/pull/1770/files#diff-768a3668fda546db3140aa35963e1247R25, not sure if that still warrants not exporting (I'm super new to Go, so the import/export semantics elude me a bit right now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, looks like this is used by the resources package as well and so needs to live on as exported for the time being 👍
@MLBMatt thanks for the PR, could you squash the commits, rebase on top of latest master, and ensure that the commit message continues to match the PR description you've included here (after all the squashing is done)? I think otherwise this is looking ready to merge. Many thanks! 🙏 |
This change enables sidecars to use variable subtitution and leverage pipeline-specific params to execute whatever actions during a pipelinerun. Fixes tektoncd#1761
@sbwsg squashed and rebased 👍 |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg 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 |
/retest |
1 similar comment
/retest |
/lgtm |
This change enables sidecars to use variable subtitution and leverage
pipeline-specific params to execute whatever actions during a
pipelinerun.
Fixes #1761
Changes
This change enables sidecars to use variable subtitution and leverage
pipeline-specific params to execute whatever actions during a
pipelinerun.
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:
cmd
dir, please updatethe release Task to build and release this image.
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