Skip to content

Commit 7cc04d8

Browse files
authored
Fix breakglass behavior for jobs in production mode when yaml sync flag is enabled (#4463)
## Changes Fix breakglass behavior for production jobs when `experimentalYamlSyncEnabled` is enabled. ## Why Jobs deployed with this flag enabled are unlocked by default, this behavior is expected only for development mode ## Tests Add unit test, it's not yet possible to run acceptance tests on DBR <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent a93fc07 commit 7cc04d8

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

bundle/deploy/metadata/annotate_jobs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/databricks/cli/bundle"
8+
"github.com/databricks/cli/bundle/config"
89
"github.com/databricks/cli/bundle/env"
910
"github.com/databricks/cli/libs/dbr"
1011
"github.com/databricks/cli/libs/diag"
@@ -30,7 +31,7 @@ func (m *annotateJobs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
3031

3132
isDatabricksWorkspace := dbr.RunsOnRuntime(ctx) && strings.HasPrefix(b.SyncRootPath, "/Workspace/")
3233
_, experimentalYamlSyncEnabled := env.ExperimentalYamlSync(ctx)
33-
if isDatabricksWorkspace && experimentalYamlSyncEnabled {
34+
if isDatabricksWorkspace && experimentalYamlSyncEnabled && b.Config.Bundle.Mode == config.Development {
3435
job.EditMode = jobs.JobEditModeEditable
3536
} else {
3637
job.EditMode = jobs.JobEditModeUiLocked

bundle/deploy/metadata/annotate_jobs_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func TestAnnotateJobsWorkspaceWithFlag(t *testing.T) {
8484
b := &bundle.Bundle{
8585
SyncRootPath: "/Workspace/Users/user@example.com/project",
8686
Config: config.Root{
87+
Bundle: config.Bundle{
88+
Mode: config.Development,
89+
},
8790
Workspace: config.Workspace{
8891
StatePath: "/a/b/c",
8992
},
@@ -110,6 +113,39 @@ func TestAnnotateJobsWorkspaceWithFlag(t *testing.T) {
110113
assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format)
111114
}
112115

116+
func TestAnnotateJobsWorkspaceNonDevelopment(t *testing.T) {
117+
b := &bundle.Bundle{
118+
SyncRootPath: "/Workspace/Users/user@example.com/project",
119+
Config: config.Root{
120+
Bundle: config.Bundle{
121+
Mode: config.Production,
122+
},
123+
Workspace: config.Workspace{
124+
StatePath: "/a/b/c",
125+
},
126+
Resources: config.Resources{
127+
Jobs: map[string]*resources.Job{
128+
"my-job": {
129+
JobSettings: jobs.JobSettings{
130+
Name: "My Job",
131+
},
132+
},
133+
},
134+
},
135+
},
136+
}
137+
138+
ctx := context.Background()
139+
ctx = dbr.MockRuntime(ctx, dbr.Environment{IsDbr: true, Version: "14.0"})
140+
ctx = env.Set(ctx, "DATABRICKS_BUNDLE_ENABLE_EXPERIMENTAL_YAML_SYNC", "1")
141+
142+
diags := AnnotateJobs().Apply(ctx, b)
143+
require.NoError(t, diags.Error())
144+
145+
assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job"].EditMode)
146+
assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format)
147+
}
148+
113149
func TestAnnotateJobsWorkspaceWithoutFlag(t *testing.T) {
114150
b := &bundle.Bundle{
115151
SyncRootPath: "/Workspace/Users/user@example.com/project",

0 commit comments

Comments
 (0)