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

feat: Refine The Atlantis VCS Logging Configuration #4285

Merged
merged 10 commits into from
Feb 26, 2024

Conversation

X-Guardian
Copy link
Contributor

what

This PR refines the Atlantis VCS logging as follows:

  • Add additional debug logging entries for all the GitHub and GitLab client functions.
  • Modify the VCS logging so that the VCS clients all use loggers inherited from the command runners rather than the VCS client.

why

  • Improve the debug logging of the GitHub and GitLab clients.
  • VCS logging entries will now be included in the --verbose output when running Atlantis commands, making VCS issue trouble shooting easier, as debug logs for a command can be produced without having to run the Atlantis server with the debug log level.

tests

Tested locally

Examples

atlantis plan --verbose

GitHub

Current Log
[DBUG] Building plan command for all affected projects
[DBUG] 1 files were modified in this pull request. Modified files: [live/aws/123456789012/develop/eu-west-2/cloudfront/main.tf]
[DBUG] got workspace lock
[DBUG] moduleInfo for /root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default (matching "") = map[]
[INFO] found no atlantis.yaml file
[INFO] filtered modified files to 1 file(s) in the autoplan file list: [live/aws/123456789012/develop/eu-west-2/cloudfront/main.tf]
[INFO] there are 1 modified project(s) at path(s): live/aws/123456789012/develop/eu-west-2/cloudfront
[INFO] automatically determined that there were 1 additional projects modified in this pull request: [repofullname=Guardian-Teck/atlantis-test path=live/aws/123456789012/develop/eu-west-2/cloudfront]
[DBUG] determining config for project at dir: "live/aws/123456789012/develop/eu-west-2/cloudfront"
[INFO] looking for Terraform Cloud workspace from configuration in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default"
[DBUG] no Terraform Cloud workspace explicitly configured in Terraform codes. Use default workspace ("default")
[DBUG] building config based on server-side config
[DBUG] setting policy_check: false from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting workflow: "default" from default server config
[DBUG] setting allowed_overrides: [] from default server config
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] setting repo_locking: true from default server config
[DBUG] setting apply_requirements: [] from default server config
[DBUG] setting allow_custom_workflows: false from default server config
[DBUG] setting custom_policy_check: false from default server config
[DBUG] Building project command context for plan
[DBUG] Found required_version setting of ">=1.3.8"
[DBUG] Listing Terraform versions available at: https://releases.hashicorp.com/terraform
[INFO] Detected module requires version: 1.7.4
[DBUG] deleting previous plans and locks
[INFO] acquired lock with id "Guardian-Teck/atlantis-test/live/aws/123456789012/develop/eu-west-2/cloudfront/default"
[DBUG] acquired lock for project
[DBUG] Deleting `/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront/.terraform.lock.hcl` that was generated by previous terraform init
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 init -input=false -upgrade" in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront"
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 plan -input=false -refresh -out \"/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront/default.tfplan\"" in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront"
[INFO] plan success. output available at: https://github.com/Guardian-Teck/atlantis-test/pull/9
[DBUG] Hiding previous plan comments for command: 'Plan', directory: ''
New Log
[DBUG] Getting GitHub pull request 9
[DBUG] GET /repos/Guardian-Teck/atlantis-test/pulls/9 returned: 200
[DBUG] Checking if GitHub pull request 9 is approved
[DBUG] GET /repos/Guardian-Teck/atlantis-test/pulls/9/reviews returned: 200
[DBUG] Checking if GitHub pull request 9 is mergeable
[DBUG] Getting GitHub pull request 9
[DBUG] GET /repos/Guardian-Teck/atlantis-test/pulls/9 returned: 200
[INFO] updating vcs status
[DBUG] Updating status on GitHub pull request 9 for 'Plan in progress...' to 'pending'
[DBUG] POST /repos/Guardian-Teck/atlantis-test/statuses/ef444e366b8cea3415e93d6a261a04b734a4b7a0 returned: 201
[DBUG] Building plan command for all affected projects
[DBUG] Getting modified files for GitHub pull request 9
[DBUG] [attempt 1] GET /repos/Guardian-Teck/atlantis-test/pulls/9/files returned: 200
[DBUG] 1 files were modified in this pull request. Modified files: [live/aws/123456789012/develop/eu-west-2/cloudfront/main.tf]
[DBUG] got workspace lock
[DBUG] moduleInfo for /root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default (matching "") = map[]
[INFO] found no atlantis.yaml file
[INFO] filtered modified files to 1 file(s) in the autoplan file list: [live/aws/123456789012/develop/eu-west-2/cloudfront/main.tf]
[INFO] there are 1 modified project(s) at path(s): live/aws/123456789012/develop/eu-west-2/cloudfront
[INFO] automatically determined that there were 1 additional projects modified in this pull request: [repofullname=Guardian-Teck/atlantis-test path=live/aws/123456789012/develop/eu-west-2/cloudfront]
[DBUG] determining config for project at dir: "live/aws/123456789012/develop/eu-west-2/cloudfront"
[INFO] looking for Terraform Cloud workspace from configuration in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default"
[DBUG] no Terraform Cloud workspace explicitly configured in Terraform codes. Use default workspace ("default")
[DBUG] building config based on server-side config
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] setting repo_locking: true from default server config
[DBUG] setting policy_check: false from default server config
[DBUG] setting apply_requirements: [] from default server config
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting workflow: "default" from default server config
[DBUG] setting allow_custom_workflows: false from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] setting allowed_overrides: [] from default server config
[DBUG] setting custom_policy_check: false from default server config
[DBUG] Building project command context for plan
[DBUG] Found required_version setting of ">=1.3.8"
[DBUG] Listing Terraform versions available at: https://releases.hashicorp.com/terraform
[INFO] Detected module requires version: 1.7.4
[DBUG] deleting previous plans and locks
[INFO] updating vcs status
[DBUG] Updating status on GitHub pull request 9 for 'Plan in progress...' to 'pending'
[DBUG] POST /repos/Guardian-Teck/atlantis-test/statuses/ef444e366b8cea3415e93d6a261a04b734a4b7a0 returned: 201
[INFO] acquired lock with id "Guardian-Teck/atlantis-test/live/aws/123456789012/develop/eu-west-2/cloudfront/default"
[DBUG] acquired lock for project
[DBUG] Deleting `/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront/.terraform.lock.hcl` that was generated by previous terraform init
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 init -input=false -upgrade" in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront"
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 plan -input=false -refresh -out \"/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront/default.tfplan\"" in "/root/.atlantis/repos/Guardian-Teck/atlantis-test/9/default/live/aws/123456789012/develop/eu-west-2/cloudfront"
[INFO] updating vcs status
[DBUG] Updating status on GitHub pull request 9 for 'Plan: 1 to add, 0 to change, 0 to destroy.' to 'success'
[DBUG] POST /repos/Guardian-Teck/atlantis-test/statuses/ef444e366b8cea3415e93d6a261a04b734a4b7a0 returned: 201
[INFO] plan success. output available at: https://github.com/Guardian-Teck/atlantis-test/pull/9
[DBUG] Hiding previous plan comments for command: 'Plan', directory: ''
[DBUG] Hiding previous command comments on GitHub pull request 9
[DBUG] GET /repos/Guardian-Teck/atlantis-test/issues/9/comments returned: 200
[DBUG] Hiding comment IC_kwDOJlX-Cc50K-IM
[DBUG] Hiding comment IC_kwDOJlX-Cc50LG59
[DBUG] Hiding comment IC_kwDOJlX-Cc50LG8W
[DBUG] Hiding comment IC_kwDOJlX-Cc50_M4i
[DBUG] Hiding comment IC_kwDOJlX-Cc50_M46
[DBUG] Hiding comment IC_kwDOJlX-Cc50_NC3

GitLab

Current Log
[DBUG] Building plan command for all affected projects
[DBUG] 1 files were modified in this pull request. Modified files: [live/aws/123456789012/develop/eu-west-2/stack11/main.tf]
[DBUG] got workspace lock
[DBUG] moduleInfo for /root/.atlantis/repos/sheather/test/31/default (matching "") = map[]
[INFO] found no atlantis.yaml file
[INFO] filtered modified files to 1 file(s) in the autoplan file list: [live/aws/123456789012/develop/eu-west-2/stack11/main.tf]
[INFO] there are 1 modified project(s) at path(s): live/aws/123456789012/develop/eu-west-2/stack11
[INFO] automatically determined that there were 1 additional projects modified in this pull request: [repofullname=sheather/test path=live/aws/123456789012/develop/eu-west-2/stack11]
[DBUG] determining config for project at dir: "live/aws/123456789012/develop/eu-west-2/stack11"
[INFO] looking for Terraform Cloud workspace from configuration in "/root/.atlantis/repos/sheather/test/31/default"
[DBUG] no Terraform Cloud workspace explicitly configured in Terraform codes. Use default workspace ("default")
[DBUG] building config based on server-side config
[DBUG] setting apply_requirements: [mergeable] from repos[1], id: /.*/
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting allow_custom_workflows: false from default server config
[DBUG] setting policy_check: false from default server config
[DBUG] setting custom_policy_check: false from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] setting workflow: "default" from default server config
[DBUG] setting allowed_overrides: [] from default server config
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] setting repo_locking: true from default server config
[DBUG] Building project command context for plan
[DBUG] Found required_version setting of ">=1.3.9"
[DBUG] Listing Terraform versions available at: https://releases.hashicorp.com/terraform
[INFO] Detected module requires version: 1.7.4
[DBUG] deleting previous plans and locks
[INFO] acquired lock with id "sheather/test/live/aws/123456789012/develop/eu-west-2/stack11/default"
[DBUG] acquired lock for project
[DBUG] Deleting `/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11/.terraform.lock.hcl` that was generated by previous terraform init
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 init -input=false -upgrade" in "/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11"
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 plan -input=false -refresh -out \"/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11/default.tfplan\"" in "/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11"
[INFO] plan success. output available at: https://gitlab.lan/sheather/test/-/merge_requests/31
[DBUG] Hiding previous plan comments for command: 'Plan', directory: ''

New Log
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Checking if GitLab merge request 31 is approved
[DBUG] GET /projects/sheather/test/merge_requests/31/approvals returned: 200
[DBUG] Checking if GitLab merge request 31 is mergeable
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] GET /projects/2 returned: 200
[DBUG] GET /projects/2/commits/91a7ea6756cee6e9e62ab72665556c363bbf9af7/statuses returned: 200
[DBUG] Checking if GitLab supports detailed merge status
[DBUG] Getting GitLab version
[DBUG] GET /version returned: 200
[DBUG] Updating GitLab commit status for 'atlantis/plan' to 'pending'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[DBUG] Building plan command for all affected projects
[DBUG] Getting modified files for GitLab merge request 31
[DBUG] GET projects/sheather%2Ftest/merge_requests/31/changes returned: 200
[DBUG] 1 files were modified in this pull request. Modified files: [live/aws/123456789012/develop/eu-west-2/stack11/main.tf]
[DBUG] got workspace lock
[DBUG] moduleInfo for /root/.atlantis/repos/sheather/test/31/default (matching "") = map[]
[INFO] found no atlantis.yaml file
[INFO] filtered modified files to 1 file(s) in the autoplan file list: [live/aws/123456789012/develop/eu-west-2/stack11/main.tf]
[INFO] there are 1 modified project(s) at path(s): live/aws/123456789012/develop/eu-west-2/stack11
[INFO] automatically determined that there were 1 additional projects modified in this pull request: [repofullname=sheather/test path=live/aws/123456789012/develop/eu-west-2/stack11]
[DBUG] determining config for project at dir: "live/aws/123456789012/develop/eu-west-2/stack11"
[INFO] looking for Terraform Cloud workspace from configuration in "/root/.atlantis/repos/sheather/test/31/default"
[DBUG] no Terraform Cloud workspace explicitly configured in Terraform codes. Use default workspace ("default")
[DBUG] building config based on server-side config
[DBUG] setting workflow: "default" from default server config
[DBUG] setting allowed_overrides: [] from default server config
[DBUG] setting allow_custom_workflows: false from default server config
[DBUG] setting policy_check: false from default server config
[DBUG] setting custom_policy_check: false from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] setting apply_requirements: [mergeable] from repos[1], id: /.*/
[DBUG] setting repo_locking: true from default server config
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] Building project command context for plan
[DBUG] Found required_version setting of ">=1.3.9"
[DBUG] Listing Terraform versions available at: https://releases.hashicorp.com/terraform
[INFO] Detected module requires version: 1.7.4
[DBUG] deleting previous plans and locks
[DBUG] Updating GitLab commit status for 'atlantis/plan: live/aws/123456789012/develop/eu-west-2/stack11/default' to 'pending'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[INFO] acquired lock with id "sheather/test/live/aws/123456789012/develop/eu-west-2/stack11/default"
[DBUG] acquired lock for project
[DBUG] Deleting `/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11/.terraform.lock.hcl` that was generated by previous terraform init
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 init -input=false -upgrade" in "/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11"
[DBUG] starting "/root/.atlantis/bin/terraform1.7.4 plan -input=false -refresh -out \"/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11/default.tfplan\"" in "/root/.atlantis/repos/sheather/test/31/default/live/aws/123456789012/develop/eu-west-2/stack11"
[DBUG] Updating GitLab commit status for 'atlantis/plan: live/aws/123456789012/develop/eu-west-2/stack11/default' to 'success'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[INFO] plan success. output available at: https://gitlab.lan/sheather/test/-/merge_requests/31
[DBUG] Hiding previous plan comments for command: 'Plan', directory: ''
[DBUG] Hiding previous command comments on GitLab merge request 31
[DBUG] /projects/sheather/test/merge_requests/31/notes
[DBUG] GET /projects/sheather/test/merge_requests/31/notes returned: 200
[DBUG] Updating merge request note: Repo: 'sheather/test', MR: '31', comment ID: '710'
[DBUG] PUT /projects/sheather/test/merge_requests/31/notes/710 returned: 200

@GenPage GenPage mentioned this pull request Feb 26, 2024
@GenPage GenPage added this to the v0.28.0 milestone Feb 26, 2024
@GenPage GenPage added feature New functionality/enhancement quick-win Is obviously something Atlantis should do and will take <4 hrs work labels Feb 26, 2024
@GenPage GenPage self-assigned this Feb 26, 2024
@GenPage GenPage merged commit 67b5740 into runatlantis:main Feb 26, 2024
24 checks passed
@X-Guardian X-Guardian deleted the vcs-logging-refinement branch February 26, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement go Pull requests that update Go code provider/azuredevops provider/bitbucket provider/github provider/gitlab quick-win Is obviously something Atlantis should do and will take <4 hrs work
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants