Skip to content
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
6 changes: 3 additions & 3 deletions acceptance/bundle/generate/app_not_yet_deployed/output.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

>>> [CLI] apps create my-app
>>> [CLI] apps create my-app --no-compute --no-wait
{
"app_status": {
"message":"Application is running.",
"state":"RUNNING"
},
"compute_size":"MEDIUM",
"compute_status": {
"message":"App compute is active.",
"state":"ACTIVE"
"message":"App compute is stopped.",
"state":"STOPPED"
},
"id":"1000",
"name":"my-app",
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/generate/app_not_yet_deployed/script
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
trace $CLI apps create my-app
trace $CLI apps create my-app --no-compute --no-wait
trace $CLI bundle generate app --existing-app-name my-app --config-dir . --key out
87 changes: 2 additions & 85 deletions acceptance/bundle/resources/apps/config-drift/out.plan.direct.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
{}
{
"active_deployment": {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

skipping actions with "skip:action" from output as not relevant for the test

"action": "skip",
"reason": "spec:output_only",
"remote": {
"command": [
"streamlit",
"run",
"dashboard.py"
],
"deployment_id": "deploy-[NUMID]",
"env_vars": [
{
"name": "MY_VAR",
"value": "changed_value"
},
{
"name": "NEW_VAR",
"value": "new_value"
}
],
"mode": "SNAPSHOT",
"source_code_path": "./app",
"status": {
"message": "Deployment succeeded",
"state": "SUCCEEDED"
}
}
},
"app_status": {
"action": "skip",
"reason": "spec:output_only",
"remote": {
"message": "Application is running.",
"state": "RUNNING"
}
},
"compute_size": {
"action": "skip",
"reason": "backend_default",
"remote": "MEDIUM"
},
"compute_status": {
"action": "skip",
"reason": "spec:output_only",
"remote": {
"message": "App compute is active.",
"state": "ACTIVE"
}
},
"config.command": {
"action": "update",
"old": [
Expand Down Expand Up @@ -88,41 +40,6 @@
"value": "new_value"
}
]
},
"default_source_code_path": {
"action": "skip",
"reason": "spec:output_only",
"remote": "./app"
},
"id": {
"action": "skip",
"reason": "spec:output_only",
"remote": "1000"
},
"service_principal_client_id": {
"action": "skip",
"reason": "spec:output_only",
"remote": "[UUID]"
},
"service_principal_id": {
"action": "skip",
"reason": "spec:output_only",
"remote": [NUMID]
},
"service_principal_name": {
"action": "skip",
"reason": "spec:output_only",
"remote": "app-[UNIQUE_NAME]"
},
"source_code_path": {
"action": "update",
"old": "/Workspace/Users/[USERNAME]/.bundle/config-drift-[UNIQUE_NAME]/default/files/app",
"new": "/Workspace/Users/[USERNAME]/.bundle/config-drift-[UNIQUE_NAME]/default/files/app",
"remote": "./app"
},
"url": {
"action": "skip",
"reason": "spec:output_only",
"remote": "[UNIQUE_NAME]-123.cloud.databricksapps.com"
}
}
{}

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

23 changes: 4 additions & 19 deletions acceptance/bundle/resources/apps/config-drift/output.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@

=== First deploy: creates app
>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-drift-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Second deploy: pushes code with config
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The fix to deploy on create removes this second deploy which shouldn't be there in the first place and was a sign of the bug

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-drift-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Verify no drift after deploy
>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
>>> [CLI] bundle plan -o json

>>> [CLI] apps get [UNIQUE_NAME] --output json

=== Simulate out-of-band deployment with changed command and env
=== Plan should detect config drift
Expand All @@ -32,15 +25,7 @@ Updating deployment state...
Deployment complete!

=== Verify no drift after fix
>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged

=== Simulate out-of-band deployment with git_source added
=== Plan should detect git_source drift
>>> [CLI] bundle plan
update apps.myapp

Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
>>> [CLI] bundle plan -o json

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
Expand Down
28 changes: 9 additions & 19 deletions acceptance/bundle/resources/apps/config-drift/script
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ cleanup() {
}
trap cleanup EXIT

title "First deploy: creates app"
trace $CLI bundle deploy

title "Second deploy: pushes code with config"
trace $CLI bundle deploy

title "Verify no drift after deploy"
trace $CLI bundle plan
trace $CLI bundle plan -o json | jq '.plan."resources.apps.myapp".changes.config // .plan."resources.apps.myapp".changes' | jq 'del(.[] | select(.action == "skip"))' > out.plan.direct.json

SOURCE_CODE_PATH=$(trace $CLI apps get $UNIQUE_NAME --output json | jq -r '.active_deployment.source_code_path')

