microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.46k stars 2.6k forks source link

[BUG]: KubernetesManifest@v0 and v1 do not update container image when registry/repository do not match #19393

Open cristianrgreco opened 8 months ago

cristianrgreco commented 8 months ago

New issue checklist

Task name

KubernetesManifest

Task version

v0 and v1

Issue Description

I have the following example Kubernetes manifest:

      containers:
          image: registry1.azurecr.io/repository1:latest

I have configured this DevOps task to update the container image:

      - task: KubernetesManifest@0
        inputs:
          action: deploy
          containers: |
            registry2.azurecr.io/repository2:${{parameters.version}}
          manifests: |
            $(System.DefaultWorkingDirectory)/manifest.yaml

Expected: The container image is updated to registry2.azurecr.io/repository2:${{parameters.version}}.

Actual: The container image is not updated. No warnings or errors logged.

I've found the code which is responsible, it's here: https://github.com/microsoft/azure-pipelines-tasks/blob/v232/Tasks/KubernetesManifestV1/src/utils/KubernetesObjectUtility.ts#L339-L363

See that it will only update the image if the registry/repository match. I don't know what the reasoning is (we assume it's because the manifests/containers are both lists and could not be in-order), but if it's expected, please update the containers part of the task documentation to say this.

This took several hours to figure out why the container image was not updating.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu 20.04

Relevant log output

N/A

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

No response

dillingerlab commented 7 months ago

I also spent a bit of time debugging this "issue". The check seems to make sense so just having something in the docs would be appreciated.

Chamssiddine commented 2 months ago

The KubernetesManifest@1 is not updating the image is there any updates on this bug ?