-
Notifications
You must be signed in to change notification settings - Fork 57
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
Added support for Databricks Apps in DABs #1928
base: main
Are you sure you want to change the base?
Conversation
bc4c9ac
to
d72b03e
Compare
320b408
to
e9e0566
Compare
## Changes Added support for bundle generate and bind for Apps ## Tests - [ ] Add E2E test
Test Details: go/deco-tests/12394072048 |
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
diags := bundle.Apply(context.Background(), b, InterpolateVariables()) | ||
require.Empty(t, diags) | ||
require.Equal(t, []any([]any{map[string]any{"name": "JOB_ID", "value": "123"}}), b.Config.Resources.Apps["my_app_1"].Config["env"]) | ||
require.Nil(t, b.Config.Resources.Apps["my_app_2"].Config) |
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 test works but doesn't actually use the translation map.
I suspect you intend to make sure that the conversion of bundle-internal field references to Terraform resource field references is undone so that we can interpolate the IDs ourselves. But the test runs against a bundle-internal field reference.
Is there an alternative approach such that we don't have to convert back-and-forth? Maybe we completely skip this path during variable resolution? Or only skip resources.*
references under resources.apps.*.config.**
? Then we have less coupling with the TF resource interpolation.
var diags diag.Diagnostics | ||
errGroup, ctx := errgroup.WithContext(ctx) | ||
|
||
mu := &sync.Mutex{} |
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.
Doesn't need to be a pointer, can be a regular value.
// It means we need to write app.yml file with the content of the config field | ||
// to the remote source code path of the app. | ||
if app.Config != nil { | ||
if !strings.HasPrefix(app.SourceCodePath, b.Config.Workspace.FilePath) { |
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.
Do we check this during validation as well?
return diag.FromErr(err) | ||
} | ||
|
||
// When the app is started, create a new app deployment and wait for it to complete. |
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.
Comment doesn't make sense here.
diags = append(diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "Duplicate app source code path", | ||
Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s'", key, usedSourceCodePaths[app.SourceCodePath]), |
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 should include why it is not allowed.
AFAICT it is because it causes a conflict on app.yml
.
usedSourceCodePaths[app.SourceCodePath] = key | ||
|
||
for _, configFile := range possibleConfigFiles { | ||
cf := path.Join(app.SourceCodePath, configFile) |
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 this guaranteed to be relative?
} | ||
|
||
func (a *App) InitializeURL(baseURL url.URL) { | ||
if a.Name == "" { |
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.
Discussed earlier; now that we don't have an ID, this will return an URL even if the app isn't deployed yet.
(confirmed this is the case with the latest build)
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.
You could use the ModifiedStatus
here.
@@ -34,6 +34,7 @@ type stateResourceInstance struct { | |||
|
|||
type stateInstanceAttributes struct { | |||
ID string `json:"id"` | |||
Name string `json:"name,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.
Can you call out that this is specifically for apps?
Other resources with a "name" will also see this field populated.
PLACEHOLDER | ||
"name": | ||
"description": |- | ||
PLACEHOLDER |
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.
Please run make schema
with a path to the OpenAPI spec configured. I suspect these will show up in the OpenAPI annotations file instead and be non-empty. The apps API surface is documented.
cc @ilyakuz-db
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.
That's correct, using genkit should also make the trick
I'll take a look how to make it more clear what to run if new fields were added. Looks like it should be possible to just filter annotations by package
|
||
// Try to run the app | ||
_, out := runResourceWithStderr(t, ctx, root, "test_app") | ||
require.Contains(t, out, app.Url) |
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.
How long does this take? Might be a candidate for testing.Short
(ref: #2024).
Changes
Now it's possible to configure new
app
resource in bundle and point it to the customsource_code_path
location where Databricks App code is defined.On
databricks bundle deploy
DABs will create an app. All consecutivedatabricks bundle deploy
execution will update an existing app if there are any updatedOn
databricks bundle run <my_app>
DABs will execute app deployment. If the app is not started yet, it will start the app first.Bundle configuration
Execution
databricks bundle deploy -t dev
databricks bundle run my_app -t dev
If app is started
If app is not started
Tests
Added unit and config tests + manual test.