jenkins-infra / helpdesk

Open your Infrastructure related issues here for the Jenkins project
https://github.com/jenkins-infra/helpdesk/issues/new/choose
17 stars 10 forks source link

[Terraform Projects] Bump to Terraform 1.9.x #4164

Closed dduportal closed 3 months ago

dduportal commented 3 months ago

Service(s)

AWS, Azure, Datadog, DigitalOcean, Update center, Other

Summary

We are using the 1.6.x line of Terraform today: https://github.com/jenkins-infra/packer-images/blob/d7c995afe5e637226d24362a673260ba8d76a03b/provisioning/tools-versions.yml#L45

This issue is to track the work associated to upgrading to Terraform 1.9.x:

Reproduction steps

No response

dduportal commented 3 months ago

Update:

dduportal commented 3 months ago

Update:

11:01:31  Terraform has been successfully initialized!
11:01:31  Starting common-tests...
11:04:10  make: *** [Makefile:27: common-tests] Error 1
11:04:10  make: Leaving directory '/home/jenkins/agent/workspace/terraform-jobs_azure_main/.shared-tools/terraform'

=> Gotta check to understand what is wrong. Could be due to Terraform 1.9.1 or a mistake in https://github.com/jenkins-infra/helpdesk/issues/4166. First step would be to reproduce the error locally, check the line 27 of the Makefile and eventually reproduce with the terratest golang execution. If no progress, we can disable the test (as it is a flaky one if changing Terraform make it fail).

dduportal commented 3 months ago

Update:

* All projects are now running with Terraform 1.9.1 with success for the "Plan" and "Ship" stages => we can safely operate the infrastructure

* One last thing: the tests for the Azure project (and only this project) are now failing with the following (unclear) error:
11:01:31  Terraform has been successfully initialized!
11:01:31  Starting common-tests...
11:04:10  make: *** [Makefile:27: common-tests] Error 1
11:04:10  make: Leaving directory '/home/jenkins/agent/workspace/terraform-jobs_azure_main/.shared-tools/terraform'

=> Gotta check to understand what is wrong. Could be due to Terraform 1.9.1 or a mistake in #4166. First step would be to reproduce the error locally, check the line 27 of the Makefile and eventually reproduce with the terratest golang execution. If no progress, we can disable the test (as it is a flaky one if changing Terraform make it fail).

Retrieved the test logs (file ./common-tests.logs) and got the following error from it:

plan.go:17: 
                Error Trace:    plan.go:17
                                                        terraform_main_test.go:49
                Error:          Received unexpected error:
                                FatalError{Underlying: error while running command: exit status 1; β•·
                                β”‚ Error: Invalid provider configuration
                                β”‚ 
                                β”‚ Provider "registry.terraform.io/hashicorp/azuread" requires explicit
                                β”‚ configuration. Add a provider block to the root module and configure the
                                β”‚ provider's required arguments as described in the provider documentation.
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azuread"],
                                β”‚   on <empty> line 0:
                                β”‚   (source code not available)
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azurerm"],
                                β”‚   on providers.tf line 2, in provider "azurerm":
                                β”‚    2: provider "azurerm" {
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azurerm"].jenkins-sponsorship,
                                β”‚   on providers.tf line 7, in provider "azurerm":
                                β”‚    7: provider "azurerm" {
                                β”‚ 
                                β•΅}
                Test:           TestTerraformCluster

It's weird because azure-net does not fail with these errors πŸ€”

dduportal commented 3 months ago

Update:

* All projects are now running with Terraform 1.9.1 with success for the "Plan" and "Ship" stages => we can safely operate the infrastructure

* One last thing: the tests for the Azure project (and only this project) are now failing with the following (unclear) error:
11:01:31  Terraform has been successfully initialized!
11:01:31  Starting common-tests...
11:04:10  make: *** [Makefile:27: common-tests] Error 1
11:04:10  make: Leaving directory '/home/jenkins/agent/workspace/terraform-jobs_azure_main/.shared-tools/terraform'

=> Gotta check to understand what is wrong. Could be due to Terraform 1.9.1 or a mistake in #4166. First step would be to reproduce the error locally, check the line 27 of the Makefile and eventually reproduce with the terratest golang execution. If no progress, we can disable the test (as it is a flaky one if changing Terraform make it fail).

Retrieved the test logs (file ./common-tests.logs) and got the following error from it:

plan.go:17: 
                Error Trace:    plan.go:17
                                                        terraform_main_test.go:49
                Error:          Received unexpected error:
                                FatalError{Underlying: error while running command: exit status 1; β•·
                                β”‚ Error: Invalid provider configuration
                                β”‚ 
                                β”‚ Provider "registry.terraform.io/hashicorp/azuread" requires explicit
                                β”‚ configuration. Add a provider block to the root module and configure the
                                β”‚ provider's required arguments as described in the provider documentation.
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azuread"],
                                β”‚   on <empty> line 0:
                                β”‚   (source code not available)
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azurerm"],
                                β”‚   on providers.tf line 2, in provider "azurerm":
                                β”‚    2: provider "azurerm" {
                                β”‚ 
                                β•΅
                                β•·
                                β”‚ Error: unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: obtaining subscription ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
                                β”‚ 
                                β”‚   with provider["registry.terraform.io/hashicorp/azurerm"].jenkins-sponsorship,
                                β”‚   on providers.tf line 7, in provider "azurerm":
                                β”‚    7: provider "azurerm" {
                                β”‚ 
                                β•΅}
                Test:           TestTerraformCluster

It's weird because azure-net does not fail with these errors πŸ€”

Found the issue! It was a mistake I made when updating the SOPS credentials as part of https://github.com/jenkins-infra/helpdesk/issues/4166:

Capture d’écran 2024-07-15 aΜ€ 15 23 37

As you can see, 2 fields of the Azure SP credential are empty in infra.ci.jenkins.io which explains the error.

dduportal commented 3 months ago

Terraform 1.9.1 is now used!