hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.45k stars 9.51k forks source link

Terraform Registry parsed v0.11-oriented module using new HCL parser #18384

Closed apparentlymart closed 6 years ago

apparentlymart commented 6 years ago

Over in hashicorp/hcl2#35, @bhushan-rane reported getting an import error from the public module registry that included an error message produced by the new HCL parser.

This module (version v1.1.0) is targeting current Terraform versions, and includes some constructs that will no longer be valid in the next major release. However, the registry should've been able to parse this successfully using the old (that is, current) parser.

I ran the parsing code that the registry uses (the library code directly, excluding any code in the registry application itself) and got a successful result, indicating that it used the correct parser:

Module modules/distributed_topology

Provider Requirements:

  • libvirt: (any version)
  • null: (any version)

Input Variables

  • boot_img_path (default "/work/images/newimages/ubuntu_boot"): Ubuntu Image Path for boot node
  • default_worker (default "1"): Number of worker nodes one want to add while installation IBM Cloud Private-CE 2.1.0
  • extra_worker (default "1"): Number of extra worker nodes one want to add After installation IBM Cloud Private-CE 2.1.0
  • master_img_path (default "/work/images/newimages/ubuntu_master"): Ubuntu Image Path for master node
  • mng_img_path (default "/work/images/newimages/ubuntu_mng"): Ubuntu Image Path for management node
  • proxy_img_path (default "/work/images/newimages/ubuntu_proxy"): Ubuntu Image Path for proxy node
  • ssh_private_key_path (default "/root/.ssh/id_rsa"): SSH private key path
  • worker_img_path (default "/work/images/newimages/ubuntu_worker"): Ubuntu Image Path for worker node

Output Values

  • boot-ip: Boot node IP:
  • master-ip: Master node IP...
  • mng-ip: Mangement Node IP:
  • proxy-ip: Proxy node IP...

Managed Resources

  • libvirt_cloudinit.boot from libvirt
  • libvirt_cloudinit.exworker from libvirt
  • libvirt_cloudinit.master from libvirt
  • libvirt_cloudinit.mng from libvirt
  • libvirt_cloudinit.proxy from libvirt
  • libvirt_cloudinit.worker from libvirt
  • libvirt_domain.ExICPworker from libvirt
  • libvirt_domain.ICP_boot from libvirt
  • libvirt_domain.ICP_master from libvirt
  • libvirt_domain.ICP_mng from libvirt
  • libvirt_domain.ICP_proxy from libvirt
  • libvirt_domain.ICP_worker from libvirt
  • libvirt_volume.ICP from libvirt
  • libvirt_volume.exvolume from libvirt
  • libvirt_volume.ubuntu_boot from libvirt
  • libvirt_volume.ubuntu_management from libvirt
  • libvirt_volume.ubuntu_master from libvirt
  • libvirt_volume.ubuntu_proxy from libvirt
  • libvirt_volume.volume from libvirt
  • null_resource.ExICPworker from null

It would seem, then, that something else went wrong in the registry application code that caused it to fail to parse using the "HCL1" parser and thus fall back on returning the errors from the "HCL2" parse. This is confusing, because the automatic dual version handling is handled within the library I ran here, and not within the registry itself.

apparentlymart commented 6 years ago

Looking at this again today with fresh eyes, I see my mistake: I somehow concluded that it was v1.1.0 of the module that was getting that error, but looking again at the screenshot I see it was v1.0.0.

And indeed one of the differences between v1.0.0 and v1.1.0 is a change that would make this parse successfully in the old parser, so it was my choice of the wrong version that caused me to not be able to reproduce here.

For future reference: the behavior of the registry at the time of writing is to attempt parsing both both with the old and new versions of HCL. If both fail, then it prefers to return the error from the new version, which is what was shown in the screenshot here. If either one succeeds then the new version takes priority over the old. Since the registry only cares about top-level metadata, the result of both parsers should be the same if they both succeed.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.