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

Fix issues from bug bash #1460

Merged
merged 6 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
64 changes: 38 additions & 26 deletions cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ var (
)

var (
errDagsParseFailed = errors.New("your local DAGs did not parse. Fix the listed errors or use `astro deploy [deployment-id] -f` to force deploy") //nolint:revive
envFileMissing = errors.New("Env file path is incorrect: ") //nolint:revive
errCiCdEnforcementUpdate = errors.New("cannot update dag deploy since ci/cd enforcement is enabled for this deployment. Please use API Tokens or API Keys instead")
errDagsParseFailed = errors.New("your local DAGs did not parse. Fix the listed errors or use `astro deploy [deployment-id] -f` to force deploy") //nolint:revive
envFileMissing = errors.New("Env file path is incorrect: ") //nolint:revive
errCiCdEnforcementUpdate = errors.New("cannot update dag deploy since ci/cd enforcement is enabled for this deployment. Please use API Tokens or API Keys instead")
errImageDeployNoPriorDags = errors.New("cannot do image deploy with no prior DAGs deployed. Please deploy DAGs to your Deployment first")
)

var (
Expand All @@ -83,16 +84,17 @@ var (
)

type deploymentInfo struct {
deploymentID string
namespace string
deployImage string
currentVersion string
organizationID string
workspaceID string
webserverURL string
dagDeployEnabled bool
deploymentType string
cicdEnforcement bool
deploymentID string
namespace string
deployImage string
currentVersion string
organizationID string
workspaceID string
webserverURL string
deploymentType string
desiredDagTarballVersion string
dagDeployEnabled bool
cicdEnforcement bool
}

type InputDeploy struct {
Expand Down Expand Up @@ -232,6 +234,15 @@ func Deploy(deployInput InputDeploy, client astro.Client, coreClient astrocore.C
return nil
}

if deployInput.Image {
if !deployInfo.dagDeployEnabled {
return fmt.Errorf(enableDagDeployMsg, deployInfo.deploymentID) //nolint
}
if deployInfo.desiredDagTarballVersion == "" {
return errImageDeployNoPriorDags
}
}

deploymentURL, err := deployment.GetDeploymentURL(deployInfo.deploymentID, deployInfo.workspaceID)
if err != nil {
return err
Expand Down Expand Up @@ -372,23 +383,12 @@ func Deploy(deployInput InputDeploy, client astro.Client, coreClient astrocore.C
return err
}
} else {
if !deployInfo.dagDeployEnabled {
return fmt.Errorf(enableDagDeployMsg, deployInfo.deploymentID) //nolint
}
fmt.Println("Image Deploy only. Skipping deploying DAG...")
}
}
// finish deploy
if deployInput.Image {
coreDeployment, err := deployment.CoreGetDeployment(deployInfo.workspaceID, deployInfo.organizationID, deployInfo.deploymentID, coreClient)
if err != nil {
return err
}
if coreDeployment.CurrentDagTarballVersion != nil {
dagTarballVersion = *coreDeployment.CurrentDagTarballVersion
} else {
dagTarballVersion = ""
}
dagTarballVersion = deployInfo.desiredDagTarballVersion
}
err = updateDeploy(deployID, deployInfo.deploymentID, deployInfo.organizationID, dagTarballVersion, deployInfo.dagDeployEnabled, coreClient)
if err != nil {
Expand Down Expand Up @@ -430,6 +430,17 @@ func getDeploymentInfo(deploymentID, wsID, deploymentName string, prompt bool, c
if err != nil {
return deploymentInfo{}, err
}
coreDeployment, err := deployment.CoreGetDeployment(currentDeployment.Workspace.ID, currentDeployment.Workspace.OrganizationID, currentDeployment.ID, coreClient)
if err != nil {
return deploymentInfo{}, err
}
var desiredDagTarballVersion string
if coreDeployment.DesiredDagTarballVersion != nil {
desiredDagTarballVersion = *coreDeployment.DesiredDagTarballVersion
} else {
desiredDagTarballVersion = ""
}

return deploymentInfo{
currentDeployment.ID,
currentDeployment.ReleaseName,
Expand All @@ -438,8 +449,9 @@ func getDeploymentInfo(deploymentID, wsID, deploymentName string, prompt bool, c
currentDeployment.Workspace.OrganizationID,
currentDeployment.Workspace.ID,
currentDeployment.DeploymentSpec.Webserver.URL,
currentDeployment.DagDeployEnabled,
currentDeployment.Type,
desiredDagTarballVersion,
currentDeployment.DagDeployEnabled,
currentDeployment.APIKeyOnlyDeployments,
}, nil
}
Expand Down
4 changes: 4 additions & 0 deletions cloud/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ func Update(deploymentID, label, ws, description, deploymentName, dagDeploy, exe
}
}

// determine dagDeploy enabled/disabled
if dagDeploy == "" {
deploymentUpdate.DagDeployEnabled = currentDeployment.DagDeployEnabled
}
if dagDeploy == "enable" {
if currentDeployment.DagDeployEnabled {
fmt.Println("\nDAG deploys are already enabled for this Deployment. Your DAGs will continue to run as scheduled.")
Expand Down