Rename this server in Dagu Console from Dagu

Merged
YO
25d ago
+2090-1072

Summary

Dagu Console showed a connected server only by the name it reports (license.server_name, else the hostname, e.g. s-macbook-pro.taild5c75a.ts.net), and changing it took a config edit, a restart, and up to an hour.

  • License page: the Server row on Plan & features gets a Rename button for a server that checks in with Dagu Console. Once renamed, it shows the name the server reports beside the new one. Saving an empty name returns to the reported name.
  • API: PUT /api/v1/license/server-name (admin only, also through remote nodes) sends the name to Dagu Console and returns the license status. It refuses names over 100 characters and licenses that never check in, and explains a refusal by Dagu Console. Each rename is audited as license_server_rename.
  • License status: serverName is now the name Dagu Console shows, read from the license token's new server_name claim; the new reportedName is the name the server reports. Without the claim (older Console), serverName stays the reported name.

Dagu Console keeps the name, so there is one source for it. Owners can also rename a server on its Settings tab in the console, and check-ins no longer overwrite a name a person gave. The console side (POST /api/v1/licenses/rename and the server_name claim) is already deployed.

Docs: https://github.com/dagucloud/docs/pull/46

Testing

  • internal/license: client request/response, rename applies and saves the returned token without counting as a check-in, empty name clears, length limit counts characters, Console refusal keeps the license, 404 from an older Console, licenses that never check in.
  • internal/service/frontend/api/v1: rename through a fake Console, refusal message, unreachable Console (502), name too long, no check-in, admin-only, audit entry.
  • UI: rename flow, prefill with a given name, error keeps the form open, no rename without check-in.
  • make check, make test for the touched packages, pnpm test, pnpm typecheck, pnpm build.

Summary by cubic

Lets you rename this server in Dagu Console from the Plan & features page, so the console no longer shows only the cryptic hostname the server reports.

  • The Server row gets a Rename button for servers that check in; a renamed server shows its new name beside the reported one, and clearing the name returns to the reported one.
  • PUT /api/v1/license/server-name (admin only) sends the name to Dagu Console, refuses names over 100 characters, explains a refusal by Dagu Console, and is audited as license_server_rename.
  • License status now returns the console's name as serverName and the reported name as reportedName; without a server_name claim, serverName falls back to the reported name.

Summary by CodeRabbit

  • New Features
    • Added an option to rename the server shown in license details. Names can be up to 100 characters; leaving the field empty uses the server’s reported name.
    • License details now distinguish the chosen display name from the name reported by the server.
  • Bug Fixes
    • Server-name updates now preserve the existing license check-in time.