Skip to content

Some charts having diffs where there are no changes #305

Closed

Description

@mahgo

I'm having a problem with some charts when calling helm diff upgrade; it is detecting changes but when viewing the outputted diff, it appears to be the same. For example:

default, foo-bar-service, Service (v1) has changed:
  # Source: foo-bar/templates/service.yaml
- apiVersion: v1
- kind: Service
- metadata:
-   name: foo-bar-service
- spec:
-   type: NodePort
-   selector:
-     app: foo-bar-frontend
-   ports:
-   - protocol: TCP
-     port: 80
+ apiVersion: v1
+ kind: Service
+ metadata:
+   name: foo-bar-service
+ spec:
+   type: NodePort
+   selector:
+     app: foo-bar-frontend
+   ports:
+   - protocol: TCP
+     port: 80
      targetPort:

Activity

  1. mahgo commented on Sep 17, 2021

    @mahgo
    Author

    This seems to only occur when the previous upgrade on a chart was from a different computer.

  2. jonerer commented on Oct 5, 2021

    @jonerer

    Could it be a difference in newlines? Like windows vs linux \r\n and \n? If you could check the content of the secrets, that would be interesting

  3. mahgo commented on Oct 8, 2021

    @mahgo
    Author

    Using --normalize-manifests (not yet in a release) seems to fix this issue. But is this something that you should need to use a parameter on or should this be the sort of thing that is fixed by default?

  4. mahgo commented on Oct 8, 2021

    @mahgo
    Author

    @jonerer I have mainly been using Linux and WSL2 Linux, which probably shouldn't be different. What would be the best way to check this?

  5. jonerer commented on Oct 8, 2021

    @jonerer

    Send the output of helm template to a file and have a look at it. And then try to see what's bee written in the helm secret in your cluster. Kubectl get secrets and have a look around to find it

  6. stale commented on Jan 8, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  7. mumoshu commented on Jan 9, 2022

    @mumoshu
    Collaborator

    Could anyone buy me a Windows laptop for testing or contribute a fix? 😃

    Anyway, if it's a line-ending issue, it would have something to do with the fact that we call helm get manifest RELEASE and helm template to get the current and the desired manifests to be diffed. Maybe normalize line-endings by default there ould fix it.

  8. mahgo commented on Jan 10, 2022

    @mahgo
    Author

    I can test this in the next few days. I'd definitely be up for normalizing the line endings by default though. Are there any use cases for not wanting to normalize line endings?

  9. mumoshu commented on Jan 10, 2022

    @mumoshu
    Collaborator

    @mahgo Thanks. The point here is that helm-diff should be normalizing line-endings already. --normalize-manifests isn't intended for normalizing line-endings only so enabling it by default isn't an option imho.

  10. mahgo commented on Jan 11, 2022

    @mahgo
    Author

    @mumoshu I've done a diff on the manifest and template using git diff --no-index --word-diff=color --word-diff-regex=. manifest.txt template.txt. Here's a snippet of the output:
    image

  11. mumoshu commented on Jan 11, 2022

    @mumoshu
    Collaborator

    @mahgo Assuming ^M represents a carriage-return, does it mean that you have carriage-returns in the result only in the output of helm-template, right?

  12. mumoshu commented on Jan 11, 2022

    @mumoshu
    Collaborator

    @mahgo Would you mind checking how the result looks like when you used helm upgrade --dry-run instead of helm template to generate template.txt?

  13. 4 remaining items

  14. mahgo commented on Jan 11, 2022

    @mahgo
    Author

    @mumoshu Was given access to their git repository, to collaborate with them.

  15. mumoshu commented on Jan 11, 2022

    @mumoshu
    Collaborator

    @mahgo Thanks. You used git clone to fetched the chart, right?

  16. mahgo commented on Jan 11, 2022

    @mahgo
    Author

    @mumoshu Yes that is correct.

    Should helm-diff ignore this character by default maybe? Or is there a reason not to?

  17. mumoshu commented on Jan 11, 2022

    @mumoshu
    Collaborator

    @mahgo Hmmm, maybe..? Honestly, I'm not yet sure why helm-diff needs to that even though helm doesn't do it (in helm-template and helm-upgrade-dry-run)

    A workaround would be to set your git config correctly, so that it won't automatically add carriage-returns.
    Does it sound too terrible?

  18. mahgo commented on Jan 11, 2022

    @mahgo
    Author

    @mumoshu I think it would be good for helm-diff to ignore this by default. Would be keen to hear what others think.

    Looking into why git adds these carraige-returns too is probably not a bad idea as well, thanks.

  19. mahgo commented on Jan 11, 2022

    @mahgo
    Author

    Maybe make --normalize-manifests default but give an option to turn it off? Is there anyone that has a use case in which using --normalize-manifests is a problem?

  20. mumoshu commented on Jan 19, 2022

    @mumoshu
    Collaborator

    anyone that has a use case in which using --normalize-manifests is a problem?

    @mahgo AFAIK, no. But that doesn't mean it is battle-tested to work for every use case. That's why I'm not eager to turn it on by default. Flipping a big feature flag just to resolve one issue that happens only on Windows might not be a great idea in terms of reliability.

  21. mahgo commented on Jan 19, 2022

    @mahgo
    Author

    That's fair enough. What do you think about showing these hidden characters in the diff, when they are the cause of the diff line?

  22. mumoshu commented on Jan 23, 2022

    @mumoshu
    Collaborator

    @mahgo Sounds like a nice-to-have from the user's perspective, but as a maintainer, I would prefer a mechanism like that to be implemented outside of helm-diff.

    We use aryann/difflib for taking diff between two inputs so probably anyone could contribute to the library for the addition? 🤔

  23. mumoshu commented on Jan 23, 2022

    @mumoshu
    Collaborator

    Also, we're going to enable helm-diff to toggle --normalize-manifests via an envvar. See #358.
    If your issue can be rephrased to be concern about repeating --normalize-manifests for every helm-diff run, would the ability to toggle it via the envvar helps?

  24. jack1902 commented on Jan 25, 2022

    @jack1902

    Potentially related, but i'm using ansible to run my helm-charts which has helm diff installed for better detection of changes.

    For some of the charts, it all works perfectly but for one in particular its behaving as if there is a change on every run, even when nothing on the file system has changed. To elaborate, the helm-chart consumes values which I am reading in from a file on disk using lookup('file', 'FILEPATH') to get the value of the file into helm as an example:

    ansible snippet
    ---
    # Get linkerd charts
    - name: Add linkerd chart repo
      kubernetes.core.helm_repository:
        name: linkerd
        repo_url: "https://helm.linkerd.io/stable"
    
    - name: Deploy linkerd2 chart
      kubernetes.core.helm:
        name: linkerd2
        chart_ref: linkerd/linkerd2
        chart_version: 2.11.1
        release_namespace: linkerd
        wait: true
        release_values:
          installNamespace: false
          # ca.crt
          identityTrustAnchorsPEM: "{{ lookup('file', 'ca.crt') }}"
          identity:
            issuer:
              tls:
                # issuer.crt
                crtPEM: "{{ lookup('file', 'issuer.crt') }}"
                # issuer.key
                keyPEM: "{{ lookup('file', 'issuer.key') }}"

    The files being read-in are certificate files which are strings over multiple lines. No matter what I do, I constantly have ansible re-install the chart which is wholly unnecessary. Would --nomalize-manifests work in this use-case since the values are set as secrets.

    Happy to attempt any debugging

  25. mumoshu commented on Jan 26, 2022

    @mumoshu
    Collaborator

    @jack1902 To be extra sure what's going on- are you running ansible on Windows/WSL/cygwin/etc?

  26. stale commented on Apr 27, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions