TykTechnologies/tyk-operator

[TT-8658] json serialization settings cause mis-alignment between desired and live manifests

patriziobrunops opened this issue · 4 comments

When I create an api-definition setting some bool fields to their default values, the live manifest returned by kubernetes doesn't contain those fields. I am using ArgoCD to deploy my manifests through helm charts. The end result is that ArgoCD keeps complaining about out-of-sync api-definitions (see screenshot attached). Though currently I'm not experiencing the problem with strings, I'd expect the same problem.

Expected Behavior

The live manifest should parse exactly like the desired manifest.

Current Behavior

Boolean fields are excluded from the live manifest when they're set to false.

Possible Solution

Replace bool fields with *bool. This will cause the serializer to output false when appropriate, and omit serialization only for non-set values.

Steps to Reproduce

  1. save the the following manifest in a file named desired-test-api.yaml and use it to create an api-definition by running kubectl create -f desired-test-api.yaml:
    apiVersion: tyk.tyk.io/v1alpha1
    kind: ApiDefinition
    metadata:
      name: test-api
    spec:
      active: true
      proxy:
          strip_listen_path: false
          listen_path: /
  2. save the live manifest into a temporary file: kubectl get apidefinition test-api -o yaml > live-test-api.yaml
  3. compare the desired and live manifests: diff desired-test-api.yaml live-test-api.yaml. The spec object should be the same between the two files.

Screenshots/Video

ArgoCD

Context

Your Environment

  • OS (e.g. Linux, macOS, Windows):
    • OS version:
  • tyk-operator version/commit:

Thank you @patriziobrunops for raising the issue. We have added it in our backlog.

We always welcome community contributions! Please feel free to submit a pull request or reach out to us if you have any questions or suggestions.

Hi @patriziobrunops , do you need to include false values for some reason? false boolean values or empty string values are considered default and is omitted from saving to spec.

Hi @patriziobrunops , the fix has been merged to master. It will be available soon in v0.14.2.

Thanks for the report as always!

Hi @caroltyk , thanks! I still see many booleans with pointers in the apispec that can cause the same issue, but I'll report it if/when we'll have the problem. It's always great working with you 🙂