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

Migrated databricks_cluster resource to Go SDK #3376

Merged
merged 29 commits into from
Apr 12, 2024
Merged

Conversation

tanmay-db
Copy link
Contributor

@tanmay-db tanmay-db commented Mar 18, 2024

Changes

Migrated cluster resource to Go SDK along with migrating major references of libraries api and method across clusters, jobs, exporter etc.

Note: Many resources use old clusters API, methods -- migration for these would be part of when we will be migrating those resources to Go SDK to account for resource specific OpenAPI changes, extra methods at that time like we did with the libraries resource.

Tests

Unit tests, Nightly tests are running ...

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

@tanmay-db tanmay-db requested review from a team as code owners March 18, 2024 03:23
@tanmay-db tanmay-db requested review from mgyucht and removed request for a team and mgyucht March 18, 2024 03:23
@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 75.42857% with 43 lines in your changes are missing coverage. Please review.

Project coverage is 82.95%. Comparing base (3d30621) to head (cbcfc68).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3376      +/-   ##
==========================================
- Coverage   83.51%   82.95%   -0.56%     
==========================================
  Files         178      178              
  Lines       16595    16575      -20     
==========================================
- Hits        13859    13750     -109     
- Misses       1891     1967      +76     
- Partials      845      858      +13     
Files Coverage Δ
jobs/resource_job.go 89.45% <ø> (ø)
pipelines/resource_pipeline.go 92.85% <ø> (ø)
exporter/importables.go 79.84% <80.00%> (ø)
libraries/libraries_api.go 56.09% <42.85%> (-38.81%) ⬇️
clusters/resource_cluster.go 85.26% <84.80%> (-2.00%) ⬇️
exporter/util.go 74.55% <50.00%> (-2.24%) ⬇️

... and 1 file with indirect coverage changes

@tanmay-db tanmay-db changed the title Migrated databricks_cluster resource to Go SDK [WIP] Migrated databricks_cluster resource to Go SDK Mar 18, 2024
@alexott alexott requested review from a team, mgyucht and edwardfeng-db March 18, 2024 08:47
libraries/libraries_api.go Outdated Show resolved Hide resolved
@tanmay-db tanmay-db changed the title [WIP] Migrated databricks_cluster resource to Go SDK Migrated databricks_cluster resource to Go SDK Mar 28, 2024
@tanmay-db tanmay-db requested review from alexott and nkvuong March 28, 2024 12:26
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, but otherwise looking good!

clusters/resource_cluster.go Show resolved Hide resolved
clusters/resource_cluster.go Show resolved Hide resolved
clusters/resource_cluster.go Outdated Show resolved Hide resolved
clusters/resource_cluster.go Outdated Show resolved Hide resolved
clusters/resource_cluster_test.go Outdated Show resolved Hide resolved
clusters/resource_cluster_test.go Show resolved Hide resolved
clusters/resource_cluster.go Outdated Show resolved Hide resolved
libraries/libraries_api.go Outdated Show resolved Hide resolved
clusters/resource_cluster.go Show resolved Hide resolved
@tanmay-db tanmay-db requested a review from mgyucht April 11, 2024 11:26
}
}

type LibraryList struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this type (with struct annotations) below, so we have to explicitly declare it.

var libraryList LibraryList
common.DataToStructPointer(d, clusterSchema, &libraryList)

Given it's only used in clusters and to not encourage wide use, I think we should keep it here as compared to libraries_api.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @miles, I am not sure if there is a better / easier way to do this, we could probably get the type from ClusterSpec.Libraries using reflection but I think having a 2 line struct would be simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use ClusterSpec

Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two very small nits, but otherwise this LGTM!

Comment on lines +243 to 244
var libraryList compute.InstallLibraries
common.DataToStructPointer(d, clusterSchema, &libraryList)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of adding libraries to the schema was that we don't need to call DataToStructPointer multiple times, right?

Suggested change
var libraryList compute.InstallLibraries
common.DataToStructPointer(d, clusterSchema, &libraryList)
libraryList := compute.InstallLibraries{
ClusterId: clusterInfo.ClusterId,
Libraries: cluster.Libraries,
}

Comment on lines +441 to +443
var libraryList ClusterSpec
common.DataToStructPointer(d, clusterSchema, &libraryList)
libsToInstall, libsToUninstall := libraries.GetLibrariesToInstallAndUninstall(libraryList.Libraries, libsClusterStatus)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well?

Suggested change
var libraryList ClusterSpec
common.DataToStructPointer(d, clusterSchema, &libraryList)
libsToInstall, libsToUninstall := libraries.GetLibrariesToInstallAndUninstall(libraryList.Libraries, libsClusterStatus)
libsToInstall, libsToUninstall := libraries.GetLibrariesToInstallAndUninstall(cluster.Libraries, libsClusterStatus)

@tanmay-db
Copy link
Contributor Author

Going ahead with merge for now, need to check issues arising due to differences between ClusterSpec and other Cluster structs.

@tanmay-db tanmay-db added this pull request to the merge queue Apr 12, 2024
Merged via the queue into main with commit f2e395b Apr 12, 2024
5 checks passed
@tanmay-db tanmay-db deleted the migrate-cluster branch April 12, 2024 09:13
@tanmay-db tanmay-db mentioned this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants