buildpacks / tekton-integration

Buildpacks + Tekton
22 stars 3 forks source link

Warning "Tekton fails in step-image-digest-exporter with No index.json found" #17

Closed jromero closed 3 years ago

jromero commented 3 years ago

Clone from https://github.com/tektoncd/catalog/issues/616

The sample task for buildpacks all define an output resource for the image, for example here:

  resources:
    outputs:
      - name: image
        type: image

This leads to the logic described in Surfacing the image digest built in a task to apply. Tekton will try to find out the digest of the image at its default location, /workspace/output/${resourceName}, by checking the OCI image layout index.json. The code to extract the digest runs in the step-image-digest-exporter container after the Task's steps have finished.

The sample buildpacks task is not producing the index.json file and therefore causes the warning Tekton fails in step-image-digest-exporter with No index.json found.

Expected Behavior

The sample task should either produce an index.json file so that the output resource can be used by Tekton, or does not define the output resource. (with a preference on the first choice ;-) )

Actual Behavior

The output resource is defined but no index.json is produced leading to the image digest missing in the TaskRun's status and the warning in the logs.

Steps to Reproduce the Problem

  1. Use the Buildpacks sample task with any suitable source code

Additional Info

I slightly modified the task definition as a workaround:

  1. I add chown -R "$(params.USER_ID):$(params.GROUP_ID)" /workspace/output to the prepare step
  2. I add the -report=/workspace/output/image/report.toml argument to the creator call
  3. I modified the creator step to not just run the creator but also this little script: echo "{\"schemaVersion\":2,\"manifests\":[{\"mediaType\":\"application/vnd.docker.distribution.manifest.v2+json\",\"digest\":\"$(cat /workspace/output/image/report.toml | grep digest | tr -d ' \"' | sed s/digest=//)\"}]}" > /workspace/output/image/index.json

This works, but while the first two things are okayish, the third item looks a little hacky. Maybe there is a better way to support this?

jromero commented 3 years ago

Hi @SaschaSchwarze0, I cloned this issue to this repo since this is where we'll be continuing the development of the mentioned task.

I appreciate you reporting this issue. I notices this quote "with a preference on the first choice" with reference to "produce an index.json file so that the output resource can be used by Tekton". Given that we've moved away from resources due to the recommendations made here, I'm curious if a task result would suffice. Similar to buildah's digest result. This would be my prefered method of moving forward but want to make sure it would satisfy any use case you may have in mind.

SaschaSchwarze0 commented 3 years ago

I appreciate you reporting this issue. I notices this quote "with a preference on the first choice" with reference to "produce an index.json file so that the output resource can be used by Tekton". Given that we've moved away from resources due to the recommendations made here, I'm curious if a task result would suffice. Similar to buildah's digest result. This would be my prefered method of moving forward but want to make sure it would satisfy any use case you may have in mind.

Is fine. I was basically stating that one should either fix the usage of the existing capability, or remove it. I was in favor of fixing it = to make sure that the image digest is available. If it is in the result, then that's fine with me.