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

[ISSUE] Unable to Create Databricks Repo with v0.3.8 #852

Closed
troyinsight opened this issue Oct 8, 2021 · 15 comments
Closed

[ISSUE] Unable to Create Databricks Repo with v0.3.8 #852

troyinsight opened this issue Oct 8, 2021 · 15 comments
Assignees
Labels
azure Occurring on Azure cloud invalid This issue is not relevant to this provider or works as designed
Milestone

Comments

@troyinsight
Copy link

troyinsight commented Oct 8, 2021

Howdy,

I'm trying to set up a new Repo within Databricks, pointing to a private GitHub repository. I have manually created a GitHub PAT and set up my Git Integration to use this. I can manually create the Repo using the Databricks UI. Trying to create the repo via Terraform fails with an 'Invalid access token' error.

Configuration

provider "databricks" {
  host  = module.databricks_workspace.workspace_url
}

Expected Behavior

Creates a new Repo linked to my GitHub repository.

Actual Behavior

I receive an error stating: Error: Invalid access token

Steps to Reproduce

  1. Create PAT token within GitHub
  2. Update Git Integration to use this token
  3. terraform apply

Terraform and provider versions

Terraform v1.0.8
on darwin_amd64

  • provider registry.terraform.io/databrickslabs/databricks v0.3.8
  • provider registry.terraform.io/hashicorp/azuread v2.6.0
  • provider registry.terraform.io/hashicorp/azurerm v2.79.1
  • provider registry.terraform.io/hashicorp/random v3.1.0
  • provider registry.terraform.io/integrations/github v4.16.0
  • provider registry.terraform.io/microsoft/azuredevops v0.1.7
@troyinsight troyinsight changed the title [ISSUE] Provider issue [ISSUE] Unable to Create Databricks Repo with v0.3.8 Oct 8, 2021
@alexott
Copy link
Contributor

alexott commented Oct 8, 2021

@troyinsight please attach debug output. It looks like you can’t authenticate to DB itself

@alexott alexott self-assigned this Oct 8, 2021
@troyinsight
Copy link
Author

Thanks @alexott. I think I've just discovered the issue. You can see from the debug output below that it's using the DEFAULT profile from my .databrickscfg file. Why would it be using this file? I don't have any issues creating clusters, pools, secret scopes etc, just my new repo.

