Skip to content

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

Open
scott-mead-db wants to merge 2 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 2 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

@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: c16a3d161ba03f026010e1c80dc627acbe062edc

Checks will be approved automatically on success.

@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


title "Conflicting flags fail before any API call (no request recorded)"
musterr $CLI postgres create-branch projects/acc-proj branch-conflict --ttl 1h --no-expiry &> LOG.conflict

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.

Could you add a tst when both passed like --no-expiry --json '{\"spec\":{\"no_expiry\":false}}'


title "An expiration is required: no flag fails before any API call (no request recorded)"
musterr $CLI postgres create-branch projects/acc-proj branch-none &> LOG.required

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.

coudl you add a test for `create-branch projects/p b --json 'not json'


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\":\"\"}}'?

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

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