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

Store and return the Recipe that was used as part of portable resources #6440

Closed
AaronCrawfis opened this issue Oct 9, 2023 · 6 comments · Fixed by #6450
Closed

Store and return the Recipe that was used as part of portable resources #6440

AaronCrawfis opened this issue Oct 9, 2023 · 6 comments · Fixed by #6450
Assignees
Labels
triaged This issue has been reviewed and triaged

Comments

@AaronCrawfis
Copy link
Contributor

AaronCrawfis commented Oct 9, 2023

Overview

We should return templateKind and templatePath (and templateVersion if Terraform) as part of the portable resource body (see below).

Note that this should be the templateKind and templatePath that were used when the portable resource was deployed. If the environment is updated with a different path/kind then the portable resource should still return the old one from when the portable resource was deployed, and not the new one.

Example

import radius as rad

resource env 'Applications.Core/environments@2023-10-01-preview' = {
  name: 'default'
  properties: {
    compute: {
      kind: 'kubernetes'
      namespace: 'default'
    }
    recipes: {
      'Applications.Datastores/redisCaches': {
        'default': {
          templateKind: 'bicep'
          templatePath: 'radius.azurecr.io/recipes/local-dev/rediscaches'
        }
      }
    }
  }
}

resource app 'Applications.Core/applications@2023-10-01-preview' = {
  name: 'myapp'
}

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = {
  name: 'redis'
  properties: {
    environment: env.id
    application: app.id
  }
}

Expected output

rad resource show rediscaches redis -o json
{
  "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Datastores/redisCaches/redis",
  "location": "global",
  "name": "redis",
  "properties": {
    "application": "/planes/radius/local/resourceGroups/default/providers/applications.core/applications/demo",
    "environment": "/planes/radius/local/resourceGroups/default/providers/applications.core/environments/default",
    "host": "redis-hjo6ha3uqagio.default-demo.svc.cluster.local",
    "port": 6379,
    "provisioningState": "Succeeded",
    "recipe": {
      "name": "default"
    },
    "resourceProvisioning": "recipe",
    "status": {
+      "recipe": {
+        templateKind: "bicep",
+        templatePath: "radius.azurecr.io/recipes/local-dev/rediscaches:latest"
+      }
      "outputResources": [
        {
          "id": "/planes/kubernetes/local/namespaces/default-demo/providers/core/Service/redis-hjo6ha3uqagio",
          "radiusManaged": true
        },
        {
          "id": "/planes/kubernetes/local/namespaces/default-demo/providers/apps/Deployment/redis-hjo6ha3uqagio",
          "radiusManaged": true
        }
      ]
    },
    "tls": false,
    "username": ""
  },
  "systemData": {
    "createdAt": "0001-01-01T00:00:00Z",
    "createdBy": "",
    "createdByType": "",
    "lastModifiedAt": "0001-01-01T00:00:00Z",
    "lastModifiedBy": "",
    "lastModifiedByType": ""
  },
  "tags": {},
  "type": "Applications.Datastores/redisCaches"
}

AB#9683

@rynowak
Copy link
Contributor

rynowak commented Oct 9, 2023

/cc @ytimocin

@shalabhms shalabhms added the triaged This issue has been reviewed and triaged label Oct 9, 2023
@ytimocin
Copy link
Contributor

ytimocin commented Oct 9, 2023

The design document will be added by me. Two things we want in the document: the statement of the scenario, and the typespec changes.

@rynowak
Copy link
Contributor

rynowak commented Oct 9, 2023

@AaronCrawfis - should this be included in the application graph as well?

@AaronCrawfis
Copy link
Contributor Author

should this be included in the application graph as well?

Yeah I think so, here's what I'm thinking:

{
    "resources": [
        {
            "connections": [
                {
                    "direction": "Inbound",
                    "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Core/containers/demo"
                }
            ],
            "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Datastores/redisCaches/redis",
            "name": "redis",
            "resources": [
                {
                    "id": "/planes/kubernetes/local/namespaces/default-myapp/providers/core/Service/redis-sdf675",
                    "name": "redis-sdf675",
                    "type": "core/Service"
                },
                {
                    "id": "/planes/kubernetes/local/namespaces/default-myapp/providers/apps/Deployment/redis-sdf675",
                    "name": "redis-sdf675",
                    "type": "apps/Deployment"
                }
            ],
+            "recipe": {
+               templateKind: "bicep",
+               templatePath: "radius.azurecr.io/recipes/local-dev/rediscaches:latest"
+            },
            "type": "Applications.Datastores/redisCaches",
            "provisioningState": "Succeeded"
        }
    ]
}

@rynowak
Copy link
Contributor

rynowak commented Oct 12, 2023

/cc @ytimocin @vinayada1 @nithyatsu - let's make sure the data is also in the new graph API before we close this issue.

@ytimocin
Copy link
Contributor

ytimocin commented Oct 12, 2023

Then this PR @vinayada1 should go before this PR @nithyatsu. The second one should be rebased after the first one is merged.

@rynowak rynowak removed the demo label Nov 2, 2023
vinayada1 added a commit that referenced this issue Nov 3, 2023
# Description

Add template kind and path to resource status. Then store these values
and return in rad resource show

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

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

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #6440 

## Auto-generated summary

<!--
GitHub Copilot for docs will auto-generate a summary of the PR
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at e1cbaec</samp>

### Summary
📝🚀🎁

<!--
1. 📝 - This emoji represents the changes that modify or update the test
cases and the sample data models to reflect the new `Recipe` field in
the `ResourceStatus` type. It also represents the changes that add
custom JSON serialization and deserialization logic for the `RecipeData`
and `ResourceStatus` types.
2. 🚀 - This emoji represents the changes that add the conditional blocks
to the `ConvertFrom` functions of the various resource types to populate
the `Recipe` field of the `ResourceStatus` type with the `RecipeData`
type. It also represents the changes that introduce the `RecipeData`
type and the `Recipe` field in the `ResourceStatus` type. These changes
enable the deployment of resources using templates, such as bicep files,
as part of the resource provider.
3. 🎁 - This emoji represents the changes that add new types and fields
to the `v20231001preview` package to support template-based resource
deployment with the dapr resource provider. It also represents the pull
request as a whole, which adds a new feature to the resource provider.
-->
This pull request adds support for template-based resource deployment in
the `v20231001preview` API version of the radius project. It introduces
the `RecipeData` type and the `Recipe` field in various resource status
types, and adds custom JSON serialization and deserialization logic for
them. It also updates the `ConvertFrom` functions and the test cases for
the affected resource types to handle the new `Recipe` field.

> _`Recipe` field added_
> _To support template deployment_
> _A new feature blooms_

### Walkthrough
* Add `RecipeData` type to represent the recipe data for a resource
deployment using templates
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-21034b9d798fa570ecae4b7d54142c7f94d9d0f1b39c5f45f0c4c859674b19fbR1354-R1362),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-a50172617a56a90110cf640526438fbb2b1e3b46f1c22dc2f0119a1d513baedfR481-R489),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-4ba9624b522a455e82e79bb4fac573d7c8c8af0f39b9df75efa926034a9e6156R1103-R1133))
* Add `Recipe` field to `ResourceStatus` type to hold the recipe data
for a resource deployment
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-21034b9d798fa570ecae4b7d54142c7f94d9d0f1b39c5f45f0c4c859674b19fbR1455-R1457),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-a50172617a56a90110cf640526438fbb2b1e3b46f1c22dc2f0119a1d513baedfR527-R529),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-4ba9624b522a455e82e79bb4fac573d7c8c8af0f39b9df75efa926034a9e6156R1236),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-4ba9624b522a455e82e79bb4fac573d7c8c8af0f39b9df75efa926034a9e6156R1255-R1257))
* Populate `Recipe` field in `ConvertFrom` functions of `Extender`,
`DaprPubSubBroker`, `DaprSecretStore`, `DaprStateStore`,
`MongoDatabase`, and `RedisCache` types
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-287413ad769e13989c3e7d75c20c1399ce90a2ccd7be0e1a57918968f5490729R90-R96),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-3a000e41539b8b6457f28fc3587853d2bc3aac0d9fac097f33cd622347835e1bR144-R150),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-eb720f089b10b32de7e0206eb26ba88405e39096da247e3a35d9d8cd125e38d8R136-R143),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-a8a8f5a7060d5275f77ceec374c048e6e38430ab02cfd60dffdcdc98020a4c8aR127-R133),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-a3deb9a38591d44ecf385106451d056ec8baeb200b3d558396b430952ecefcb2R111-R117),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-f3da6c5dde4eaacd441388811703b7cb0e650b6ae6ba9c9b6e1c9c6c6b580fb8R110-R116))
* Update test cases for `ConvertFrom` functions of `Extender`,
`DaprPubSubBroker`, `DaprSecretStore`, `DaprStateStore`,
`MongoDatabase`, and `RedisCache` types to reflect the `Recipe` field
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-bd287311ae13f33257e57cc10affc0dfa7c68d06294186501f62d76e1a85faf3L207-R212),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-3e36042b3fa516b14d6e34fee3536dcef97fb5c73325a4bc0244d8f1576daed1L220-R225),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-ed4bd83d135ddb4290a01afbb8d22312a733f13dba286675c9d466d7408bb002L184-R189),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-0951811300b3dbd68d11e79138bdaec82cb3624aca2cc15d718c92b7b374b7dcR173),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-0951811300b3dbd68d11e79138bdaec82cb3624aca2cc15d718c92b7b374b7dcR179-R184),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-10f63831be836e2619070614aa768a9a6351f3a1f388942fbf5478d611a7a84bR299-R302),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-3c767c971732c83e96fc31b7e924cf66d4fb853fc9d42d83936283b895085a0dL224-R229))
* Add sample data models for testing `ConvertFrom` functions of
`Extender`, `DaprPubSubBroker`, `DaprSecretStore`, and `DaprStateStore`
types with the `Recipe` field
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-e01ee096c196892a0b5be43c5e28fd01759162b492878771d860b7fef8464820L22-R26),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-105a4d9930462d0e04049cdad7cc1c97fa30bc4707c4d9e4a2fd4517e68a2d03L24-R28),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-2d3dd347fde4e6895a7c22d4ec1c665d56b30551ecb6e2193e2e11c4ce6e9a46L24-R28),
[link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-11867dad48397245fdab0cc50c6eb4b99e47f7cb20dac8118a6d06af75bc7056L24-R28))
* Simplify test case for `ConvertFrom` function of `DaprStateStore` type
by removing redundant assignment of `Status` field
([link](https://github.com/radius-project/radius/pull/6450/files?diff=unified&w=0#diff-0951811300b3dbd68d11e79138bdaec82cb3624aca2cc15d718c92b7b374b7dcL158))

---------

Signed-off-by: vinayada1 <[email protected]>
Co-authored-by: Shalabh Mohan Shrivastava <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged This issue has been reviewed and triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants