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.31k stars 9.49k forks source link

Terraform cloud fails to upload when there is a symlink leading to a non-existing directory #28109

Closed AndrewDryga closed 3 years ago

AndrewDryga commented 3 years ago

Terraform Version

Terraform v0.14.8

Problem statement

We are trying to migrate to Terraform Cloud and faced a bug that won't let us proceed. Our repository is setup so that it has terraform configuration for multiple environments (in rel/deployment/terraform/{env_name}) so we needed to set a working directory in Terraform Cloud, but artifact upload never finishes:

Skipping excluded path: _build/test/lib/dealerships_catalog_web/.mix/compile.elixir_scm
Skipping excluded path: _build/test/lib/dealerships_catalog_web/.mix/compile.lock

Error: Failed to upload configuration files: Failed to get symbolic link destination for "/Users/andrew/Projects/hammer/mono/_build/test/lib/dealerships_catalog_web/priv": lstat /Users/andrew/Projects/hammer/mono/apps/dealerships_catalog_web/priv: no such file or directory

The configured "remote" backend encountered an unexpected error. Sometimes
this is caused by network connection problems, in which case you could retry
the command. If the issue persists please open a support ticket to get help
resolving the problem.

This is because symlink is created for a non-existing directory:

$ ls -la "/Users/andrew/Projects/hammer/mono/_build/test/lib/dealerships_catalog_web/priv"
lrwxr-xr-x  1 andrew  staff  45 Feb 11 14:16 /Users/andrew/Projects/hammer/mono/_build/test/lib/dealerships_catalog_web/priv -> ../../../../apps/dealerships_catalog_web/priv

$  ls -la /Users/andrew/Projects/hammer/mono/apps/dealerships_catalog_web/priv                                                                                 
ls: /Users/andrew/Projects/hammer/mono/apps/dealerships_catalog_web/priv: No such file or directory

You can also notice that _build is actually ignored but the evaluation is still trying to copy those symlinks 🤷‍♂️:

# Applications
apps
legacy_apps
python-apps
config
test

# Elixir directories
_build
deps

# All dot-directories
.*/

# Ignore crash logs generated by some OTP application
log/
erl_crash.dump
pselle commented 3 years ago

Hi @AndrewDryga!

We use issues in this repository to represent bugs and feature requests in Terraform CLI. Terraform Cloud is developed by other teams who don't typically monitor this repository, and they prefer to hear about bug reports and feature requests via the customer support system.

If you have a paid account on Terraform Cloud, please send this feedback to your usual support contacts. Otherwise, you can contact the Terraform Cloud support team at tf-cloud-support@hashicorp.com. If you contact the support team, be sure to include your Terraform Cloud username and organization name in your request.

Thanks again!

AndrewDryga commented 3 years ago

@pselle isn't the Terraform CLI is the tool responsible for packing up the archive which is sent to remote provider? It doesn't matter if it's Terraform Cloud or anything else, Terraform CLI should not crash when it finds a symlink to a non-existing directory (especially at ignored location).

pselle commented 3 years ago

No, that's not work done by this codebase. https://github.com/hashicorp/go-slug is a possible culprit, which is then used by https://github.com/hashicorp/go-tfe. Either way, it's related to interactions with Terraform Cloud in such a way where reaching out through support is the best way for you to get assistance here.

pselle commented 3 years ago

Actually, let me add some additional info -- the file you have here is .terraformignore I expect? A reminder that you might want to reference the docs on .gitignore files, upon which .terraformignore is based, as _build by itself might not be excluding the directory, but _build/. No guarantees on this, but perhaps it'll help you find your solution. For similar question-asking, I suggest checking out our community forums.

AndrewDryga commented 3 years ago

It does exclude the path, from first post in this PR:

Skipping excluded path: _build/test/lib/dealerships_catalog_web/.mix/compile.elixir_scm

ghost commented 3 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.