Skip to content

postgres create-branch: add --ttl and --no-expiry flags - #6313

Open
scott-mead-db wants to merge 4 commits into
databricks:mainfrom
scott-mead-db:postgres-create-branch-ttl
Open

postgres create-branch: add --ttl and --no-expiry flags#6313
scott-mead-db wants to merge 4 commits into
databricks:mainfrom
scott-mead-db:postgres-create-branch-ttl

Conversation

@scott-mead-db

@scott-mead-db scott-mead-db commented Aug 18, 2026

Copy link
Copy Markdown

Creating a Lakebase branch requires an expiration (no-expiry is valid, but required). Today, this is not documented and only possible via a --json spec which is unintuitive and creates friction for users.

Previous syntax:

databricks postgres create-branch projects/my-project new-branch-name \
     --json '{"spec": {"no_expiry": true}}'

New syntax:

databricks postgres create-branch projects/my-project new-branch-name --no-expiry
  # or
databricks postgres create-branch projects/my-project new-branch-name --ttl 7d

This PR adds two switches to the databricks postgres create-branch command:

--ttl sets spec.ttl; accepts the REST API form (604800s),
a Go duration (168h), or day/week units (7d, 3w)
--no-expiry sets spec.no_expiry

One of --ttl, --no-expiry, or a spec expiration in --json is required; they are mutually exclusive. The flags are wired through the existing createBranchOverrides hook in a PreRunE that shapes req.Branch.Spec before the generated RunE merges --json and calls the API, so the generated command and the SDK are untouched.

Co-authored-by: Isaac

Setting a branch's expiration on `databricks postgres create-branch`
previously required a hand-written `--json` spec. Add two convenience
flags:

  --ttl <duration>   sets spec.ttl; accepts the REST API form (604800s),
                     a Go duration (168h), or day/week units (7d, 3w)
  --no-expiry        sets spec.no_expiry

One of --ttl, --no-expiry, or a spec expiration in --json is required;
they are mutually exclusive. The flags are wired through the existing
createBranchOverrides hook in a PreRunE that shapes req.Branch.Spec
before the generated RunE merges --json and calls the API, so the
generated command and the SDK are untouched.

Co-authored-by: Isaac
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @janniklasrose -- recent work in .nextchanges/cli/

Eligible reviewers: @andrewnester, @anton-107, @denik, @lennartkats-db, @pietern, @rclarey, @renaudhartert-db, @rugpanov, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

@scott-mead-db

Copy link
Copy Markdown
Author

Asking for a review @andrewnester

@scott-mead-db

Copy link
Copy Markdown
Author

@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: c16a3d1

Run: 32345462596

Env 🟨​KNOWN 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 286 1160 5:14
💚​ aws windows 4 4 288 1158 8:57
💚​ azure linux 4 4 285 1160 5:15
💚​ azure windows 4 4 287 1158 7:23
🟨​ gcp linux 1 1 4 286 1160 8:04
🟨​ gcp windows 1 1 4 288 1158 9:36
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 KNOWN
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 🟨​K 🟨​K
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R
Top 6 slowest tests (at least 2 minutes):
duration env testname
8:48 aws windows TestAccept
7:14 azure windows TestAccept
7:05 gcp windows TestAccept
3:51 aws linux TestAccept
3:50 gcp linux TestAccept
3:46 azure linux TestAccept

Comment thread acceptance/cmd/workspace/postgres/create-branch/script
Comment thread acceptance/cmd/workspace/postgres/create-branch/script

title "the --no-wait path still works alongside --no-expiry"
$CLI postgres create-branch projects/acc-proj branch-nowait --no-expiry --no-wait > LOG.nowait 2>&1

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.

What happens if you pass something like --json '{\"spec\":{\"ttl\":\"\"}}'?

@scott-mead-db scott-mead-db Aug 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The SDK will error out with: Error: invalid character 't' after top-level value

Comment thread cmd/workspace/postgres/overrides.go Outdated
if len(raw) == 0 {
return false
}
var probe struct {

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.

Why a separate type instead of SDK one? This decodes differently from convert.Normalize, and if a future SDK bump renames/retypes a BranchSpec field, neither the compiler nor tests catch the drift which lead to error / unexpected behaviour

scott-mead-db and others added 2 commits August 24, 2026 12:20
- Check for a --json expiration by decoding into the SDK BranchSpec, not a
  hand-rolled struct, so it matches the real decode and won't drift on a rename.
- --no-expiry with a --json that sets spec.no_expiry is now a conflict, not a
  silent override.
- Tests for the conflict, malformed json, and an empty ttl.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 6313
  • Commit SHA: fa135a2805a90d2371d8516dc30a5c91f053f081

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants