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 pvc vs bucket detection case 🌵 #475

Merged

Conversation

vdemeester
Copy link
Member

Depending on the config-artifact-bucket configMap, build-pipeline
will create either a PVC or GCS Bucket for sharing output between
task(run)s in the pipeline. There was a bug (or missing case) in the
code that checks if it needs to create PVC.

We want to create a PVC in the following cases:

  • the config-artifact-bucket configMap is missing
  • the config-artifact-bucket configMap data is empty
  • the config-artifact-bucket configMap has no
    BucketLocationKey (aka location) or it's value is empty.

The 2nd case wasn't correctly handled between
InitializedArtifactStorage and GetArtifactStorage functions.

/cc @shashwathi

Signed-off-by: Vincent Demeester vdemeest@redhat.com

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Feb 5, 2019
@knative-prow-robot
Copy link

[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

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 5, 2019
@abayer
Copy link
Contributor

abayer commented Feb 5, 2019

+1 from me!

@vdemeester
Copy link
Member Author

/hold

I'll be adding some unit tests 👼

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 5, 2019
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 5, 2019
@vdemeester
Copy link
Member Author

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 5, 2019
Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

Thanks for catching this @vdemeester !! just a couple comments about logging/error handling :D

if strings.TrimSpace(location) == "" {
return true
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like in some of these cases we should be logging a warning or something, what do you think? if the user provided the configmap but didn't provide the data or url, that seems like they made a mistake? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@bobcatfish good point, I'll add some logging in there 😉

@@ -68,11 +54,31 @@ func InitializeArtifactStorage(pr *v1alpha1.PipelineRun, c kubernetes.Interface)
return NewArtifactBucketConfigFromConfigMap(configMap)
}

func needsPVC(configMap *corev1.ConfigMap, err error) bool {
if err != nil {
return true
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm in this error case we should definitely at least log i think (unless it's a not found error, which we can probably check for explicitly) - if not even fail the run?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point 👍 didn't change the current behavior but if it's not a not found error, it seems fishy and we may fail the run as a fail early 👼

Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

Great catch. Looks like @bobcatfish has comments so I will leave this upto her to lgtm this PR.

I had a thought when @vdemeester was debugging this. From a user how can I realize from pod spec whether this is using pvc or bucket?
If its bucket storage then pod spec should contain the volume mount pointing to config map and if its PVC then it should have pvc volume mount. The information exists but it is in gigantic pod spec of taskrun.
Can we use labels or annotation to add some meta info to get this info in clear way? Do you think this would have helped you debug faster or better @vdemeester

@shashwathi
Copy link
Contributor

/assign @bobcatfish

Depending on the `config-artifact-bucket` configMap, `build-pipeline`
will create either a PVC or GCS Bucket for sharing output between
task(run)s in the pipeline. There was a bug (or missing case) in the
code that checks if it needs to create PVC.

We want to create a PVC in the following cases:
- the `config-artifact-bucket` configMap is missing
- the `config-artifact-bucket` configMap data is empty
- the `config-artifact-bucket` configMap has no
`BucketLocationKey` (aka `location`) *or* it's value is empty.

The 2nd case wasn't correctly handled between
`InitializedArtifactStorage` and `GetArtifactStorage` functions.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the fix-pvc-need-detection branch 2 times, most recently from 48f9141 to dba7b6b Compare February 6, 2019 11:22
# - https://github.com/knative/build-pipeline/pull/443
# for test in taskrun pipelinerun; do
for test in taskrun; do
for test in taskrun pipelinerun; do
Copy link
Member Author

Choose a reason for hiding this comment

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

@bobcatfish trying something 🙃 related to #477

Copy link
Collaborator

Choose a reason for hiding this comment

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

😅

@vdemeester
Copy link
Member Author

I0206 11:38:57.871] [demo-pipeline-run-1-build-skaffold-web] [build-step-source-copy-skaffold-image-leeroy-web] {"level":"error","ts":1549453114.161359,"logger":"fallback-logger","caller":"bash/main.go:62","msg":"Error executing command \"cp -r /workspace/output/builtImage/. /pvc/build-skaffold-web/builtImage\" with arguments cp: can't stat '/workspace/output/builtImage/.': No such file or directory\n","stacktrace":"main.main\n\t/go/src/github.com/knative/build-pipeline/cmd/bash/main.go:62\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:201"}

ok it's trying to copy /workspace/output/builtImage content, which, I'm guessing is not existing because kaniko push the image (and didn't create anything here) to gcr.io/knative-boskos-14/kbuild-pipeline-e2e-img/leeroy-web:latest

@vdemeester
Copy link
Member Author

vdemeester commented Feb 6, 2019

Removed dba7b6b commit 👼

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-build-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/artifacts/artifacts_storage.go 87.0% 82.8% -4.2

@abayer
Copy link
Contributor

abayer commented Feb 6, 2019

/lgtm
/meow space

@knative-prow-robot
Copy link

@abayer: cat image

In response to this:

/lgtm
/meow space

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.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 6, 2019
@abayer
Copy link
Contributor

abayer commented Feb 6, 2019

Also, because why not:
/meow boxes

@knative-prow-robot
Copy link

@abayer: cat image

In response to this:

Also, because why not:
/meow boxes

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.

@bobcatfish
Copy link
Collaborator

ooo boxes, that's a good one @abayer

@knative-prow-robot knative-prow-robot merged commit 6411f05 into tektoncd:master Feb 6, 2019
@vdemeester vdemeester deleted the fix-pvc-need-detection branch February 6, 2019 17:54
@vdemeester vdemeester restored the fix-pvc-need-detection branch February 26, 2019 09:17
@vdemeester vdemeester deleted the fix-pvc-need-detection branch February 26, 2019 09:17
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants