Skip to content

Commit a62cd2f

Browse files
Fix oss-source pipeline errors when using the Databricks CLI (#3889)
## Changes Removes validation that incorrectly rejected bundles using the `definitions` field in `databricks.yml`. ## Why PR #3797 inadvertently applied validation to reject OSS Spark Declarative Pipelines to all Databricks CLI bundles. This error was only meant for the pipelines CLI. Customers commonly use the `definitions` field for YAML anchors (e.g., to reuse cluster configurations), and this validation blocked their deployments with the error: ``` Error: databricks.yml seems to be formatted for open-source Spark Declarative Pipelines. Pipelines CLI currently only supports Lakeflow Declarative Pipelines development. ``` The validation has been removed entirely. The Pipelines CLI is not yet in active use, and the pipelines team can add a better context-aware check later that only applies when running as the Pipelines CLI. ## Tests - New acceptance test: `acceptance/bundle/validate/definitions_yaml_anchors/` verifies bundles with `definitions` field validate successfully - Existing test: `acceptance/pipelines/deploy/oss-spark-error/` ensures the error continues to work for the pipelines CLI.
1 parent ab4e802 commit a62cd2f

File tree

7 files changed

+69
-28
lines changed

7 files changed

+69
-28
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This test verifies that bundles can use the 'definitions' field for YAML anchors
2+
# without triggering the OSS Spark Pipelines validation error. This was a regression
3+
# patched in https://github.com/databricks/cli/pull/3889
4+
5+
definitions:
6+
common_cluster_settings: &common_cluster_settings
7+
spark_version: "13.3.x-scala2.12"
8+
node_type_id: "i3.xlarge"
9+
num_workers: 2
10+
11+
resources:
12+
jobs:
13+
my_job:
14+
name: "test job with anchors"
15+
tasks:
16+
- task_key: "main"
17+
new_cluster:
18+
<<: *common_cluster_settings
19+
notebook_task:
20+
notebook_path: "/some/notebook"

acceptance/bundle/validate/definitions_yaml_anchors/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
>>> [CLI] bundle validate
3+
Name: test-bundle
4+
Target: default
5+
Workspace:
6+
User: [USERNAME]
7+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
8+
9+
Validation OK!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle validate

bundle/phases/initialize.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package phases
22

33
import (
44
"context"
5-
"errors"
6-
"path/filepath"
75

86
"github.com/databricks/cli/bundle/config/mutator/resourcemutator"
97

@@ -18,9 +16,7 @@ import (
1816
"github.com/databricks/cli/bundle/permissions"
1917
"github.com/databricks/cli/bundle/scripts"
2018
"github.com/databricks/cli/bundle/trampoline"
21-
"github.com/databricks/cli/libs/dyn"
2219
"github.com/databricks/cli/libs/log"
23-
"github.com/databricks/cli/libs/logdiag"
2420
)
2521

2622
// The initialize phase fills in defaults and connects to the workspace.
@@ -29,11 +25,6 @@ import (
2925
func Initialize(ctx context.Context, b *bundle.Bundle) {
3026
log.Info(ctx, "Phase: initialize")
3127

32-
rejectDefinitions(ctx, b)
33-
if logdiag.HasError(ctx) {
34-
return
35-
}
36-
3728
bundle.ApplySeqContext(ctx, b,
3829
// Reads (dynamic): resource.*.*
3930
// Checks that none of resources.<type>.<key> is nil. Raises error otherwise.
@@ -206,17 +197,3 @@ func Initialize(ctx context.Context, b *bundle.Bundle) {
206197
scripts.Execute(config.ScriptPostInit),
207198
)
208199
}
209-
210-
func rejectDefinitions(ctx context.Context, b *bundle.Bundle) {
211-
if b.Config.Definitions != nil {
212-
v := dyn.GetValue(b.Config.Value(), "definitions")
213-
loc := v.Locations()
214-
filename := "input yaml"
215-
if len(loc) > 0 {
216-
filename = filepath.ToSlash(loc[0].File)
217-
}
218-
logdiag.LogError(ctx, errors.New(filename+` seems to be formatted for open-source Spark Declarative Pipelines.
219-
Pipelines CLI currently only supports Lakeflow Declarative Pipelines development.
220-
To see an example of a supported pipelines template, create a new Pipelines CLI project with "pipelines init".`))
221-
}
222-
}

cmd/bundle/utils/process.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package utils
22

33
import (
44
"context"
5+
"errors"
6+
"path/filepath"
57
"time"
68

79
"github.com/databricks/cli/bundle"
@@ -11,6 +13,7 @@ import (
1113
"github.com/databricks/cli/bundle/statemgmt"
1214
"github.com/databricks/cli/cmd/root"
1315
"github.com/databricks/cli/libs/diag"
16+
"github.com/databricks/cli/libs/dyn"
1417
"github.com/databricks/cli/libs/logdiag"
1518
"github.com/databricks/cli/libs/sync"
1619
"github.com/databricks/cli/libs/telemetry/protos"
@@ -56,6 +59,9 @@ type ProcessOptions struct {
5659
Validate bool
5760
Build bool
5861
Deploy bool
62+
63+
// Indicate whether the bundle operation originates from the pipelines CLI
64+
IsPipelinesCLI bool
5965
}
6066

6167
func ProcessBundle(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle, error) {
@@ -166,6 +172,14 @@ func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle,
166172
if logdiag.HasError(ctx) {
167173
return b, isDirectEngine, root.ErrAlreadyPrinted
168174
}
175+
176+
// Pipeline CLI only validation.
177+
if opts.IsPipelinesCLI {
178+
rejectDefinitions(ctx, b)
179+
if logdiag.HasError(ctx) {
180+
return b, isDirectEngine, root.ErrAlreadyPrinted
181+
}
182+
}
169183
}
170184

171185
if opts.Validate {
@@ -210,3 +224,17 @@ func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle,
210224

211225
return b, isDirectEngine, nil
212226
}
227+
228+
func rejectDefinitions(ctx context.Context, b *bundle.Bundle) {
229+
if b.Config.Definitions != nil {
230+
v := dyn.GetValue(b.Config.Value(), "definitions")
231+
loc := v.Locations()
232+
filename := "input yaml"
233+
if len(loc) > 0 {
234+
filename = filepath.ToSlash(loc[0].File)
235+
}
236+
logdiag.LogError(ctx, errors.New(filename+` seems to be formatted for open-source Spark Declarative Pipelines.
237+
Pipelines CLI currently only supports Lakeflow Declarative Pipelines development.
238+
To see an example of a supported pipelines template, create a new Pipelines CLI project with "pipelines init".`))
239+
}
240+
}

cmd/pipelines/deploy.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ func deployCommand() *cobra.Command {
4444
b.Config.Bundle.Deployment.FailOnActiveRuns = failOnActiveRuns
4545
}
4646
},
47-
Verbose: verbose,
48-
AlwaysPull: true,
49-
FastValidate: true,
50-
Build: true,
51-
Deploy: true,
47+
Verbose: verbose,
48+
AlwaysPull: true,
49+
FastValidate: true,
50+
Build: true,
51+
Deploy: true,
52+
IsPipelinesCLI: true,
5253
})
5354
if err != nil {
5455
return err

0 commit comments

Comments
 (0)