Bug: fails to deploy two manifests with the same name
What happened?
I have the following:
...
...
- name: Deploy frontend & backend
uses: azure/k8s-deploy@v4
with:
namespace: default
manifests: |
artifacts/frontend/deployment.yaml
artifacts/backend/deployment.yaml
...
...
Since the two manifests have the same name (deployment.yaml) it deploys the same file twice. Probably, because all files are copied to the same /tmp folder, overwrite each other, and then deployed by their name only.
There's a simple workaround to use two separate steps for that, which I did and it works fine now, But I have suffered a lot before figuring out the issue.
The workaround:
...
...
- name: Deploy frontend
uses: azure/k8s-deploy@v4
with:
namespace: default
manifests: |
artifacts/frontend/deployment.yaml
- name: Deploy backend
uses: azure/k8s-deploy@v4
with:
namespace: default
manifests: |
artifacts/backend/deployment.yaml
...
...
Version
- [X] I am using the latest version
Runner
ubuntu-latest
Relevant log output
##[debug]Evaluating condition for step: 'Deploy frontend & backend'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Deploy frontend & backend
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run azure/k8s-deploy@v[4](https://github.com/motcke/*****#step:6:4)
##[debug]Input manifest files: /tmp/deployment.yaml,/tmp/deployment.yaml
::group::Deploying manifests
Deploying manifests
##[debug]Kubectl run with command: /usr/bin/kubectl apply,-f,/tmp/deployment.yaml,/tmp/deployment.yaml,--namespace,default
/usr/bin/kubectl apply -f /tmp/deployment.yaml,/tmp/deployment.yaml --namespace default
service/*****-svc unchanged
deployment.apps/*****-deploy configured
horizontalpodautoscaler.autoscaling/*****-scaler unchanged
secretproviderclass.secrets-store.csi.x-k8s.io/******-sync-env-vars configured
service/******-svc unchanged
deployment.apps/******-deploy configured
horizontalpodautoscaler.autoscaling/******-scaler unchanged
secretproviderclass.secrets-store.csi.x-k8s.io/******-sync-env-vars unchanged
##[debug]Deployed manifest files: /tmp/deployment.yaml,/tmp/deployment.yaml
::endgroup::
::group::Checking manifest stability
Checking manifest stability
...
...
...
In my case it detects multiple manifests, but duplicates first one.
Run ls -l manifests
total 8
drwxr-xr-x 2 runner docker [4]096 Jun 18 22:19 manifests-front
drwxr-xr-x 2 runner docker 4096 Jun 18 22:19 manifests-imgproxy
In both (or more) directories there are deployment.yml service.yml and ingress.yml
And then I'm applying them:
-
name: Deploy manifests to cluster
uses: azure/k8s-deploy@v5
with:
manifests: |
manifests
imagepullsecrets: ghcr
But for some reason instead using all files for kubectl apply, it is duplicating paths always from first one. So also If will try to deploy manifests for 3 services (x, y, z), it will try to deploy "x" three times instead. That has to be a bug.
/usr/bin/kubectl apply -f /tmp/Deployment_imgproxy_1718749155628, /tmp/Ingress_imgproxy_1718749155628, /tmp/Service_imgproxy_1718749155628, /tmp/Deployment_imgproxy_1718749155628, // it should be "front" /tmp/Ingress_imgproxy_1718749155628, // it should be "front" /tmp/Service_imgproxy_1718749155628 // it should be "front" --namespace default
Checking manifest stability /usr/bin/kubectl rollout status Deployment/imgproxy --namespace default deployment "imgproxy" successfully rolled out /usr/bin/kubectl rollout status Deployment/imgproxy --namespace default deployment "imgproxy" successfully rolled out
@motcke you said that issue is maybe due to fact that all directories are merged into /tmp. It is true, but in theory it should be handled ok. In logs we can see that this action is generating unique names based on original subdirectory and timestamp, so there should be no problem with conflicts.
Edit: @motcke was right - file name is indeed not unique in tmp https://github.com/Azure/k8s-deploy/blob/main/src/utilities/manifestUpdateUtils.ts#L95
looking into this!