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

Simplify database interface #8126

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

rynowak
Copy link
Contributor

@rynowak rynowak commented Dec 12, 2024

Description

This change simplifes our database provider interface by removing the 'name' parameter.

Prior to this change, each database client was used to store and retrieve a single resource type's data. Every piece of code had to be aware of the resource type associated with the client, and make sure to get a different client for each resource type it interacted with.

This was complicated further by the fact that not all of our database providers implemented this restriction.


After removing this restriction, our code can be simplified all over the place. A lot of code that used to need the dataprovider.DataStoreProvider now just needs the store.StorageClient.

This change pushes the simplification as far as possible. I also added validation to places where we initialize controllers, because it was too easy to initialize a controller with missing data.

Type of change

  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
  • If applicable, design document has been reviewed and approved by Radius maintainers/approvers.
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.

@rynowak rynowak requested review from a team as code owners December 12, 2024 17:42
@rynowak rynowak temporarily deployed to functional-tests December 12, 2024 17:46 — with GitHub Actions Inactive
@radius-functional-tests
Copy link

radius-functional-tests bot commented Dec 12, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository rynowak/radius
Commit ref a72530b
Unique ID funcbde3141ecd
Image tag pr-funcbde3141ecd
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr:
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcbde3141ecd
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcbde3141ecd
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcbde3141ecd
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcbde3141ecd
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcbde3141ecd
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
❌ Failed to install Radius for ucp-cloud functional test. Please check the logs for more details
❌ ucp-cloud functional test failed. Please check the logs for more details
❌ Failed to install Radius for corerp-cloud functional test. Please check the logs for more details
❌ corerp-cloud functional test failed. Please check the logs for more details

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 63.38583% with 93 lines in your changes missing coverage. Please review.

Project coverage is 59.46%. Comparing base (186800b) to head (3d1f9f6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/armrpc/asyncoperation/controller/controller.go 0.00% 9 Missing ⚠️
pkg/armrpc/asyncoperation/worker/service.go 0.00% 8 Missing ⚠️
pkg/armrpc/frontend/server/service.go 0.00% 7 Missing ⚠️
pkg/dynamicrp/options.go 0.00% 7 Missing ⚠️
pkg/server/asyncworker.go 0.00% 7 Missing ⚠️
pkg/ucp/dataprovider/storageprovider.go 85.71% 4 Missing and 3 partials ⚠️
pkg/ucp/frontend/api/server.go 0.00% 7 Missing ⚠️
pkg/server/apiservice.go 0.00% 6 Missing ⚠️
pkg/ucp/backend/service.go 62.50% 6 Missing ⚠️
pkg/armrpc/frontend/server/handler.go 37.50% 5 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8126      +/-   ##
==========================================
- Coverage   59.66%   59.46%   -0.20%     
==========================================
  Files         577      577              
  Lines       38573    38644      +71     
==========================================
- Hits        23013    22981      -32     
- Misses      13914    13996      +82     
- Partials     1646     1667      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lakshmimsft
Copy link
Contributor

will there be separate PR for name updates proposed here: https://gist.github.com/rynowak/0e625521404326eb194adc98155a736b

@rynowak
Copy link
Contributor Author

rynowak commented Dec 13, 2024

Functional test failure is due to applications rp crashing at startup. I'll dig into it.

@rynowak rynowak force-pushed the rynowak/simplify-database branch from a72530b to afc96c6 Compare December 16, 2024 21:16
@rynowak rynowak force-pushed the rynowak/simplify-database branch from afc96c6 to e23467b Compare December 16, 2024 22:04
@rynowak rynowak temporarily deployed to functional-tests December 16, 2024 22:18 — with GitHub Actions Inactive
This change simplifes our database provider interface by removing the 'name' parameter.

Prior to this change, each database client was used to store and retrieve a single resource type's data. Every piece of code had to be aware of the resource type associated with the client, and make sure to get a different client for each resource type it interacted with.

This was complicated further by the fact that not all of our database providers implemented this restriction.

---

After removing this restriction, our code can be simplified all over the place. A lot of code that used to need the `dataprovider.DataStoreProvider` now just needs the `store.StorageClient`.

This change pushes the simplification as far as possible. I also added validation to places where we initialize controllers, because it was too easy to initialize a controller with missing data.

Signed-off-by: Ryan Nowak <[email protected]>
@rynowak rynowak force-pushed the rynowak/simplify-database branch from e23467b to 3d1f9f6 Compare December 16, 2024 22:19
@radius-functional-tests
Copy link

radius-functional-tests bot commented Dec 16, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository rynowak/radius
Commit ref e23467b
Unique ID funcac1f4cf5e7
Image tag pr-funcac1f4cf5e7
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr:
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcac1f4cf5e7
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcac1f4cf5e7
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcac1f4cf5e7
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcac1f4cf5e7
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcac1f4cf5e7
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ corerp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded

@rynowak rynowak temporarily deployed to functional-tests December 16, 2024 22:31 — with GitHub Actions Inactive
@radius-functional-tests
Copy link

radius-functional-tests bot commented Dec 16, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository rynowak/radius
Commit ref 3d1f9f6
Unique ID funce196a6cdad
Image tag pr-funce196a6cdad
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr:
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funce196a6cdad
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funce196a6cdad
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funce196a6cdad
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funce196a6cdad
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funce196a6cdad
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

return &DataStorageProvider{result: result{client: client}}
}

// GetStorageClient returns a storage client for the given resource type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment needs update since resource type is not an input for client generated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@rynowak rynowak merged commit 4f2f16e into radius-project:main Dec 16, 2024
29 checks passed
@rynowak rynowak deleted the rynowak/simplify-database branch December 17, 2024 00:38
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