Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Error after upgrade from 0.4.1 to 0.5.0: failed to encode refreshed data for module as JSON #254

Open
dzhlobo opened this issue Jul 25, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@dzhlobo
Copy link

dzhlobo commented Jul 25, 2021

Terraform, Provider, Kubernetes versions

Terraform version: 1.0.1 (it seems terraform -v shows wrong data, since I use Terraform Cloud and I set terraform version to 1.0.3)
Provider version: 0.5.0
Kubernetes version: 1.21.2

Affected Resource(s)

kubernetes_manifest

Terraform Configuration Files

resource "kubernetes_manifest" "cert-issuer-letsencrypt" {
  provider = kubernetes-alpha

  manifest = {
    apiVersion = "cert-manager.io/v1"
    kind       = "Issuer"
    metadata = {
      name      = "letsencrypt"
      namespace = var.app_namespace
    }
    spec = {
      acme = {
        server = "https://acme-v02.api.letsencrypt.org/directory"
        email  = var.email
        privateKeySecretRef = {
          name = "letsencrypt-issuer-key"
        }
        solvers = [{
          http01 = {
            ingress = {
              class = "nginx"
            }
          }
        }]
      }
    }
  }
}

Debug Output

kubectl describe issuers/letsencrypt
Metadata:                                                                                               
  Creation Timestamp:  2021-04-25T00:07:52Z                                                             
  Generation:          1                                                                                
  Managed Fields:                                                                                       
    API Version:  cert-manager.io/v1                                                                    
    Fields Type:  FieldsV1                                                                              
    fieldsV1:                                                                                           
      f:spec:                                                                                           
        f:acme:                                                                                         
          f:email:                                                                                      
          f:privateKeySecretRef:                                                                        
            f:name:                                                                                     
          f:server:                                                                                     
          f:solvers:                                                                                    
    Manager:      Terraform                                                                             
    Operation:    Apply                                                                                 
    Time:         2021-04-25T00:07:52Z                                                                                                                                                                          
    API Version:  cert-manager.io/v1                                                                                                                                                                            
    Fields Type:  FieldsV1                                                                                                                                                                                      
    fieldsV1:                                                                                                                                                                                                   
      f:status:                                                                                                                                                                                                 
        .:                                                                                                                                                                                                      
        f:acme:                                                                                                                                                                                                 
          .:                                                                                                                                                                                                    
          f:lastRegisteredEmail:                                                                                                                                                                                
          f:uri:                                                                                                                                                                                                
        f:conditions:                                                                                                                                                                                           
    Manager:         controller                                                                                                                                                                                     Operation:       Update                                                                                                                                                                                         Time:            2021-04-25T00:07:53Z                                                               
  Resource Version:  42462                                                                              
  UID:               daa6a6df-73ac-4e2c-bb25-400c319d6951                                               

Panic Output

Steps to Reproduce

  1. Create Issuer CRD (cert-manager 1.4.1) with kubernetes-alpha 0.4.1
  2. Upgrade kubernetes-alpha to 0.5.0
  3. Run terraform apply

Expected Behavior

Terraform fetches fields it previously didn't know about and updates state.

Actual Behavior

Terraform doesn't see CRD's fields in Kubernetes and can't update them in the state and fails at the end of terraform apply execution:

Terraform detected the following changes made outside of Terraform since the
last "terraform apply":                                                                                 
                                                    
  # module.kubernetes.module.cluster.kubernetes_manifest.cert-issuer-letsencrypt has been changed
  ~ resource "kubernetes_manifest" "cert-issuer-letsencrypt" {                                          
      ~ object   = {                                                                                    
          ~ metadata   = {                                                                              
              - annotations                = null -> null
              - clusterName                = null -> null
              - creationTimestamp          = null -> null                                               
              - deletionGracePeriodSeconds = null -> null
              - deletionTimestamp          = null -> null                                               
              - finalizers                 = null -> null                                               
              - generateName               = null -> null
              - generation                 = null -> null                                               
              - labels                     = null -> null                    
              - managedFields              = null -> null               
              - ownerReferences            = null -> null                                               
              - resourceVersion            = null -> null
              - selfLink                   = null -> null                    
              - uid                        = null -> null
                # (2 unchanged elements hidden)                                                         
            }                                                                                                                                                                                                   
            # (3 unchanged elements hidden)                                                                                                                                                                             }                                                                                                                                                                                                               # (1 unchanged attribute hidden)                                                                
    }                                     
Failed running command "cd '/terraform' && envdir /env terraform show -json /terraform/terraform.tfplan" (exit 1)
Output: Failed to marshal plan to json: error in marshalResourceDrift: 
failed to encode refreshed data for module.kubernetes.module.cluster.kubernetes_manifest.cert-issuer-letsencrypt as JSON: 
attribute "object": attribute "metadata": 
attributes "annotations", "clusterName", "creationTimestamp", "deletionGracePeriodSeconds", "deletionTimestamp", "finalizers", "generateName", "generation", "labels", "managedFields", "ownerReferences", "resourceVersion", "selfLink", and "uid" are required

Important Factoids

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant