GoogleContainerTools / GoogleContainerTools/skaffold

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

Open
#9,645 0 comments 0 reactions 0 assignees View on GitHub
build/gcb kind/bug
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

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](https://github.com/GoogleContainerTools/skaffold/blob/bcd018015a4994a0f4693166728843ec79034a74/pkg/skaffold/build/gcb/cloud_build.go#L223) 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:

```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](https://cloud.google.com/build/docs/build-push-docker-image#prepare_source_files_to_build)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.