-
Notifications
You must be signed in to change notification settings - Fork 100
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 DeploymentTemplate controller for GitOps support #8001
Add DeploymentTemplate controller for GitOps support #8001
Conversation
pkg/cli/cmd/deploy/deploy_test.go
Outdated
@@ -527,7 +527,6 @@ func Test_Run(t *testing.T) { | |||
}) | |||
|
|||
t.Run("Deployment with missing parameters", func(t *testing.T) { | |||
//t.Skip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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... |
pkg/cli/cmd/bicep/generatekubernetesmanifest/generatekubernetesmanifest.go
Outdated
Show resolved
Hide resolved
pkg/cli/cmd/bicep/generatekubernetesmanifest/generatekubernetesmanifest.go
Outdated
Show resolved
Hide resolved
pkg/cli/cmd/bicep/generatekubernetesmanifest/generatekubernetesmanifest.go
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
@@ -72,7 +72,7 @@ type BicepOptions struct { | |||
|
|||
type bicepDriver struct { | |||
ArmClientOptions *arm.ClientOptions | |||
DeploymentClient *clients.ResourceDeploymentsClient | |||
DeploymentClient clients.ResourceDeploymentsClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapping to use interface instead of struct
@@ -175,3 +188,57 @@ func (client *ResourceDeploymentsClient) createOrUpdateCreateRequest(ctx context | |||
req.Raw().Header["Accept"] = []string{"application/json"} | |||
return req, runtime.MarshalAsJSON(req, parameters) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lakshmimsft here
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls add comment for function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
connection sdk.Connection | ||
} | ||
|
||
func NewDeploymentClient(connection sdk.Connection) *DeploymentClientImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments needed for exported type/functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -42,9 +39,6 @@ type DeploymentResourceStatus struct { | |||
|
|||
// Phrase indicates the current status of the Deployment Resource. | |||
Phrase DeploymentResourcePhrase `json:"phrase,omitempty"` | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this unused before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Signed-off-by: willdavsmith <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by the naming choice. We already have a ResourceDeploymentsClient
used in the SDK clients package:
type ResourceDeploymentsClient interface { |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is rdc *ResourceDeploymentsClientImpl
the correct value? Should it not be DeploymentClientImpl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
@@ -44,7 +44,7 @@ type RecipeControllerConfig struct { | |||
ConfigLoader configloader.ConfigurationLoader | |||
|
|||
// DeploymentEngineClient is the client for interacting with the deployment engine. | |||
DeploymentEngineClient *clients.ResourceDeploymentsClient | |||
DeploymentEngineClient clients.ResourceDeploymentsClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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... |
Signed-off-by: willdavsmith <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
rad bicep generate-kubernetes-manifest
CLIType of change
#6689
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: