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

Add capabilities to resource type API #8182

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

rynowak
Copy link
Contributor

@rynowak rynowak commented Jan 2, 2025

Description

This change adds the 'capabilities' concept to the resource type API.

  • Capabilities enable resource types to indicate the schema and behaviors they support.
  • Capabilities enable clients like the rad CLI to understand the behaviors of resource types dynamically.

For example, we're adding the SupportsRecipes capability.

  • All resource types that support recipes should declare this capability. This is how a UDT will opt-in to recipe functionality during provisioning.
  • The rad CLI functionality for rad recipe register can introspect the resource type to validate recipe support, rather than hardcoding which types have the support and which don't.

Description of the changes:

  • The manifests previously supported capabilities as part of the API version, we're moving this to the resource type for a simplification.
  • The manifest entry for capabilities wasn't sent to the server. Now it is.
  • Updated API, converters, and UCP functionality.

Type of change

  • This pull request adds or changes features of Radius and has an approved issue (issue link required).

Part of: #6688

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 January 2, 2025 21:59
@rynowak
Copy link
Contributor Author

rynowak commented Jan 2, 2025

/cc @lakshmimsft

@@ -4,34 +4,34 @@ types:
apiVersions:
"2025-01-01-preview":
schema: {}
capabilities: []
capabilities: []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: we decided to move this to the resource type rather than the API version.

There are edge cases in how a consumer should behave for a capability that was added to a resource type, and is missing support from previous API versions. These edge cases are present regardless of where we configure the capability, so we went with the simplest design.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of the changes in this PR are updates to existing configuration files or tests.

extenders:
apiVersions:
"2025-01-01-preview":
schema: {}
capabilities: ["Recipes"]
capabilities: ["SupportsRecipes"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: We wanted capabilities to use a Verb+Noun naming style so they are more readable.

@@ -140,6 +140,7 @@ func (r *Runner) Run(ctx context.Context) error {
r.Output.LogInfo("Creating resource type %s/%s", r.ResourceProvider.Name, resourceTypeName)
_, err := client.CreateOrUpdateResourceType(ctx, "local", r.ResourceProvider.Name, resourceTypeName, &v20231001preview.ResourceTypeResource{
Properties: &v20231001preview.ResourceTypeProperties{
Capabilities: to.SliceOfPtrs(resourceType.Capabilities...),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prior to this change, it was possible to include capabilities in a manifest, but they were unused.

return nil
}

return v1.NewClientErrInvalidRequest(fmt.Sprintf("capability %q is not recognized. Supported capabilities: %s", *input, datamodel.CapabilitySupportsRecipes))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This validation will be expanded over time, and potentially made more flexible. For right now we're just validating that one capability we support.


const (
// CapabilitySupportsRecipes is a capability that indicates the resource type supports recipes.
CapabilitySupportsRecipes = "SupportsRecipes"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next pull-request for UDT will read this capability and run the recipe engine if needed.

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 60.15%. Comparing base (46dc40d) to head (3ea3c72).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...cp/api/v20231001preview/resourcetype_conversion.go 82.35% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8182      +/-   ##
==========================================
- Coverage   60.15%   60.15%   -0.01%     
==========================================
  Files         587      587              
  Lines       38923    38943      +20     
==========================================
+ Hits        23415    23426      +11     
- Misses      13781    13787       +6     
- Partials     1727     1730       +3     

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

ytimocin
ytimocin previously approved these changes Jan 2, 2025
@rynowak rynowak temporarily deployed to functional-tests January 2, 2025 22:16 — with GitHub Actions Inactive
@radius-functional-tests
Copy link

radius-functional-tests bot commented Jan 2, 2025

Radius functional test overview

🔍 Go to test action run

Name Value
Repository rynowak/radius
Commit ref ab9d11e
Unique ID funcc1b36deabb
Image tag pr-funcc1b36deabb
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-funcc1b36deabb
  • 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-funcc1b36deabb
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcc1b36deabb
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcc1b36deabb
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcc1b36deabb
  • 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...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@@ -40,7 +43,4 @@ type ResourceTypeAPIVersion struct {
// TODO: this allows anything right now, and will be ignored. We'll improve this in
// a future pull-request.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

DefaultAPIVersion: dm.Properties.DefaultAPIVersion,
}

return nil
}

func validateCapability(input *string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a unit test for new function.

@lakshmimsft
Copy link
Contributor

lakshmimsft commented Jan 3, 2025

due to rebase, this file will need update: /pkg/ucp/integrationtests/resourceproviders/testdata/manifests/resourceprovider-valid1.yaml and
pkg/cli/manifest/testdata/registerdirectory/*.yaml

This change adds the 'capabilities' concept to the resource type API.

- Capabilities enable resource types to indicate the schema and behaviors they support.
- Capabilities enable clients like the `rad` CLI to understand the behaviors of resource types dynamically.

For example, we're adding the `SupportsRecipes` capability.

- All resource types that support recipes should declare this capability. This is how a UDT will opt-in to recipe functionality during provisioning.
- The `rad` CLI functionality for `rad recipe register` can introspect the resource type to validate recipe support, rather than hardcoding which types have the support and which don't.

----

Description of the changes:

- The manifests previously supported capabilities as part of the API version, we're moving this to the resource type for a simplification.
- The manifest entry for capabilities wasn't sent to the server. Now it is.
- Updated API, converters, and UCP functionality.

Signed-off-by: Ryan Nowak <nowakra@gmail.com>
@rynowak
Copy link
Contributor Author

rynowak commented Jan 3, 2025

@lakshmimsft - updated, can you re-review?

@rynowak rynowak temporarily deployed to functional-tests January 3, 2025 23:30 — with GitHub Actions Inactive
@radius-functional-tests
Copy link

radius-functional-tests bot commented Jan 3, 2025

Radius functional test overview

🔍 Go to test action run

Name Value
Repository rynowak/radius
Commit ref 3ea3c72
Unique ID funcbaf6cd1280
Image tag pr-funcbaf6cd1280
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-funcbaf6cd1280
  • 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-funcbaf6cd1280
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcbaf6cd1280
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcbaf6cd1280
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcbaf6cd1280
  • 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...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@rynowak rynowak merged commit 75d093a into radius-project:main Jan 4, 2025
29 checks passed
@rynowak rynowak deleted the capabilities branch January 4, 2025 07: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.

4 participants