Repository navigation
Add DeploymentTemplate controller for GitOps support - #8001
willdavsmith merged 77 commits into
Conversation
| }) | ||
|
|
||
| t.Run("Deployment with missing parameters", func(t *testing.T) { | ||
| //t.Skip() |
There was a problem hiding this comment.
removing commented out t.Skip()
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
There was a problem hiding this comment.
I ran make generate build test and got 8 failures.
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run/Create_basic_DeploymentTemplate (0.00s)
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run/Create_DeploymentTemplate_with_template_content (0.00s)
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run/Create_DeploymentTemplate_with_Azure_scope (0.00s)
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run/Create_DeploymentTemplate_with_AWS_scope (0.00s)
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run (0.00s)
=== FAIL: pkg/controller/reconciler Test_DeploymentResourceReconciler_Basic (10.01s)
=== FAIL: pkg/controller/reconciler Test_DeploymentTemplateReconciler_Basic (0.01s)
=== FAIL: pkg/controller/reconciler Test_DeploymentTemplateReconciler_FailureRecovery (0.00s)Here's one example:
=== FAIL: pkg/cli/cmd/bicep/generatekubernetesmanifest Test_Run/Create_DeploymentTemplate_with_Azure_scope (0.00s)
Creating DeploymentTemplate YAML file
generatekubernetesmanifest_test.go:396:
Error Trace: /workspaces/radius/pkg/cli/cmd/bicep/generatekubernetesmanifest/generatekubernetesmanifest_test.go:396
Error: Not equal:
expected: "apiVersion: radapp.io/v1alpha3\nkind: DeploymentTemplate\nmetadata:\n name: azure.yaml\n namespace: radius-system\nspec:\n parameters: '{}'\n providerConfig: '{\"radius\":{\"type\":\"radius\",\"value\":{\"scope\":\"/planes/radius/local/resourceGroups/test-resource-group\"}},\"az\":{\"type\":\"azure\",\"value\":{\"scope\":\"/subscriptions/test-subId/resourceGroups/test-rg\"}},\"deployments\":{\"type\":\"Microsoft.Resources\",\"value\":{\"scope\":\"/planes/radius/local/resourceGroups/test-resource-group\"}}}'\n template: '{}'\n"
actual : "apiVersion: radapp.io/v1alpha3\nkind: DeploymentTemplate\nmetadata:\n name: azure.yaml\n namespace: radius-system\nspec:\n parameters: '{}'\n providerConfig: '{\"radius\":{\"type\":\"radius\",\"value\":{\"scope\":\"/planes/radius/local/resourceGroups/test-resource-group\"}},\"az\":{\"type\":\"azure\",\"value\":{\"scope\":\"/subscriptions/test-subId/resourceGroups/test-rg\"}},\"deployments\":{\"type\":\"Microsoft.Resources\",\"value\":{\"scope\":\"/planes/radius/local/resourceGroups/test-resource-group\"}}}'\n repository: azure.yaml\n template: '{}'\n"
Diff:
--- Expected
+++ Actual
@@ -8,2 +8,3 @@
providerConfig: '{"radius":{"type":"radius","value":{"scope":"/planes/radius/local/resourceGroups/test-resource-group"}},"az":{"type":"azure","value":{"scope":"/subscriptions/test-subId/resourceGroups/test-rg"}},"deployments":{"type":"Microsoft.Resources","value":{"scope":"/planes/radius/local/resourceGroups/test-resource-group"}}}'
+ repository: azure.yaml
template: '{}'
Test: Test_Run/Create_DeploymentTemplate_with_Azure_scope
--- FAIL: Test_Run/Create_DeploymentTemplate_with_Azure_scope (0.00s)
brooke-hamilton
left a comment
There was a problem hiding this comment.
Running make generate results in these files being changed.
deploy/Chart/crds/radius/radapp.io_deploymentresources.yaml
deploy/Chart/crds/radius/radapp.io_deploymenttemplates.yaml
deploy/Chart/crds/radius/radapp.io_recipes.yaml
deploy/Chart/crds/ucpd/ucp.dev_queuemessages.yaml
deploy/Chart/crds/ucpd/ucp.dev_resources.yaml
For example, controller-gen.kubebuilder.io/version: v0.16.4 changes to controller-gen.kubebuilder.io/version: v0.16.0
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
| type ResourceDeploymentClient struct { | ||
| RadiusResourceGroup string | ||
| Client *sdkclients.ResourceDeploymentsClient | ||
| Client sdkclients.ResourceDeploymentsClient |
There was a problem hiding this comment.
I changed this from a struct to an interface (since I use the same type in deploymenttemplate controller). This makes testing way easier.
There was a problem hiding this comment.
It should not impact the functionality at all.
| resourceDeploymentClient := ResourceDeploymentClient{ | ||
| RadiusResourceGroup: "testrg", | ||
| Client: &sdkclients.ResourceDeploymentsClient{}, | ||
| OperationsClient: &sdkclients.ResourceDeploymentOperationsClient{}, |
There was a problem hiding this comment.
These weren't actually doing anything in the test. We should write tests using the interface like I do in the deploymenttemplate controller unit tests.
| sdkclients "github.com/radius-project/radius/pkg/sdk/clients" | ||
| ) | ||
|
|
||
| type DeploymentClient interface { |
There was a problem hiding this comment.
I added this DeploymentClient interface (similar to the existing RadiusClient interface) because the deploymenttemplate controller needs to access the UCP deployment client. Having this interface makes it possible to write out mocks for testing.
| @@ -75,6 +76,13 @@ func (rc *mockRadiusClient) Update(exec func()) { | |||
| exec() | |||
| } | |||
There was a problem hiding this comment.
The changes in this file are for clarity. I was getting very confused when adding a new client, so I made it explicit that these operations are for the RadiusClient
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
There was a problem hiding this comment.
This isn't new code, I just moved it from the existing RadiusClient (because it's shared by RadiusClient and DeploymentClient now)
| @@ -29,15 +27,6 @@ import ( | |||
| "github.com/radius-project/radius/pkg/ucp/resources" | |||
| ) | |||
|
|
|||
There was a problem hiding this comment.
The changes in this file are only for clarity. functionality is unaffected
| type bicepDriver struct { | ||
| ArmClientOptions *arm.ClientOptions | ||
| DeploymentClient *clients.ResourceDeploymentsClient | ||
| DeploymentClient clients.ResourceDeploymentsClient |
There was a problem hiding this comment.
Swapping to use interface instead of struct
| req.Raw().Header["Accept"] = []string{"application/json"} | ||
| return req, runtime.MarshalAsJSON(req, parameters) | ||
| } | ||
|
|
There was a problem hiding this comment.
I had to add some functionality to the ResourceDeploymentsClient for async processing. Today we just call PollUntilDone() in the CLI deployment and bicep driver.
| waitForDeploymentTemplateStateDeleted(t, k8sClient, namespacedName) | ||
| } | ||
|
|
||
| func Test_DeploymentTemplateReconciler_OutputResources(t *testing.T) { |
| return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateResponse](resumeToken, *client.pipeline, nil) | ||
| } | ||
|
|
||
| func (client *ResourceDeploymentsClientImpl) Delete(ctx context.Context, resourceID, apiVersion string) (*runtime.Poller[ClientDeleteResponse], error) { |
There was a problem hiding this comment.
Pls add comment for function.
| connection sdk.Connection | ||
| } | ||
|
|
||
| func NewDeploymentClient(connection sdk.Connection) *DeploymentClientImpl { |
There was a problem hiding this comment.
comments needed for exported type/functions
|
|
||
| // Phrase indicates the current status of the Deployment Resource. | ||
| Phrase DeploymentResourcePhrase `json:"phrase,omitempty"` | ||
|
|
There was a problem hiding this comment.
I can't tell exactly what this is referring to but if it's the ProviderConfig, yes it's unused now that I'm using the DeploymentsClient instead of the RadiusClient.
…deploymenttemplatecontroller
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
|
|
||
| // ResourceDeploymentsClient is an interface for interacting | ||
| // with UCP Deployments. | ||
| type ResourceDeploymentsClient interface { |
There was a problem hiding this comment.
I'm a little confused by the naming choice. We already have a ResourceDeploymentsClient used in the SDK clients package:
Based on the code, it seems like these are both deployment clients that serve UCP (although the one linked above serves Azure and UCP) so why are we redefining the interface? If both `ResourceDeploymentsClient are meant to serve different purposes or serve different deployments (Azure/UCP vs deployment resources/templates), I think we should rename this for clarity.
There was a problem hiding this comment.
They do the same thing - I think we could consolidate them. I think I would rather handle this together with other changes later to move the mocks outside of reconciler package though.
| var _ DeploymentClient = (*DeploymentClientImpl)(nil) | ||
|
|
||
| // CreateOrUpdate creates or updates a deployment. | ||
| func (rdc *ResourceDeploymentsClientImpl) CreateOrUpdate(ctx context.Context, parameters sdkclients.Deployment, resourceID, apiVersion string) (Poller[sdkclients.ClientCreateOrUpdateResponse], error) { |
There was a problem hiding this comment.
Is rdc *ResourceDeploymentsClientImpl the correct value? Should it not be DeploymentClientImpl?
There was a problem hiding this comment.
I think this is right. ResourceDeploymentsClientImpl is the type that has all of the actual functions, DeploymentClientImpl just has an accessor (ResourceDeployments())
| var _ ResourceDeploymentsClient = (*ResourceDeploymentsClientImpl)(nil) | ||
|
|
||
| // ResourceDeploymentsClientImpl is an implementation of ResourceDeploymentsClient. | ||
| type ResourceDeploymentsClientImpl struct { |
There was a problem hiding this comment.
Can you explain why we're choosing to wrap the ResourceDeploymentsClient from sdkclients and also defined a new ResourceDeploymentsClient in this file? I'm not sure I see the 2 distinct use cases here
There was a problem hiding this comment.
They're the same - we can merge them. For now, I wanted to keep the code in the reconciler package to match the RadiusClient. We can consolidate after
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
|
|
||
| // DeploymentEngineClient is the client for interacting with the deployment engine. | ||
| DeploymentEngineClient *clients.ResourceDeploymentsClient | ||
| DeploymentEngineClient clients.ResourceDeploymentsClient |
There was a problem hiding this comment.
This is struct -> interface, shouldn't affect functionality
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
rad bicep generate-kubernetes-manifestCLIType of change
#6689
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: