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

Writing assets to disk sometimes produces bad Terraform code #40

Closed
invidian opened this issue Feb 24, 2020 · 5 comments · Fixed by #56
Closed

Writing assets to disk sometimes produces bad Terraform code #40

invidian opened this issue Feb 24, 2020 · 5 comments · Fixed by #56
Labels
bug Something isn't working
Milestone

Comments

@invidian
Copy link
Member

I'm not sure if this is only the issue when doing local development or also with standalone binaries, but I sometimes get some corrupted lines in assets files. Example:

$ cat lokomotive-assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/bootkube.tf 
module "bootkube" {
  source       = "../../../bootkube"
  cluster_name = var.cluster_name

  # Cannot use cyclic dependencies on controllers or their DNS records
  api_servers          = [local.api_fqdn]
  api_servers_external = [local.api_external_fqdn]
  etcd_servers         = local.etcd_fqdn
  asset_dir            = var.asset_dir
  networking           = var.networking
  network_mtu          = var.network_mtu

  # Select private Packet NIC by using the can-reach Calico autodetection option with the first
  # host in our private CIDR.
  network_ip_autodetection_method = "can-reach=${cidrhost(var.node_private_cidr, 1)}"

  pod_cidr              = var.pod_cidr
  service_cidr          = var.service_cidr
  cluster_domain_suffix = var.cluster_domain_suffix
  enable_reporting      = var.enable_reporting
  enable_aggregation    = var.enable_aggregation

  certs_validity_period_hours = var.certs_validity_period_hours

  container_arch = var.os_arch
}
 expose_on_all_ports = true
}
@invidian invidian added the bug Something isn't working label Feb 24, 2020
@iaguis iaguis added this to the 0.1.0 milestone Feb 24, 2020
@invidian
Copy link
Member Author

From generated_assets.go, the asset itself look OK:

$ echo -e "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x92\xcf\x6e\x1a\x31\x10\xc6\xef\xfb\x14\x9f\x68\x0f\xad\xd4\x52\xf5\x01\x38\x91\x4b\x2e\x51\xd5\x1c\xab\xca\x32\xf6\xc0\x5a\x18\xcf\x76\x3c\xde\x80\xa2\xbc\x7b\xe5\xdd\xb0\x2c\xa0\x58\x48\x68\xfd\xfd\xe6\x9b\x3f\x9e\x03\xfb\x12\x09\x8b\x0d\xb3\xee\xcb\x86\x16\x78\x6d\x80\xcc\x45\x1c\x61\x3c\x2b\x2c\x96\xcb\x1f\xe3\x6f\xc2\x1a\xc0\xc5\x92\x95\xc4\x24\x7b\x20\xac\xd0\x5b\x59\xce\xaf\x9a\x06\xf8\x84\xb5\x4d\x89\x15\x25\x13\xdc\xc9\xc5\xe0\xe0\xa9\xa3\xe4\x29\xb9\x40\x19\x9c\xe0\x38\xa9\x70\x8c\x24\x19\x2c\xd0\x96\x82\xe0\xe1\xe9\x19\x42\x8e\xc5\xe7\x06\xb0\x5d\x30\x99\xa4\xaf\xc8\x74\x56\xf8\x13\xd9\xd9\xb8\xac\xea\xf6\x9f\x4f\x7f\xaf\x49\x43\x47\x25\x49\x36\x5e\x93\xe7\xdb\x29\x84\xd4\xf9\x3b\xf7\x15\xc6\x88\x41\xac\x64\xf5\xce\x99\xd4\xf8\x20\xc0\xbc\x8a\xda\xf7\x24\x35\x40\x22\x7d\x61\xd9\x87\xb4\xbb\xc3\x2e\xd2\x85\x33\x07\x2d\x1f\x70\x55\x1a\xa7\xf8\x4c\x91\x9c\xa2\x93\xd0\x5b\x25\xfc\xb2\x6e\x4f\x8a\xa7\xc7\x35\x36\x27\x94\x5c\x73\x69\x4b\x70\x36\x7d\x17\xb2\xae\xc5\xda\xc6\xe0\x18\xb6\x28\x7b\x52\x72\x1a\x38\x81\xbb\xe1\xef\x25\x68\x3b\xe0\xdb\x20\x59\x07\xff\x96\xb3\x22\x24\x70\x91\x29\xc9\xfa\xf1\xe1\xf7\x72\x56\x67\xe8\xcc\x95\x9d\x39\x90\xb6\xec\xeb\x7a\x4c\x79\x57\x9f\x5f\x5d\xf0\x52\xed\xbe\x0c\x8d\xb0\x27\xf3\x6e\x68\xaa\xf2\x0d\x3f\xbf\xbe\x2d\x6a\x53\x1d\xfb\xe1\x06\xb8\x1f\xe7\x59\xab\x9b\x48\xd2\x07\x47\x37\xe8\x88\xcd\xb5\xd9\x3e\x7a\x3e\xd8\x90\x4c\x2e\xdb\x6d\x38\xde\x2c\xe6\x95\x56\x1f\x3f\xd9\x4d\x24\x23\xd4\xb1\xe8\xf4\x64\x63\xcc\xad\x76\xc1\xed\x6e\x27\xb4\xb3\xc3\x34\x6f\xf1\x99\x56\xdb\x74\x24\x9a\x4d\x6f\x63\xf0\x41\x4f\xa6\x23\x09\xec\x4d\xcb\x45\xf2\xb9\xb4\x8f\x89\xc1\x80\x93\xda\x90\x48\x8c\x15\xd7\xbe\xc7\x70\x1e\xbe\xaa\x4e\xc7\x8e\x33\x19\x4e\xc6\xc6\x68\x6a\xa9\xd5\x58\xa5\x50\xf3\xd6\xfc\x0f\x00\x00\xff\xff\x8c\x2a\x2a\xcd\xde\x03\x00\x00" | gunzip
module "bootkube" {
  source       = "../../../bootkube"
  cluster_name = var.cluster_name

  # Cannot use cyclic dependencies on controllers or their DNS records
  api_servers          = [local.api_fqdn]
  api_servers_external = [local.api_external_fqdn]
  etcd_servers         = local.etcd_fqdn
  asset_dir            = var.asset_dir
  networking           = var.networking
  network_mtu          = var.network_mtu

  # Select private Packet NIC by using the can-reach Calico autodetection option with the first
  # host in our private CIDR.
  network_ip_autodetection_method = "can-reach=${cidrhost(var.node_private_cidr, 1)}"

  pod_cidr              = var.pod_cidr
  service_cidr          = var.service_cidr
  cluster_domain_suffix = var.cluster_domain_suffix
  enable_reporting      = var.enable_reporting
  enable_aggregation    = var.enable_aggregation

  certs_validity_period_hours = var.certs_validity_period_hours

  container_arch = var.os_arch

  expose_on_all_ports = true
}

gzip: stdin: unexpected end of file

@iaguis
Copy link
Contributor

iaguis commented Feb 24, 2020

This happened to me while testing #32 on the kube-apiserver template YAML:

      volumes:
      - name: secrets
        secret:
          secretName: kube-apiserver
      - name: ssl-certs-host
        hostPath:
          path: {{ .Values.apiserver.trustedCertsDir }}
      - name: data
        emptyDir: {}
 - name: port
        emptyDir: {}
      - name: haproxy
        emptyDir: {}

@invidian
Copy link
Member Author

I'm pretty sure I found the source of this behavior: https://gist.github.com/invidian/0aabe5170e7d3a58a643ae1abf59fc18. Will submit PR soon.

invidian added a commit that referenced this issue Feb 26, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
invidian added a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
iaguis pushed a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
iaguis pushed a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
iaguis pushed a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
iaguis pushed a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@mauriciovasquezbernal
Copy link
Member

^^^ It's an example of why it is a bad idea to reference an issue on a commit message.

iaguis pushed a commit that referenced this issue Feb 27, 2020
To avoid leaving old content untouched when updating files, which may
happen if new content is smaller than the old one.

Closes #40

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@invidian
Copy link
Member Author

^^^ It's an example of why it is a bad idea to reference an issue on a commit message.

Why exactly?

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

Successfully merging a pull request may close this issue.

3 participants