Skip to content

Import existing pgEdge Starfleet databases and branches as servers. - #10920

Draft
AntTheLimey wants to merge 4 commits into
pgadmin-org:masterfrom
AntTheLimey:feat/starfleet-import-servers
Draft

AntTheLimey wants to merge 4 commits into
pgadmin-org:masterfrom
AntTheLimey:feat/starfleet-import-servers

Conversation

@AntTheLimey

Copy link
Copy Markdown

Depends on #10832, and is built on its branch: until that merges, its three commits show here too. Review only the last commit.

What changed

Adds Import from pgEdge Starfleet... to the server group menu. The dialog signs in with #10832's credentials form (pgEdge account or API client), lists the tenant's databases and branches with whether this address can reach them, and adds or updates a server for each one chosen. It can also save the password, subject to ALLOW_SAVE_PASSWORD, and add this address to a database's allowlist. Closing the dialog signs out and revokes the refresh token, as the wizard does.

Shared code touched: _with_client gains an opt-in 401 mode for the dialog (the wizard keeps its behaviour), signin_options also returns allow_save_password, and StarfleetClient gains patch().

Gates

  • regression/runtests.py --pkg misc.cloud.starfleet: 7 passed, 0 failed
  • jest regression/javascript/misc/cloud: 42 passed
  • eslint -c .eslintrc.js and pycodestyle on the changed files: clean
  • Docs build: no new warnings

An independent review found two defects: the refresh token was not revoked on close, and sign-in errors were not shown. Both are fixed, with tests.

Risks

  • The dialog and the deployment wizard share the Starfleet session, so signing in through one while the other is open signs the other out.
  • Not yet tried against the real service.

dpage and others added 4 commits November 25, 2026 10:37
…t credentials rather than a pgEdge account sign-in. pgadmin-org#10746

The Starfleet deployment wizard now lets the user choose between signing
in with their pgEdge account and entering API client credentials.

Sign-in uses the OAuth 2.0 device authorization grant (RFC 8628) against
the pgEdge Auth0 tenant. pgAdmin requests a device code and shows the
user code and sign-in link; the browser then polls a pgAdmin endpoint
that makes at most one token request per call and honours the interval
and slow_down responses, so no request thread waits on the user. The
tokens stay in the server-side session, and the user chooses a tenant
when the account has more than one; requests then carry the
X-pgEdge-Selected-Tenant header.

The deployment job receives the access token, and the refresh token
where there is one, through its environment in the same way as the API
client secret, never on its command line. The refresh token goes to the
job alone, as Auth0 rotates it on use, and the job revokes it when it
finishes; an unused one is revoked when the wizard's session is cleared.

The Auth0 applications are configured per Starfleet API URL in
STARFLEET_AUTH0_APPS in config.py.

Closes pgadmin-org#10746
…efresh token in the session until the deployment job has started.
Add an Import from pgEdge Starfleet... option to the server group menu.
It signs in the same way as the deployment wizard, lists the tenant's
databases and branches with whether this address can reach them, and
adds or updates a server for each one chosen, optionally saving the
password and adding this address to a database's allowlist.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dpage dpage left a comment

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.

I've reviewed only the last commit (75685a7), as asked. Overall it's in good shape: the request validation is careful (the server group belongs to the user, IDs are checked before they go into API paths, and the item count is capped), passwords stay out of responses and logs, and the allowlist update rebuilds the rules from their documented fields. I checked the API calls against the managed API spec, and the user_type values, bare-address CIDRs and replace-on-PATCH behaviour all match it. The backend tests pass locally (7/7). One thing should be fixed before this goes in:

Should fix: importing an item that has no connection details reports "Unexpected response from pgEdge Starfleet." (web/pgadmin/misc/cloud/starfleet/inventory.py:149)

_connection() indexes detail['connection'], so a missing connection raises KeyError, which the MALFORMED handler at line 223 turns into the generic message. According to the API spec, this is a normal response rather than a malformed one in two cases:

  • A branch's connection "is present only while the branch is available", and the same goes for a database that is still being created or is failed.
  • application_read_only "is the read-only role the AI services connect as; a database created before it existed does not have one".

The dialog makes the first case likely, because loadInventory pre-selects every reachable item whatever its status (StarfleetImportDialog.jsx:91), so a reachable database that is still creating is ticked by default and then fails with a message that gives the user nothing to act on. I'd suggest two changes: check for the connection explicitly and give a message that names the item's status, or says the chosen role may not exist on that database; and pre-select only items whose status is available. A test for an item without a connection would cover both.

Suggestion: re-importing renames a server the user has renamed (inventory.py:116)

upsert_server sets server.name on every import, so a user who renamed an imported server, or added a server by hand with the same host, port and user name, gets the Starfleet label back. Keeping the existing name when updating seems kinder; the connection details are what actually need refreshing.

Suggestion: the allowlist message could say the change is not immediate (inventory.py:191)

The spec says an allowlist change moves the database to modifying while the rules are pushed to the ingress, so "Added {0} to the database's allowlist." can show before the address is actually admitted, and an immediate connection attempt may fail. Something like "Added {0} to the database's allowlist; it takes effect once the database is available again." would head off that confusion.

This branch has not been deployed

No deployments
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.

2 participants