Repository navigation
postgres create-branch: add --ttl and --no-expiry flags - #6313
Conversation
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
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
|
Asking for a review @andrewnester |
Integration test reportCommit: c16a3d1
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 KNOWN
Top 6 slowest tests (at least 2 minutes):
|
|
|
||
| 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 | ||
|
|
There was a problem hiding this comment.
What happens if you pass something like --json '{\"spec\":{\"ttl\":\"\"}}'?
There was a problem hiding this comment.
The SDK will error out with: Error: invalid character 't' after top-level value
| if len(raw) == 0 { | ||
| return false | ||
| } | ||
| var probe struct { |
There was a problem hiding this comment.
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
- 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>
| @@ -0,0 +1 @@ | |||
| Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required. | |||
There was a problem hiding this comment.
| Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required. | |
| * Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required. |
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
## Release v1.19.0 ### CLI * Honor `CLAUDE_CONFIG_DIR` in `aitools` commands. ([#6838](#6838)) * Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required. ([#6313](#6313)) * `databricks ssh connect` serverless sessions now provide Claude Code and Codex configured with Unity Gateway out of the box. ([#6885](#6885)) ### AI Runtime * Add `databricks air images push` (Preview) to configure Docker authentication and push container images to Databricks Artifact Registry. ([#6869](#6869)) * `air run` now grants the configured `permissions` on the MLflow experiment as well as the job. ([#6870](#6870)) ### Bundles * Add libraries field to clusters. ([#6831](#6831)) * Error out when a configured `workspace_id` does not match the connected workspace, instead of silently using it in resource URLs emitted by `bundle summary`. ([#6754](#6754)) * Fix spurious recreation of Lakebase (Postgres) branches, roles, and catalogs when the referenced project is updated in place: an in-place project change (e.g. `display_name`) no longer forces a delete + create of resources that reference the project's or branch's `name`. ([#6865](#6865)) * Direct engine now detects and applies an explicitly configured integer zero (e.g. `gcp_attributes.local_ssd_count: 0`) added to a resource first deployed without the field. ([#6867](#6867)) * Migrate existing Terraform deployment state to the direct engine before deploying (previously done after a Terraform deploy), so the deploy runs on the direct engine. ([#6749](#6749)) * The `postgres_snapshot_schedules` resource (introduced in [v1.16.0](https://github.com/databricks/cli/releases/tag/v1.16.0)) is now marked Beta and is no longer available in PyDABs, matching the other `postgres_*` resources; configure it in YAML instead. ([#6887](#6887))
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:
New syntax:
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