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

Empty commits #135

Closed
PaulRudin opened this issue Mar 24, 2021 · 5 comments · Fixed by #142
Closed

Empty commits #135

PaulRudin opened this issue Mar 24, 2021 · 5 comments · Fixed by #142
Labels
bug Something isn't working

Comments

@PaulRudin
Copy link

I have an ImageUpdateAutomation object with spec.interval set to 1m0s. I see a new commit to my repo every minute, whether or not any image has changed, so the vast majority of these commits are empty commits (i.e. no changes).

The empty commits are, I suppose, harmless; but it would be nice if there was a way of avoiding them.

@squaremo
Copy link
Member

In the normal course of things, I would expect the controller to skip an update when there are no changes made. Are you using the new "push branch" part of the API?

  push:
    branch: <something>

Can I see the ImageUpdateAutomation definition, perhaps?

@PaulRudin
Copy link
Author

I don't think I'm using the "push branch" thing... here's the definition:

---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
  name: flux-system
  namespace: flux-system
spec:
  interval: 1m0s
  ref:
    branch: main
  secretRef:
    name: flux-system
  url: https://github.com/PaulRudin/xamaral
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
  name: flux-system
  namespace: flux-system
spec:
  interval: 10m0s
  path: ./k8s/flux
  prune: true
  sourceRef:
    kind: GitRepository
    name: flux-system
  validation: client
---
apiVersion: image.toolkit.fluxcd.io/v1alpha1
kind: ImageUpdateAutomation
metadata:
  name: flux-system
  namespace: flux-system
spec:
  checkout:
    branch: main
    gitRepositoryRef:
      name: flux-system
  commit:
    authorEmail: [email protected]
    authorName: fluxcdbot
    messageTemplate: '[ci skip] update image'
  interval: 1m0s
  update:
    strategy: Setters

@squaremo
Copy link
Member

squaremo commented Apr 1, 2021

OK, I can reproduce the problem by forking your repo and making adjustments as necessary.

I restricted updates to the path k8s/gen/prod, in the hope that it was at least a workaround -- but the empty commits persist (and the investigation continues...)

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

squaremo commented Apr 1, 2021

Wow, OK: go-git/go-git#253
Basically: if you clone a repo with go-git and your repo contains a broken symlink, it will show as being modified. Flux treats this as a sign that there's something to commit.

I can put a couple of mitigations in:

  • if the update object has a path set, only look for modified files under that path
  • ignore broken symlinks specifically

@stefanprodan
Copy link
Member

@squaremo now I realise it's the same issue in the CLI, flux bootstrap for some users creates empty commits: fluxcd/flux2#1021

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