GoogleContainerTools / GoogleContainerTools/skaffold
[BUG] kaniko will not delete DockerConfigSecret when build fails
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
building with kaniko and `cluster.dockerConfig.path` configured , if first build fails, skaffold wont delete the DockerConfigSecret, and it will prevent the second try.
seems that [teardownDockerConfigSecret](https://github.com/catusax/skaffold/blob/25b4db5d9cb83f7dceaa686109c94e9f42dcf641/pkg/skaffold/build/cluster/cluster.go#L49) func is a PostBuild function, and postbuild function only runs when build success.
setting [randomDockerConfigSecret](https://skaffold.dev/docs/references/yaml/?version=v3#build-cluster-randomDockerConfigSecret) to true can solve the problem temporarily ,but all failed builds will create docker-cfg secret and needs to delete manually.
i think skaffold should use `kubectl apply` instead of `kubectl create` to create docker-cfg at here
[if _, err := secrets.Create(ctx, secret, metav1.CreateOptions{}); err != nil {](https://github.com/catusax/skaffold/blob/25b4db5d9cb83f7dceaa686109c94e9f42dcf641/pkg/skaffold/build/cluster/secret.go#L132)
should i make a pr?
### Expected behavior
start building
### Actual behavior
skaffold prints error `creating docker config secret "docker-cfg": secrets "docker-cfg" already exists`
```
Generating tags...
- registry.filcoin.xyz:8900/filexplorer/miners -> registry.filcoin.xyz:8900/filexplorer/miners:latest-prod
Checking cache...
- registry.filcoin.xyz:8900/filexplorer/miners: Not found. Building
Starting build...
Creating docker config secret [docker-cfg]...
creating docker config secret "docker-cfg": secrets "docker-cfg" already exists
```
### Information
- Skaffold version: main branch
- Operating system: macos 13.1
- Contents of skaffold.yaml:
```yaml
apiVersion: skaffold/v3
kind: Config
metadata:
name: app
build:
tagPolicy:
envTemplate:
template: "latest"
artifacts:
- image: app
kaniko:
buildArgs:
gitlab_account: "{{ .GITLAB_TOKEN }}"
cluster:
dockerConfig:
path: dockerconfig.json
deploy:
kubectl: {}
statusCheck: true
statusCheckDeadlineSeconds: 300
manifests:
rawYaml:
- resources/*.yaml
```
### Steps to reproduce the behavior
1. `skaffold build`
2. after build starts, use ctrl-c stop it.
3. run `skaffold build` again
Contributor guide
Assessment
This issue has not been assessed yet.