rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
260 stars 223 forks source link

Weird behavior of annotations field in rancher2_app_v2.monitoring #682

Open Jasstkn opened 3 years ago

Jasstkn commented 3 years ago

Hi! I was trying to configure monitoring and the huge output appeared in the console because of the changed hash in the annotations field. Is this expected behavior?

  # module.rancher_pre_prod_cluster_init.rancher2_app_v2.monitoring has been changed
  ~ resource "rancher2_app_v2" "monitoring" {
      ~ annotations                 = {
          ~ "objectset.rio.cattle.io/applied"         = "HASH" -> "HASH"
            # (4 unchanged elements hidden)
        }
        id                          = "c-XXXX.cattle-monitoring-system/rancher-monitoring"
        name                        = "rancher-monitoring"
        # (13 unchanged attributes hidden)
    }
rawmind0 commented 3 years ago

Hi @Jasstkn , not clear what you mean. Could you please provide more context around what are you trying to do and what is the issue??

Jasstkn commented 3 years ago

@rawmind0 Hi! My case is following - I deploy monitoring via rancher2_app_v2 and for values I provide external yaml file. Due to this changes everytime when something changes in the file (almost every time because of problem with YAML formatting) I see huuuuge output in terraform like this

 ~ resource "rancher2_app_v2" "monitoring" {
      ~ annotations                 = {
          ~ "objectset.rio.cattle.io/applied"         = "H4sIAAAAAAAA/+y9+ZKjyP04+CpEzUbYPaoSSAhJVIQjfqD7RvfRPeFKIDnEkYjkELIdsa+xr7dPskECOqqqe3psf73+xe78MTMFSeYnP/eVqb89OTAAKgjA0+vfnlzgwKfXJx+4igH9Fwe5ZoB809Wfnsk77AElHaCAILDh3fsXnOAAOk/PT4oPQWAid2U6EAfA8Z5e3dC2n59sIEMbp6sg+QiVAMOg7JuonM1VNhFtAGykk/MaYBWGrzMNFXI1VeO1GmRhvdrgFKbC19RaswY5rfH0j+cn4LooIOv9cGZTfXp9MqDtvADPe3r+7jgUu9B/0SPr6fWJjirP1Mh01b8soeLD4Hc/y5GHjXK6UtmHNgQYlqNK+SM+yxFb/akJfxfj/3h+IqMXUIM+dBWIn16//u0JeOYG+thE7tPrU1R5en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V74VscomolP99+3p9dvTRxR+e/rHM0Vm7Jw9H+KUpvj162/vV11kyE339mfXtL/845XSTGirxOQ6ThgA2b6VSQskZlgzUrVn+xCoSdbVAl0FhW4Afag+UyCnl2HiAPnJ2zVhqQA3xR9RTgGiVBhA3zFdmJefC55OZ4+Rb6VzBamMZtP5yLZloFhvhRbJxz8M+sAjZCxRVjGFXJhntlv3yrboGvjaIqlb81I0KJCsNyVm9j+v56aE+TxdS/wUmrQ3/JWkbn9RbvO9BAbMim8vmT/xYl7n+1KmVogU0lL/42oHZBtSyMu0etbBQZoPoEpliiIviX5QVthAccZq+J9Jvu9RSDkgyeyYHxaIvZv1LXWnbrroT5j6el8n/O3Pv9z/meWs7+xdvqerAllkPUrU5NZN8oE8aSilIdtGMaENwU0KES42Cs8ewlkF4ON8f7pVlnHBPAR0gsC/UxLwgZMyI/V3qn1rACN/ZdWEv6fDXtJ/qPy/L49/ZSPeUrmcRdD3TRW+UX9PFTnpqwGZx0L0yq0qkVtpHECgPtjjbHScsrULHJLKt1MLkZUUcK6WPpRD/v727ZPes29PbzfgSBfZPYTF/79Xd7eWs79Tb9++23L47ekt37puIxnYZV8GSjn1nBbIhric6eR0oVamnYv6TDqEamWNRGQosRgphQu/K3XJA+gDJcjY/84othb4OWeSCfDyjpvMjcQpvIEfwh/...
rawmind0 commented 3 years ago

@Jasstkn , the diff field you are attaching is not significant. It should be any other diff, due to diff on annotations containing cattle.io are supressed, https://github.com/rancher/terraform-provider-rancher2/blob/ec17aecf3d86a3482bb3c33b74ac06dad4232d09/rancher2/schema_common.go#L23

As explained in the issue you are referencing, values yaml diff are checked at low level, nos as string, so just showing "real" diffs. Could you please provide you app v2 tf definition and full diif??

Jasstkn commented 3 years ago

@Jasstkn , the diff field you are attaching is not significant. It should be any other diff, due to diff on annotations containing cattle.io are supressed,

https://github.com/rancher/terraform-provider-rancher2/blob/ec17aecf3d86a3482bb3c33b74ac06dad4232d09/rancher2/schema_common.go#L23

As explained in the issue you are referencing, values yaml diff are checked at low level, nos as string, so just showing "real" diffs. Could you please provide you app v2 tf definition and full diif??

@rawmind0 sure!

resource "rancher2_app_v2" "monitoring" {
  cluster_id = rancher2_cluster.rancher_managed_cluster.id
  name            = "rancher-monitoring"
  namespace       = "cattle-monitoring-system"
  repo_name       = "rancher-charts"
  chart_name      = "rancher-monitoring"
  chart_version   = "14.5.100"
  cleanup_on_fail = true
  values          = file("${path.cwd}/files/rancher-monitoring.yaml")
}

Full log is below log.txt

rawmind0 commented 3 years ago

@Jasstkn thanks for the update.. Are you migrating cluster monitoring from v1 to v2??

This seems the only change that the tf plan is calculating. App v2 annotation diff seems suppressed and no any diff at values argument..

...
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place

Terraform will perform the following actions:

  # module.rancher_sandbox_cluster_init.rancher2_cluster.rancher_managed_cluster will be updated in-place
  ~ resource "rancher2_cluster" "rancher_managed_cluster" {
        id                         = "c-XXXX"
        name                       = "sandbox"
        # (15 unchanged attributes hidden)

      - cluster_monitoring_input {
          - answers = {
              - "exporter-kubelets.https"                   = "true"
              - "exporter-node.enabled"                     = "true"
              - "exporter-node.ports.metrics.port"          = "9796"
              - "exporter-node.resources.limits.cpu"        = "50m"
              - "exporter-node.resources.limits.memory"     = "64Mi"
              - "grafana.persistence.enabled"               = "true"
              - "grafana.persistence.size"                  = "10Gi"
              - "grafana.persistence.storageClass"          = "default"
              - "operator.resources.limits.memory"          = "500Mi"
              - "prometheus.persistence.enabled"            = "true"
              - "prometheus.persistence.size"               = "50Gi"
              - "prometheus.persistence.storageClass"       = "default"
              - "prometheus.persistent.useReleaseName"      = "true"
              - "prometheus.resources.core.limits.cpu"      = "1000m"
              - "prometheus.resources.core.limits.memory"   = "1500Mi"
              - "prometheus.resources.core.requests.cpu"    = "750m"
              - "prometheus.resources.core.requests.memory" = "750Mi"
              - "prometheus.retention"                      = "7d"
            } -> null
        }

        # (3 unchanged blocks hidden)
    }

cluster_monitoring_input just makes effect for cluster monitoring v1. To customize v2 monitoring you should do it in that way, https://registry.terraform.io/providers/rancher/rancher2/latest/docs/guides/apps_marketplace#rancher-monitoring

Jasstkn commented 3 years ago

@rawmind0 Thank you for your answer. No, I'm not migrating. Monitoring was initially deployed like that. :( I don't understand what can trigger such output. What steps can you suggest to mitigate the issue?

rawmind0 commented 3 years ago

No, I'm not migrating. Monitoring was initially deployed like that. :( I don't understand what can trigger such output. What steps can you suggest to mitigate the issue?

You mean that the cluster was initially deployed with monitoring v1 enabled?? Once the plan is generated are you applying it??

Jasstkn commented 3 years ago

No, I'm not migrating. Monitoring was initially deployed like that. :( I don't understand what can trigger such output. What steps can you suggest to mitigate the issue?

You mean that the cluster was initially deployed with monitoring v1 enabled?? Once the plan is generated are you applying it??

Nope, I initially deployed monitoring v2 via cluster explorer view. Yes, I applied plan already few times with such output but it's still worrying me.

Jasstkn commented 3 years ago

@rawmind0 I've tried to apply the plan, it has been applied successfully. But when I run terraform plan right after apply, it still shows me this huge output :(