2021-10-08T18:37:49.950+1030 [INFO] provider.terraform-provider-databricks_v0.3.8: Using DEFAULT profile from /Users/troy/.databrickscfg: timestamp=2021-10-08T18:37:49.950+1030
2021-10-08T18:37:49.950+1030 [INFO] provider.terraform-provider-databricks_v0.3.8: Using Bearer authentication from ~/.databrickscfg: timestamp=2021-10-08T18:37:49.950+1030
2021-10-08T18:37:49.950+1030 [DEBUG] provider.terraform-provider-databricks_v0.3.8: POST /repos {
"url": "https://github.com/troy/databricks.git"
2021-10-08T18:37:50.236+1030 [DEBUG] provider.terraform-provider-databricks_v0.3.8: 403 Forbidden: timestamp=2021-10-08T18:37:50.236+1030
2021-10-08T18:37:50.236+1030 [WARN] provider.terraform-provider-databricks_v0.3.8: /api/2.0/repos:403 - Invalid access token: timestamp=2021-10-08T18:37:50.236+1030
2021-10-08T18:37:50.236+1030 [WARN] provider.terraform-provider-databricks_v0.3.8: /api/2.0/repos:403 - Invalid access token: timestamp=2021-10-08T18:37:50.236+1030

@alexott
Copy link
Contributor

alexott commented Oct 8, 2021

Repos functionality uses the same authentication as everything else. In your configuration you provided only host, but you need to provide token as well if you want to point to another workspace.

@troyinsight
Copy link
Author

troyinsight commented Oct 8, 2021

Sorry, I should have mentioned that I'm using Azure CLI Authentication.

The workspace is created using the AzureRM provider. I then reference this straight away and start creating creating clusters, pools, secret scopes etc. These all work fine. As a test I just upgraded one of my clusters to DBR 9.1. It seems to be just the Repo functionality.

@alexott
Copy link
Contributor

alexott commented Oct 8, 2021

Can you include bigger chunk of debug log? There was a refactoring for auth pieces, maybe it’s related…

@nfx
Copy link
Contributor

nfx commented Oct 8, 2021

@troyinsight most likely you have to add your GitHub PAT to Databricks workspace manually. At least for now, until the API for that is released soon.

@nfx nfx added this to the v0.3.9 milestone Oct 8, 2021
@nfx
Copy link
Contributor

nfx commented Oct 8, 2021

@troyinsight so with missing GitHub PAT token, you'd see Missing Git provider credentials. Go to User Settings > Git Integration to add your personal access token. error. Invalid access token is just strange. You can also open a support ticket with more details and debug logs.

@nfx nfx added cannot reproduce insufficient details or issue cannot be reproduced needs-api changes to Databricks Platform APIs are required labels Oct 8, 2021
@troyinsight
Copy link
Author

Thanks guys. I'm just doing some more testing this morning. I totally understand that at this stage we need to manually add our GitHub PAT token into the workspace, which I have done. As mentioned, I can create the repo within the Databricks UI and it works fine. As a test I've also tried using Terraform to create a Repo pointing to a different (and Public) GitHub repository. This didn't work either, so it doesn't seem to matter if the GitHub repo is public or private. I'll post a Gist soon.

@troyinsight
Copy link
Author

Okay, here's a link to my debug output. I've totally refactored my Terraform module so it doesn't include anything but Databricks (to keep the output smaller). My module now creates a single Databricks workspace, creates a cluster and tries to create the repo. Obviously, after the Workspace is initially created I enter my GitHub PAT token.

https://gist.github.com/troyinsight/f970a933a413eb9f69a822e55f4b30df

@alexott
Copy link
Contributor

alexott commented Oct 9, 2021

Hmmmm, it’s strange - for cluster I see azcli auth, but not for repos. Can you post your terraform code to alexey.ott at databricks.com

@nfx
Copy link
Contributor

nfx commented Oct 9, 2021

@alexott aren't you on vacation? 🥸🤫

@nfx
Copy link
Contributor

nfx commented Oct 9, 2021

@troyinsight It looks to me that you didn't initialize Databricks provider in module.troymod - e.g. no host is supplied and it looks in .databrickscfg as the last resort.

Please make sure you pass host to a module and init it there as well.

@nfx
Copy link
Contributor

nfx commented Oct 9, 2021

@troyinsight can you confirm that provider has no initialization in the module with a repo declaration? And it works, once you explicitly pass the host of the workspace?

I've reopened #821 to make auth messages less confusing.

@troyinsight
Copy link
Author

Ahh, thanks guys, it was user error. I am initialising the Databricks provider within my module, the issue is that I have two workspaces (one for ML). I wasn't using the provider alias within my databricks_repo resource. Sorry for the hassle.

It would be aweome if we could get Git Integration working through Terraform eventually :-)

@nfx
Copy link
Contributor

nfx commented Oct 9, 2021

API for adding GH PAT should be there in more than few months. Keep escalating it to your databricks representatives so it's pushed up in priority.

Closing this issue.

@nfx nfx added invalid This issue is not relevant to this provider or works as designed and removed needs-api changes to Databricks Platform APIs are required cannot reproduce insufficient details or issue cannot be reproduced labels Oct 9, 2021
@nfx nfx closed this as completed Oct 9, 2021
@nfx nfx added the azure Occurring on Azure cloud label Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure Occurring on Azure cloud invalid This issue is not relevant to this provider or works as designed
Projects
None yet
Development

No branches or pull requests

3 participants