title "Simulate out-of-band deployment with changed command and env"
$CLI apps deploy $UNIQUE_NAME --no-wait --json '{
"source_code_path": "./app",
"source_code_path": "'$SOURCE_CODE_PATH'",
"mode": "SNAPSHOT",
"command": ["streamlit", "run", "dashboard.py"],
"env_vars": [
Expand All @@ -28,22 +26,14 @@ $CLI apps deploy $UNIQUE_NAME --no-wait --json '{

title "Plan should detect config drift"
trace $CLI bundle plan
$CLI bundle plan -o json | jq '.plan."resources.apps.myapp".changes.config // .plan."resources.apps.myapp".changes' > out.plan.direct.json
# Skip entries with action "skip"
$CLI bundle plan -o json | jq '.plan."resources.apps.myapp".changes.config // .plan."resources.apps.myapp".changes' | jq 'del(.[] | select(.action == "skip"))' >> out.plan.direct.json

title "Redeploy to fix drift"
trace $CLI bundle deploy

title "Verify no drift after fix"
trace $CLI bundle plan
trace $CLI bundle plan -o json | jq '.plan."resources.apps.myapp".changes.config // .plan."resources.apps.myapp".changes' | jq 'del(.[] | select(.action == "skip"))' >> out.plan.direct.json

title "Simulate out-of-band deployment with git_source added"
$CLI apps deploy $UNIQUE_NAME --no-wait --json '{
"source_code_path": "./app",
"mode": "SNAPSHOT",
"git_source": {"branch": "feature-branch"},
"command": ["python", "app.py"],
"env_vars": [{"name": "MY_VAR", "value": "original_value"}]
}' > /dev/null

title "Plan should detect git_source drift"
trace $CLI bundle plan
# TODO: add test for git_source drift when git_source is supported in the Deploy API
# Currently it fails with the error: Git source reference is required
2 changes: 1 addition & 1 deletion acceptance/bundle/resources/apps/config-drift/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Local = true
Cloud = true
Cloud = false # This currently fails on Cloud due to incorrect API behaviour.
RecordRequests = true

Ignore = [".databricks", "databricks.yml"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

>>> [CLI] apps create test-app-already-exists
{
"active_deployment": {
"deployment_id":"deploy-[NUMID]",
"source_code_path":"/Workspace/Users/[USERNAME]/test-app-already-exists",
"status": {
"message":"Deployment succeeded",
"state":"SUCCEEDED"
}
},
"app_status": {
"message":"Application is running.",
"state":"RUNNING"
Expand All @@ -10,6 +18,7 @@
"message":"App compute is active.",
"state":"ACTIVE"
},
"default_source_code_path":"/Workspace/Users/[USERNAME]/test-app-already-exists",
"id":"1000",
"name":"test-app-already-exists",
"service_principal_client_id":"[UUID]",
Expand Down
8 changes: 8 additions & 0 deletions acceptance/bundle/resources/apps/lifecycle-started/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Deployment complete!
"name": "[UNIQUE_NAME]"
}
}
{
"method": "POST",
"path": "/api/2.0/apps/[UNIQUE_NAME]/deployments",
"body": {
"mode": "SNAPSHOT",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/lifecycle-started-[UNIQUE_NAME]/default/files/app"
}
}

>>> errcode [CLI] apps get [UNIQUE_NAME]
"ACTIVE"
Expand Down
18 changes: 18 additions & 0 deletions acceptance/cmd/workspace/apps/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
=== Apps create with correct input
>>> [CLI] apps create --json @input.json
{
"active_deployment": {
"deployment_id":"deploy-[NUMID]",
"source_code_path":"/Workspace/Users/[USERNAME]/test-name",
"status": {
"message":"Deployment succeeded",
"state":"SUCCEEDED"
}
},
"app_status": {
"message":"Application is running.",
"state":"RUNNING"
Expand All @@ -11,6 +19,7 @@
"message":"App compute is active.",
"state":"ACTIVE"
},
"default_source_code_path":"/Workspace/Users/[USERNAME]/test-name",
"description":"My app description.",
"id":"1000",
"name":"test-name",
Expand All @@ -34,6 +43,14 @@
=== Apps update with correct input
>>> [CLI] apps update test-name --json @input.json
{
"active_deployment": {
"deployment_id":"deploy-[NUMID]",
"source_code_path":"/Workspace/Users/[USERNAME]/test-name",
"status": {
"message":"Deployment succeeded",
"state":"SUCCEEDED"
}
},
"app_status": {
"message":"Application is running.",
"state":"RUNNING"
Expand All @@ -43,6 +60,7 @@
"message":"App compute is active.",
"state":"ACTIVE"
},
"default_source_code_path":"/Workspace/Users/[USERNAME]/test-name",
"description":"My app description.",
"id":"1001",
"name":"test-name",
Expand Down
4 changes: 4 additions & 0 deletions bundle/appdeploy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func logProgress(ctx context.Context, msg string) {

// BuildDeployment constructs an AppDeployment from the app's source code path, inline config and git source.
func BuildDeployment(sourcePath string, config *resources.AppConfig, gitSource *sdkapps.GitSource) sdkapps.AppDeployment {
// GitRepository is not supported in the Deploy API, only as part of Create, so we need to remove it.
if gitSource != nil {
gitSource.GitRepository = nil
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That sounds asymmetric. Known issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, GitRepository is part of only Create and you can't change it as part of Deploy

deployment := sdkapps.AppDeployment{
Mode: sdkapps.AppDeploymentModeSnapshot,
SourceCodePath: sourcePath,
Expand Down
Loading