Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Manifest comments are removed #2660

Closed
rtluckie opened this issue Dec 4, 2019 · 3 comments
Closed

Manifest comments are removed #2660

rtluckie opened this issue Dec 4, 2019 · 3 comments

Comments

@rtluckie
Copy link

rtluckie commented Dec 4, 2019

Describe the bug
Comments in yaml manifests are removed when images are updated via a automated release

To Reproduce
Steps to reproduce the behaviour:

  1. Create a manifest w/ automation enabled with a comment (see below)
  2. Trigger a image update
  3. Observe comment is removed

Expected behavior
Comments should persist

Additional context
Add any other context about the problem here, e.g

  • Flux version: flux:1.15.0
  • Helm Operator version: helm-operator:1.0.0-rc3
  • Kubernetes version: 1.16.3
  • Git provider: github enterprise
  • Container registry provider: docker.io
##################################################
#            **DO NOT EDIT MANUALLY**
#
# This file is auto-generated by `make generate`
##################################################
 ---
 apiVersion: helm.fluxcd.io/v1
 kind: HelmRelease
...
@rtluckie rtluckie added blocked-needs-validation Issue is waiting to be validated before we can proceed bug labels Dec 4, 2019
@2opremio 2opremio removed the blocked-needs-validation Issue is waiting to be validated before we can proceed label Dec 6, 2019
@2opremio
Copy link
Contributor

2opremio commented Dec 6, 2019

TL;DR: the problem is that there there isn't a YAML parser out there which is infallible at preserving comments.

In order to update the manifests you need to: parse the manifests-> make modifications -> write the manifest back.

To keep the comments you need a parser which preserves them (also called a roundtrip parser). Most of the YAML parsers are not roundtrip and the ones which are aren't infalible.

The best parser we could find is ruamel.yaml, which is written in Python. Flux is written in Go, but @squaremo created a Python program ( https://github.com/squaremo/kubeyaml ) which is invoked by Flux with the only purpose of having a decent rountrip YAML parser for editing manifests.

ruamel.yaml isn't infallibe, as you are experiencing.

So, we cannot do much besides writing a YAML parser ourselves (for which we don't have the manpower) or wait until a better parser is made available (which is basically what we are doing).

@2opremio
Copy link
Contributor

2opremio commented Dec 6, 2019

related: #1933

@kingdonb
Copy link
Member

Manifests are allowed (and expected) to have comments now, with image-automation-controller in Flux v2, which uses an upstream Kustomize library, kyaml, to drive image updates by ImagePolicy kyaml setter annotations that live in comments.

Ref: kubernetes-sigs/kustomize#3559, #3425, there are still issues with yaml reformatter not preserving things which folks want to have preserved (such as an extra indent in list syntax) but they can be addressed with upstreams now, and are not a responsibility of any software within the FluxCD org anymore.

Flux v1 is in maintenance mode now, I will go ahead and close out this issue for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants