Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - fix(init): do not require re-init after explicit init on clean directory #2949

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaymecd
Copy link

@jaymecd jaymecd commented Feb 19, 2024

Description

Running terragrunt plan --terragrunt-no-auto-init on clean directory just after terragrunt init, raises confusing warning that init is needed.

On 1st clean init previousVersion is always empty, therefore no need to mark it as init required again and this warning is misleading.

How-to reproduce:

$ rm -rf .terragrunt-cache/

$ terragrunt init
INFO[0000] Downloading Terraform configurations from ...
Initializing the backend...
... 
Terraform has been successfully initialized!
...

$ terragrunt plan --terragrunt-no-auto-init
WARN[0000] Detected that init is needed, but Auto-Init is disabled. Continuing with further actions, but subsequent terraform commands may fail.  prefix=[/path/to/stack]
...

Workaround:

terraform {
  after_hook "cleanup_init_required_file" {
    commands = ["init"]
    execute  = ["sh", "-ec", "find . -type f -name .terragrunt-init-required -delete"]
  }
}

TODOs

Read the Gruntwork contribution guidelines.

  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Removed warning when using no-auto-init flag after explicit init on clean directory.

@denis256
Copy link
Member

Noticed failing test:

    download_source_test.go:378: 
        	Error Trace:	/home/circleci/project/cli/commands/terraform/download_source_test.go:378
        	            				/home/circleci/project/cli/commands/terraform/download_source_test.go:238
        	Error:      	Should be true
        	Test:       	TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource
--- FAIL: TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource (2.72s)

@yhakbar
Copy link
Collaborator

yhakbar commented Aug 6, 2024

Hey @jaymecd

We're still seeing errors like the following in tests:

=== NAME  TestTerragruntPrintAwsErrors
    integration_test.go:6156: 
                Error Trace:    /home/circleci/project/test/integration_test.go:6156
                Error:          An error is expected but got nil.
                Test:           TestTerragruntPrintAwsErrors
--- FAIL: TestTerragruntPrintAwsErrors (5.99s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1a6f170]

Are you able to run the tests locally?

@jaymecd
Copy link
Author

jaymecd commented Aug 8, 2024

will take a look shortly

@yhakbar
Copy link
Collaborator

yhakbar commented Aug 27, 2024

Hey @jaymecd ,

Moving this PR to WIP. Please mark ready for review when it is.

@yhakbar yhakbar marked this pull request as draft August 27, 2024 13:08
@yhakbar yhakbar changed the title fix(init): do not require re-init after explicit init on clean directory WIP - fix(init): do not require re-init after explicit init on clean directory Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants