英文:
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状态保存在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时,这段代码可以正常工作。
这里您可以看到成功运行的示例:
当将databricks版本更改为1.5.0时,此管道中出现的错误如下:
我尝试过但未成功的解决方案:
- 我将"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:
- 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 = "<azure subscription id>"
resource_group_name = "<name of azure resource group>"
storage_account_name = "<name of my azure storage account>"
container_name = "tfstates"
key = "databricks-job.tfstate"
The code for versions.tf is as follows:
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.44.1"
}
databricks = {
source = "databrickslabs/databricks"
version = "1.5.0" ## works for 0.6.2
}
}
}
The DevOps stage to terraform init and plan is as follows:
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 application id>
ARM_CLIENT_SECRET: <Service principal secret >
ARM_SUBSCRIPTION_ID: <Azure subscription id>
ARM_TENANT_ID: <Azure tenant id>
- script: cat deployment-pipelines/tf/$(artifactPath)/$(artifactName)
displayName: Read tfplan
- publish: deployment-pipelines/tf/$(artifactPath)/$(artifactName)
displayName: 'Publish Terraform plan file'
artifact: $(artifactName)
Just in case you want to know what is in main.tf, it is as follows:
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"
}
}
}
As I mentioned this code works well when 1.5.0 is replaced with 0.6.2.
Here you can see the successful run:
Here is the error in the pipeline when databricks version is changed to 1.5.0:
Solutions I tried but didn't work:
-
I downgraded the "databrickslabs/databricks" version to 1.4.0, still same error.
-
I deleted the terraform state file in Azure Storage container, but still same error.
-
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注册表提供了从databrickslabs
到databricks
的重定向,但在一些中间版本中出现了问题,因此您只能拉取到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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论