Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit-template also include non-updated images #133

Closed
bjornmagnusson opened this issue Mar 22, 2021 · 2 comments · Fixed by #144
Closed

commit-template also include non-updated images #133

bjornmagnusson opened this issue Mar 22, 2021 · 2 comments · Fixed by #144
Labels
bug Something isn't working

Comments

@bjornmagnusson
Copy link

Describe the bug

When using the message template for the image automation described in documentation, the commit includes not only the updated image but all images that using that ImageUpdateAutomation object.
In below only IMAGE1 is updated but both IMAGE1 and IMAGE2 is included in commit message

ImageUpdateAutomation object spec includes:
messageTemplate: 'Automated image update: {{range .Updated.Images}}{{println .}}{{end}}'

git show
Automated image update: IMAGE1 IMAGE2
diff --git a/workload1.yaml b/workload2.yaml
index 8e27b4c..77d76ab 100644
--- a/workload1.yaml
+++ b/workload1.yaml
@@ -21,7 +21,7 @@ spec:
     image:
       registry: REDACTED
       repository: REDACTED
-      tag: IMAGE1_OLDTAG # {"$imagepolicy": "flux-system:imageupdateobject:tag"}
+      tag: IMAGE1_NEWTAG # {"$imagepolicy": "flux-system:imageupdateobject:tag"}

To Reproduce

Steps to reproduce the behaviour:

  1. Add ImageUpdateAutomation yaml from documentation as above
  2. Use the added ImageUpdateAutomation in two workload yaml
  3. Trigger image update of one of the workload
  4. Commit message now includes both workload images/files

Expected behavior

Commit message should only include the updated image and its file.

Additional context

  • Kubernetes version: v1.19.7
  • Git provider: Bitbucket Server
  • Container registry provider: Docker Registry 2.0

Below please provide the output of the following commands:

flux --version
flux version 0.10.0
flux check
► checking prerequisites
✔ kubectl 1.19.7 >=1.18.0-0
✔ Kubernetes 1.19.7 >=1.16.0-0
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.8.2
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.7.0
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.7.1
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v0.9.3
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v0.10.0
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v0.9.1
✔ all checks passed
kubectl -n <namespace> get all
NAME                                               READY   STATUS    RESTARTS   AGE
pod/helm-controller-6d4885f6d8-jmlgg               1/1     Running   16         4d
pod/image-automation-controller-55f75dcb89-s8tnf   1/1     Running   15         4d
pod/image-reflector-controller-8bffb4df7-tskkm     1/1     Running   17         4d
pod/kustomize-controller-5dd4d4fd4f-6cwff          1/1     Running   20         4d
pod/notification-controller-f9d655df7-4mv5l        1/1     Running   18         4d
pod/source-controller-6b4d8df7f7-hj4nv             1/1     Running   19         4d

NAME                              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
service/notification-controller   ClusterIP   10.96.14.160     <none>        80/TCP    4d
service/source-controller         ClusterIP   10.110.111.185   <none>        80/TCP    4d
service/webhook-receiver          ClusterIP   10.102.88.174    <none>        80/TCP    4d

NAME                                          READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/helm-controller               1/1     1            1           4d
deployment.apps/image-automation-controller   1/1     1            1           4d
deployment.apps/image-reflector-controller    1/1     1            1           4d
deployment.apps/kustomize-controller          1/1     1            1           4d
deployment.apps/notification-controller       1/1     1            1           4d
deployment.apps/source-controller             1/1     1            1           4d

NAME                                                     DESIRED   CURRENT   READY   AGE
replicaset.apps/helm-controller-6d4885f6d8               1         1         1       4d
replicaset.apps/helm-controller-7fd55b8c9f               0         0         0       4d
replicaset.apps/image-automation-controller-55f75dcb89   1         1         1       4d
replicaset.apps/image-automation-controller-7d7bbb68c7   0         0         0       4d
replicaset.apps/image-reflector-controller-7848db879b    0         0         0       4d
replicaset.apps/image-reflector-controller-8bffb4df7     1         1         1       4d
replicaset.apps/kustomize-controller-5dd4d4fd4f          1         1         1       4d
replicaset.apps/kustomize-controller-84fdd79d5b          0         0         0       4d
replicaset.apps/notification-controller-d9464dbdf        0         0         0       4d
replicaset.apps/notification-controller-f9d655df7        1         1         1       4d
replicaset.apps/source-controller-6b4d8df7f7             1         1         1       4d
replicaset.apps/source-controller-798bd8fffb             0         0         0       4d
@bjornmagnusson bjornmagnusson changed the title ImageAutomation: commit-template also include non-updated images ImageUpdateAutomation: commit-template also include non-updated images Mar 22, 2021
@stefanprodan stefanprodan transferred this issue from fluxcd/flux2 Mar 22, 2021
@stefanprodan stefanprodan changed the title ImageUpdateAutomation: commit-template also include non-updated images commit-template also include non-updated images Mar 22, 2021
@Legion2
Copy link

Legion2 commented Mar 30, 2021

Same issue here, we have one ImageUpdateAutomation object for the whole cluster and every time one image is updates, the commit messages contains all images, so it is impossible to know which image actually was updates from the commit message alone.

@squaremo squaremo added the bug Something isn't working label Mar 31, 2021
@squaremo
Copy link
Member

squaremo commented Apr 5, 2021

I think I see what is happening here. It comes from me misunderstanding how setters keep count of when they are applied -- I thought they would only count when they made a change, but they count when they are referenced, whether or not they made a change.

squaremo added a commit that referenced this issue Apr 5, 2021
With reference to

    #133

this commmit adapts the update->result test so that it checks an
additional case: that a field with an update marker that _does_
correspond to a policy, but _doesn't_ get changed, is not included in
the results.

This test fails at present, because the method for determining the
result is to count which setters are referenced, rather than which
fields were changed.

Signed-off-by: Michael Bridgen <[email protected]>
squaremo added a commit that referenced this issue Apr 5, 2021
With reference to

    #133

this commit adapts the update->result test so that it checks an
additional case: that a field with an update marker that _does_
correspond to a policy, but _doesn't_ get changed, is not included in
the results.

This test fails at present, because the method for determining the
result is to count which setters are referenced, rather than which
fields were changed.

Signed-off-by: Michael Bridgen <[email protected]>
squaremo added a commit that referenced this issue Apr 6, 2021
With reference to

    #133

this commit adapts the update->result test so that it checks an
additional case: that a field with an update marker that _does_
correspond to a policy, but _doesn't_ get changed, is not included in
the results.

This test fails at present, because the method for determining the
result is to count which setters are referenced, rather than which
fields were changed.

Signed-off-by: Michael Bridgen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants