skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

Skaffold child builds using Kaniko fails with the Google Cloud Build integration

Open louisjimenez opened this issue 10 months ago • 0 comments

Using Skaffold to build an image from a Dockerfile with Kaniko on Google Cloud Build results in a parent build and a child build. The child build succeeds in building the image but the parent build fails with the error message:

error copying logs to stdout: invalid write result
ERROR
ERROR: build step 0 "gcr.io/k8s-skaffold/skaffold:v2.11.1" failed: step exited with non-zero status: 1

The error is coming from here in the implementation of the GCB builder.

Expected behavior

The intended functionality is that the Skaffold image would output the child build logs so that they could be surfaced in the parent build logs.

Actual behavior

The above error.

Information

  • Skaffold version: gcr.io/k8s-skaffold/skaffold:v2.11.1
  • Operating system: Google Cloud Build Default Pool VM
  • Installed via: Executed as image with the following args to Cloud Build [ "skaffold", "build", "--filename=skaffold.issue.yaml", "--timestamps=true" ]
  • Contents of skaffold.yaml:
apiVersion: skaffold/v4beta9
kind: Config
metadata:
  name: failing-parent-build

build:
  googleCloudBuild:
    region: asia-southeast1

  tagPolicy:
    dateTime: {}

  artifacts:  
    - image: asia-southeast1-docker.pkg.dev/test-project/test-repo/test-image
      kaniko:
        dockerfile: Dockerfile
        cache:
          cacheCopyLayers: true
        verbosity: debug
  • Contents of cloudbuild.yaml:
steps:
  - name: gcr.io/k8s-skaffold/skaffold:v2.11.1
    args: [ "skaffold", "build", "--filename=skaffold.issue.yaml", "--timestamps=true" ]
  • Contents of Dockerfile:
FROM alpine
COPY quickstart.sh /
CMD ["/quickstart.sh"]

Steps to reproduce the behavior

Steps are based on the Google Cloud Build quickstart

  1. Copy the above example skaffold.yaml, cloudbuild.yaml and Dockerfile to a directory.
  2. Create an empty quickstart.sh file in the same directory. touch quickstart.sh
  3. Run the command gcloud builds submit --region=asia-southeast1 --config cloudbuild.issue.yaml
  4. The parent build should successfully download the Skaffold image and create a child build using the image to build the Dockerfile with Kaniko.
  5. The parent build will fail when attempting to surface the child build logs from the Skaffold image.

louisjimenez avatar Jan 09 '25 15:01 louisjimenez