Skip to content

'flux build kustomization' corrupts files when run concurrently #5781

@rycli

Description

@rycli

Describe the bug

When multiple instances of the flux build kustomization command are run concurrently, there is a chance of corruption due to the file writing of .original creation and related logic. This manifests as;

  • kustomization.yaml files being modified/corrupted
  • kustomization.yaml files being emptied
  • kustomization.yaml.original files being left behind
  • failing builds, due to the above

A similar build failure also occurs if the repository files/directories are read-only.

Steps to reproduce

Given that this is a timing-sensitive issue, I've created a set of small reproduction scripts at https://github.com/rycli/fluxcd-kustomize-build-bug-repro . See the README.txt for example output of the failures.

Expected behavior

One or more of the following:

  • flux kustomize build does not write any files.
  • flux only writes files when necessary (e.g., missing kustomization.yaml file)
  • flux writes all of its files to a tempdir/the configured cache dir.

OS / Distro

macOS 26, Ubuntu 24

Flux version

v2.8.1

Additional context

While this doesn't happen on every execution, I'm consistently running into this issue when running Flux in CI/CD pipelines. I'm running a busy multi-tenant environment with very frequent automated checks; these issues end up showing up rather frequently.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions