Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

huangapple go评论115阅读模式
英文:

Terraform Databricks plan failed to install provider databrickslabs/databricks - checksum list has no SHA-256 hash for provider

问题

我使用Terraform来创建一个Databricks作业。当我使用提供者databrickslabs/databricks版本0.6.2时,作业成功创建。因为我需要使用数据源"databricks_job",所以我决定将这个提供者升级到版本1.5.0,这是databricks job数据源上最新的版本。但是,一旦我将版本从0.6.2升级到1.5.0,我就会收到以下错误消息。 我尝试使用1.4.0,但错误仍然相同:

错误:无法安装提供者

安装databrickslabs/databricks v1.5.0时出错:checksum列表中没有SHA-256哈希值

"https://github.com/databricks/terraform-provider-databricks/releases/download/v1.5.0/terraform-provider-databricks_1.5.0_linux_amd64.zip"

设置:

  • 我使用Azure DevOps管道来运行我的Terraform代码。
  • 我使用Azure虚拟机规模集,其操作系统为Ubuntu Linux,作为自托管代理来实现基础架构(可能与使用databrickslabs版本0.6.2的相同代理池无关)。
  • DevOps管道在docker容器中运行Terraform代码,基础镜像为python:3.10-slim,已安装了Terraform版本1.3.9
  • Terraform init、plan和apply是通过脚本在DevOps管道中运行的。您可以稍后在此处找到脚本来源。
  • Terraform代码结构如下所示:

Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

  • 我将Terraform状态保存在Azure存储帐户中的容器中。这在dev文件夹下的init.tfvars中设置。

init.tfvars如下所示:

use_msi              = false
subscription_id      = "<Azure订阅ID>"
resource_group_name  = "<Azure资源组名称>"
storage_account_name = "<Azure存储帐户名称>"
container_name       = "tfstates"
key                  = "databricks-job.tfstate"

versions.tf的代码如下所示:

terraform {
  required_version = ">= 1.3.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.44.1"
    }
    databricks = {
      source  = "databrickslabs/databricks"
      version = "1.5.0" ## 0.6.2版本可用
    }
  }
}

DevOps阶段Terraform init和plan如下所示:

stages:
- stage: ${{parameters.stageName}}
  displayName: 'Plan Terraform Create Databricks Job'
  dependsOn: ${{parameters.dependsOn}}
  variables:
  - group: ${{parameters.variableGroup}}
  - name: artifactPath
    value: $(Build.BuildId)-prod-terraform
  - name: artifactName
    value: $(Build.BuildId)_prod_plan.tfplan
  jobs:
  - job: create_datbaricks_job_by_tf
    container: ${{parameters.containerName}}
    steps:
    - checkout: self
    - script: |
        pwd
      displayName: Working Directory
    - script: |
        ls
      displayName: folder structure
    - script: |
        export AZDO_PERSONAL_ACCESS_TOKEN=$(System.AccessToken)
        export AZDO_ORG_SERVICE_URL="https://dev.azure.com/MYORGANIZATION/"
        echo https://token:$(System.AccessToken)@dev.azure.com/MYORGANIZATION/MYPROJECT/ > ~/.git-credentials
        git config --global credential.helper 'store --file ~/.git-credentials'
        chmod 600 ~/.git-credentials
        terraform --version
        echo "Present working directory " 
        pwd
        echo "backend-config path:"
        echo "./tfvars/${{parameters.environment}}/init.tfvars"
        echo "################"
        cd deployment-pipelines/tf && terraform init --backend-config="./tfvars/${{parameters.environment}}/init.tfvars"
        echo "terraform providers"
        # terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64 
        terraform providers
        echo "terraform validate"
        terraform validate
        mkdir $(artifactPath)
        terraform plan -input=false -out="$(artifactPath)/$(artifactName)" -var-file="./tfvars/${{parameters.environment}}/terraform.tfvars"
      displayName: 'Terraform Init, Validate, Plan'
      env:
        ARM_CLIENT_ID: <Service principal应用程序ID>
        ARM_CLIENT_SECRET: <Service principal密钥> 
        ARM_SUBSCRIPTION_ID: <Azure订阅ID> 
        ARM_TENANT_ID: <Azure租户ID>
    - script: cat deployment-pipelines/tf/$(artifactPath)/$(artifactName) 
      displayName: Read tfplan
- publish: deployment-pipelines/tf/$(artifactPath)/$(artifactName)
  displayName: 'Publish Terraform plan file'
  artifact: $(artifactName)

如果您想知道main.tf中有什么,它如下所示:

resource "databricks_job" "sample-tf-job" {
  name = var.job_name
  task{
    task_key = "a"
    existing_cluster_id = "<databricks-cluster>"
    python_wheel_task {
      package_name = "myWheelOackage"
      entry_point = "__init__.py"
    }
    library {
      whl = "dbfs:/tmp/myWheel-1.0.0-py3-none-any.whl"
    } 
  }
}

正如我所提到的,当将1.5.0版本替换为0.6.2时,这段代码可以正常工作。

这里您可以看到成功运行的示例:

Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

当将databricks版本更改为1.5.0时,此管道中出现的错误如下:
Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

我尝试过但未成功的解决方案:

  1. 我将"databrickslabs/databricks"版本降级到1.4.0,仍然出现相同的错误。
    2
英文:

I am using terraform to create a databricks job. The job has been created successfully when I use the provider databrickslabs/databricks version 0.6.2. Because I need to use data source "databricks_job", I decided to upgrade this provider to version 1.5.0, which is the latest version available at databricks job data source. As soon as I upgrade the version from 0.6.2 to 1.5.0 I get the following error. I tried using 1.4.0 but the error stays the same:

> Error: Failed to install provider

> Error while installing databrickslabs/databricks v1.5.0: checksum list has
no SHA-256 hash for
"https://github.com/databricks/terraform-provider-databricks/releases/download/v1.5.0/terraform-provider-databricks_1.5.0_linux_amd64.zip"

Setup:

  • I am using Azure DevOps pipelines to run my terraform code.
  • I am using an Azure virtual machine scale set with ubuntu linux os as a self-hosted agent to implement the infrastructure. (May be irrelevant as the same agent pool works properly with databrickslabs version 0.6.2)
  • The DevOps pipeline is executing the terraform code in a docker container with base image python:3.10-slim which has terraform version 1.3.9 installed.
  • Terraform init, plan and apply run from within DevOps pipeline by using scripts. You can find the script source later here.
  • The terraform code structure is as follows:

Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

  • I am saving the terraform state into a container in an Azure Storage account. This is set in init.tfvars under dev folder.

The init.tfvars is as follows:

use_msi              = false
subscription_id      = &quot;&lt;azure subscription id&gt;&quot;
resource_group_name  = &quot;&lt;name of azure resource group&gt;&quot; 
storage_account_name = &quot;&lt;name of my azure storage account&gt;&quot;
container_name       = &quot;tfstates&quot;
key                  = &quot;databricks-job.tfstate&quot;

The code for versions.tf is as follows:

terraform {
  required_version = &quot;&gt;= 1.3.0&quot;
  required_providers {
    azurerm = {
      source  = &quot;hashicorp/azurerm&quot;
      version = &quot;=3.44.1&quot;
    }
    databricks = {
      source  = &quot;databrickslabs/databricks&quot;
      version = &quot;1.5.0&quot; ## works for 0.6.2
    }
  }
}

The DevOps stage to terraform init and plan is as follows:

stages:
- stage: ${{parameters.stageName}}
  displayName: &#39;Plan Terraform Create Databricks Job&#39;
  dependsOn: ${{parameters.dependsOn}}
  variables:
  - group: ${{parameters.variableGroup}}
  - name: artifactPath
    value: $(Build.BuildId)-prod-terraform
  - name: artifactName
    value: $(Build.BuildId)_prod_plan.tfplan
  jobs:
  - job: create_datbaricks_job_by_tf
    container: ${{parameters.containerName}}
    steps:
    - checkout: self
    - script: |
        pwd
      displayName: Working Directory
    - script: |
        ls
      displayName: folder structure
    - script: |
        export AZDO_PERSONAL_ACCESS_TOKEN=$(System.AccessToken)
        export AZDO_ORG_SERVICE_URL=&quot;https://dev.azure.com/MYORGANIZATION/&quot;
        echo https://token:$(System.AccessToken)@dev.azure.com/MYORGANIZATION/MYPROJECT/ &gt; ~/.git-credentials
        git config --global credential.helper &#39;store --file ~/.git-credentials&#39;
        chmod 600 ~/.git-credentials
        terraform --version
        echo &quot;Present working directory &quot; 
        pwd
        echo &quot;backend-config path:&quot;
        echo &quot;./tfvars/${{parameters.environment}}/init.tfvars&quot;
        echo &quot;################&quot;
        cd deployment-pipelines/tf &amp;&amp; terraform init --backend-config=&quot;./tfvars/${{parameters.environment}}/init.tfvars&quot;
        echo &quot;terraform providers&quot;
        # terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64 
        terraform providers
        echo &quot;terraform validate&quot;
        terraform validate
        mkdir $(artifactPath)
        terraform plan -input=false -out=&quot;$(artifactPath)/$(artifactName)&quot; -var-file=&quot;./tfvars/${{parameters.environment}}/terraform.tfvars&quot;
      displayName: &#39;Terraform Init, Validate, Plan&#39;
      env:
        ARM_CLIENT_ID: &lt;Service principal application id&gt;
        ARM_CLIENT_SECRET: &lt;Service principal secret &gt; 
        ARM_SUBSCRIPTION_ID: &lt;Azure subscription id&gt; 
        ARM_TENANT_ID: &lt;Azure tenant id&gt;
    - script: cat deployment-pipelines/tf/$(artifactPath)/$(artifactName) 
      displayName: Read tfplan
- publish: deployment-pipelines/tf/$(artifactPath)/$(artifactName)
  displayName: &#39;Publish Terraform plan file&#39;
  artifact: $(artifactName)

Just in case you want to know what is in main.tf, it is as follows:

resource &quot;databricks_job&quot; &quot;sample-tf-job&quot; {
  name = var.job_name
  task{
    task_key = &quot;a&quot;
    existing_cluster_id = &quot;&lt;databricks-cluster&gt;&quot;
    python_wheel_task {
      package_name = &quot;myWheelOackage&quot;
      entry_point = &quot;__init__.py&quot;
    }
    library {
      whl = &quot;dbfs:/tmp/myWheel-1.0.0-py3-none-any.whl&quot;
    } 
  }
}

As I mentioned this code works well when 1.5.0 is replaced with 0.6.2.

Here you can see the successful run:

Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

Here is the error in the pipeline when databricks version is changed to 1.5.0:
Terraform Databricks plan failed to install provider databrickslabs/databricks – checksum list has no SHA-256 hash for provider

Solutions I tried but didn't work:

  1. I downgraded the "databrickslabs/databricks" version to 1.4.0, still same error.

  2. I deleted the terraform state file in Azure Storage container, but still same error.

  3. I used the script mentioned in this link and added the following line to the terraform script above but it raised the same error:

    terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64

答案1

得分: 1

Databricks Terraform提供程序去年从databrickslabs切换到databricks,当它达到GA(公告博文)时。您需要更新您的代码以使用更新的版本 - 请查看故障排除指南中的说明,了解如何操作。

最好升级到最新版本 - 已经是1.11.x了。

附言:虽然Terraform注册表提供了从databrickslabsdatabricks的重定向,但在一些中间版本中出现了问题,因此您只能拉取到1.4.x或类似版本。

英文:

Databricks Terraform provider has switched from databrickslabs to databricks last year, when it reached the GA (announcement blog post). And you need to update your code to use newer versions - see instructions in the troubleshooting guide on how to do it.

And it's better to upgrade to the latest versions - it's already 1.11.x.

P.S. While Terraform registry provided a redirect from databrickslabs to databricks, it became broken in some of the intermediate versions, so you can pull only up to 1.4.x or something like that.

huangapple
  • 本文由 发表于 2023年3月3日 19:14:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定