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 workload identity to hosted deployment #1708

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions astro-client-core/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions cloud/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ const (
)

var (
sleepTime = 180
tickNum = 10
timeoutNum = 180
listLimit = 1000
dedicatedDeploymentRequest = astroplatformcore.UpdateDedicatedDeploymentRequest{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped the global variable, this makes no difference from CLI functionality pov, but it messes up the unit tests, since the global variables are shared

dagDeployEnabled bool
sleepTime = 180
tickNum = 10
timeoutNum = 180
listLimit = 1000
dagDeployEnabled bool
)

func newTableOut() *printutil.Table {
Expand Down Expand Up @@ -135,6 +134,7 @@ func List(ws string, fromAllWorkspaces bool, platformCoreClient astroplatformcor
return nil
}

// TODO (https://github.com/astronomer/astro-cli/issues/1709): move these input arguments to a struct, and drop the nolint
func Logs(deploymentID, ws, deploymentName, keyword string, logWebserver, logScheduler, logTriggerer, logWorkers, warnLogs, errorLogs, infoLogs bool, logCount int, platformCoreClient astroplatformcore.CoreClient, coreClient astrocore.CoreClient) error {
var logLevel string
var i int
Expand Down Expand Up @@ -212,6 +212,7 @@ func Logs(deploymentID, ws, deploymentName, keyword string, logWebserver, logSch
return nil
}

// TODO (https://github.com/astronomer/astro-cli/issues/1709): move these input arguments to a struct, and drop the nolint
func Create(name, workspaceID, description, clusterID, runtimeVersion, dagDeploy, executor, cloudProvider, region, schedulerSize, highAvailability, developmentMode, cicdEnforcement, defaultTaskPodCpu, defaultTaskPodMemory, resourceQuotaCpu, resourceQuotaMemory, workloadIdentity string, deploymentType astroplatformcore.DeploymentType, schedulerAU, schedulerReplicas int, platformCoreClient astroplatformcore.CoreClient, coreClient astrocore.CoreClient, waitForStatus bool) error { //nolint
var organizationID string
var currentWorkspace astrocore.Workspace
Expand Down Expand Up @@ -325,6 +326,10 @@ func Create(name, workspaceID, description, clusterID, runtimeVersion, dagDeploy
if resourceQuotaMemory == "" {
resourceQuotaMemory = configOption.ResourceQuotas.ResourceQuota.Memory.Default
}
var deplWorkloadIdentity *string
if workloadIdentity != "" {
deplWorkloadIdentity = &workloadIdentity
}
// build standard input
if IsDeploymentStandard(deploymentType) {
var requestedCloudProvider astroplatformcore.CreateStandardDeploymentRequestCloudProvider
Expand Down Expand Up @@ -360,6 +365,7 @@ func Create(name, workspaceID, description, clusterID, runtimeVersion, dagDeploy
DefaultTaskPodMemory: defaultTaskPodMemory,
ResourceQuotaCpu: resourceQuotaCpu,
ResourceQuotaMemory: resourceQuotaMemory,
WorkloadIdentity: deplWorkloadIdentity,
}
if strings.EqualFold(executor, CeleryExecutor) || strings.EqualFold(executor, CELERY) {
standardDeploymentRequest.WorkerQueues = &defautWorkerQueue
Expand Down Expand Up @@ -409,6 +415,7 @@ func Create(name, workspaceID, description, clusterID, runtimeVersion, dagDeploy
DefaultTaskPodMemory: defaultTaskPodMemory,
ResourceQuotaCpu: resourceQuotaCpu,
ResourceQuotaMemory: resourceQuotaMemory,
WorkloadIdentity: deplWorkloadIdentity,
}
if strings.EqualFold(executor, CeleryExecutor) || strings.EqualFold(executor, CELERY) {
dedicatedDeploymentRequest.WorkerQueues = &defautWorkerQueue
Expand Down Expand Up @@ -738,6 +745,7 @@ func HealthPoll(deploymentID, ws string, sleepTime, tickNum, timeoutNum int, pla
}
}

// TODO (https://github.com/astronomer/astro-cli/issues/1709): move these input arguments to a struct, and drop the nolint
func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, executor, schedulerSize, highAvailability, developmentMode, cicdEnforcement, defaultTaskPodCpu, defaultTaskPodMemory, resourceQuotaCpu, resourceQuotaMemory, workloadIdentity string, schedulerAU, schedulerReplicas int, wQueueList []astroplatformcore.WorkerQueueRequest, hybridQueueList []astroplatformcore.HybridWorkerQueueRequest, newEnvironmentVariables []astroplatformcore.DeploymentEnvironmentVariableRequest, force bool, coreClient astrocore.CoreClient, platformCoreClient astroplatformcore.CoreClient) error { //nolint
var queueCreateUpdate, confirmWithUser bool
// get deployment
Expand Down Expand Up @@ -911,6 +919,10 @@ func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, exec
if resourceQuotaMemory == "" {
resourceQuotaMemory = *currentDeployment.ResourceQuotaMemory
}
var deplWorkloadIdentity *string
if workloadIdentity != "" {
deplWorkloadIdentity = &workloadIdentity
}
if IsDeploymentStandard(*currentDeployment.Type) {
var requestedExecutor astroplatformcore.UpdateStandardDeploymentRequestExecutor
switch strings.ToUpper(executor) {
Expand Down Expand Up @@ -941,6 +953,7 @@ func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, exec
EnvironmentVariables: deploymentEnvironmentVariablesRequest,
DefaultTaskPodCpu: defaultTaskPodCpu,
DefaultTaskPodMemory: defaultTaskPodMemory,
WorkloadIdentity: deplWorkloadIdentity,
}
switch schedulerSize {
case strings.ToLower(string(astrocore.CreateStandardDeploymentRequestSchedulerSizeSMALL)):
Expand Down Expand Up @@ -988,7 +1001,7 @@ func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, exec
case strings.ToUpper(KUBERNETES):
requestedExecutor = astroplatformcore.UpdateDedicatedDeploymentRequestExecutorKUBERNETES
}
dedicatedDeploymentRequest = astroplatformcore.UpdateDedicatedDeploymentRequest{
dedicatedDeploymentRequest := astroplatformcore.UpdateDedicatedDeploymentRequest{
Description: &description,
Name: name,
Executor: requestedExecutor,
Expand All @@ -1004,6 +1017,7 @@ func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, exec
ResourceQuotaMemory: resourceQuotaMemory,
EnvironmentVariables: deploymentEnvironmentVariablesRequest,
WorkerQueues: &workerQueuesRequest,
WorkloadIdentity: deplWorkloadIdentity,
}
switch schedulerSize {
case strings.ToLower(string(astrocore.CreateStandardDeploymentRequestSchedulerSizeSMALL)):
Expand Down
Loading