Skip to content

Commit

Permalink
Add support for azure deployment creation (#1718)
Browse files Browse the repository at this point in the history
Co-authored-by: Pritesh Arora <[email protected]>
  • Loading branch information
pritt20 and Pritesh Arora authored Sep 27, 2024
1 parent 02c6923 commit a5c906a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion cloud/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ func ListClusterOptions(cloudProvider string, coreClient astrocore.CoreClient) (
if cloudProvider == awsCloud {
provider = astrocore.GetClusterOptionsParamsProvider(astrocore.GetClusterOptionsParamsProviderAws) //nolint
}
if cloudProvider == azureCloud {
provider = astrocore.GetClusterOptionsParamsProvider(astrocore.GetClusterOptionsParamsProviderAzure) //nolint
}
optionsParams := &astrocore.GetClusterOptionsParams{
Provider: &provider,
Type: astrocore.GetClusterOptionsParamsType(astrocore.GetClusterOptionsParamsTypeSHARED), //nolint
Expand Down Expand Up @@ -1734,7 +1737,7 @@ func deploymentSelectionProcess(ws string, deployments []astroplatformcore.Deplo
coreDeploymentType = astroplatformcore.DeploymentTypeSTANDARD
dagDeploy = enable
}
err = createDeployment("", ws, "", "", runtimeVersion, dagDeploy, CeleryExecutor, "gcp", "", "", "", "disable", cicdEnforcement, "", "", "", "", "", coreDeploymentType, 0, 0, platformCoreClient, coreClient, false)
err = createDeployment("", ws, "", "", runtimeVersion, dagDeploy, CeleryExecutor, "azure", "", "", "", "disable", cicdEnforcement, "", "", "", "", "", coreDeploymentType, 0, 0, platformCoreClient, coreClient, false)
if err != nil {
return astroplatformcore.Deployment{}, err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/cloud/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var (
httpClient = httputil.NewHTTPClient()
errFlag = errors.New("--deployment-file can not be used with other arguments")
errInvalidExecutor = errors.New("not a valid executor")
errInvalidCloudProvider = errors.New("not a valid cloud provider. It can only be gcp or aws")
errInvalidCloudProvider = errors.New("not a valid cloud provider. It can only be gcp, azure or aws")
)

func newDeploymentRootCmd(out io.Writer) *cobra.Command {
Expand Down Expand Up @@ -407,7 +407,7 @@ func newDeploymentCreateCmd(out io.Writer) *cobra.Command {
cmd.Flags().StringVarP(&defaultTaskPodMemory, "default-task-pod-memory", "", "", "The default task pod memory to use for the Deployment. Example value: 0.5Gi")
cmd.Flags().StringVarP(&resourceQuotaCPU, "resource-quota-cpu", "", "", "The Deployment's CPU resource quota. Example value: 10")
cmd.Flags().StringVarP(&resourceQuotaMemory, "resource-quota-memory", "", "", "The Deployment's memory resource quota. Example value: 20Gi")
cmd.Flags().StringVarP(&cloudProvider, "cloud-provider", "p", "gcp", "The Cloud Provider to use for the Deployment. Possible values can be gcp, aws.")
cmd.Flags().StringVarP(&cloudProvider, "cloud-provider", "p", "azure", "The Cloud Provider to use for the Deployment. Possible values can be gcp, aws, azure.")
cmd.Flags().StringVarP(&region, "region", "", "", "The Cloud Provider region to use for the Deployment.")
cmd.Flags().StringVarP(&schedulerSize, "scheduler-size", "", "", "The size of scheduler for the Deployment. Possible values can be small, medium, large, extra_large")
cmd.Flags().StringVarP(&highAvailability, "high-availability", "a", "disable", "Enables High Availability for the Deployment")
Expand Down Expand Up @@ -869,7 +869,7 @@ func isValidExecutor(executor string) bool {

// isValidCloudProvider returns true for valid CloudProvider values and false if not.
func isValidCloudProvider(cloudProvider astrocore.SharedClusterCloudProvider) bool {
return cloudProvider == astrocore.SharedClusterCloudProviderGcp || cloudProvider == astrocore.SharedClusterCloudProviderAws
return cloudProvider == astrocore.SharedClusterCloudProviderGcp || cloudProvider == astrocore.SharedClusterCloudProviderAws || cloudProvider == astrocore.SharedClusterCloudProviderAzure
}

func addDeploymentUser(cmd *cobra.Command, args []string, out io.Writer) error {
Expand Down
10 changes: 7 additions & 3 deletions cmd/cloud/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,10 @@ deployment:
ctx.SetContextKey("workspace", ws)
cmdArgs := []string{
"create", "--name", "test-name", "--workspace-id", ws, "--dag-deploy", "disable",
"--executor", "KubernetesExecutor", "--cloud-provider", "azure",
"--executor", "KubernetesExecutor", "--cloud-provider", "ibm",
}
_, err = execDeploymentCmd(cmdArgs...)
assert.ErrorContains(t, err, "azure is not a valid cloud provider. It can only be gcp")
assert.ErrorContains(t, err, "ibm is not a valid cloud provider. It can only be gcp")
})
t.Run("creates a hosted dedicated deployment", func(t *testing.T) {
ctx, err := context.GetCurrentContext()
Expand Down Expand Up @@ -1445,8 +1445,12 @@ func TestIsValidCloudProvider(t *testing.T) {
actual := isValidCloudProvider("aws")
assert.True(t, actual)
})
t.Run("returns false if cloudProvider is not gcp", func(t *testing.T) {
t.Run("returns true if cloudProvider is azure", func(t *testing.T) {
actual := isValidCloudProvider("azure")
assert.True(t, actual)
})
t.Run("returns false if cloudProvider is not gcp,aws or azure", func(t *testing.T) {
actual := isValidCloudProvider("ibm")
assert.False(t, actual)
})
}
Expand Down

0 comments on commit a5c906a

Please sign in to comment.