Skip to content

feat(license): manage the license in the admin panel; start without one - #31

Open
ngoyal16 wants to merge 1 commit into
mainfrom
feat/license-in-console
Open

ngoyal16 wants to merge 1 commit into
mainfrom
feat/license-in-console

Conversation

@ngoyal16

Copy link
Copy Markdown
Contributor

Summary

First step of "the console is where the system is configured": the license.

Where the key comes from

Before Now
CODEREVIEW_CONSOLE_LICENSE wins wins: an override, e.g. when nobody can sign in. The panel says so.
Admin panel (database) only used when nothing else was set the normal place: install, replace, remove
license.file wins over the panel deprecated: copied into the database once (valid keys only, audited as license.file (initial)), then ignored with a warning. Without a database it's read as before.

Executor licensing no longer blocks startup

  • With executor.type: docker|kubernetes and no executors feature, the console starts and logs an error instead of exiting.
  • A licensedExecutor wrapper refuses each review job with a clear error, and checks per job. A key pasted in the panel applies with no restart.
  • /admin/api/me carries reviews_paused. The panel shows a red banner linking to License, and Setup makes the license step required.
  • check-config still reports the missing feature.

This also resolves the first-start problem from #18: the panel is reachable without a key.

Upgrade note: installs that renew by replacing the license.file Secret should paste the new key in the panel instead. After the first start the file is ignored, and a warning in the log says so.

Testing

  • go test ./... passes.
  • New cmd/console/main_test.go:
    • license.file is copied into an empty database;
    • a panel key wins over the file;
    • the env var overrides and is shown as managed;
    • an invalid file key isn't stored;
    • with no database the file is read;
    • licensedExecutor refuses jobs until a key with executors is installed, then runs, with no restart.
  • New TestReviewsPausedWithoutExecutorLicense: /me and Setup when paused, licensed, and with the local executor.
  • UI typechecks and builds. The banner and License page wording weren't checked in a browser.

🤖 Generated with Claude Code

The panel could only manage a key when neither CODEREVIEW_CONSOLE_LICENSE
nor license.file was set, and the docker and kubernetes executors refused
to start without a license, so a fresh install couldn't reach the panel
to add one.

- The key in the database (the panel) now wins over license.file.
  license.file is deprecated: when the database has no key, a valid key
  from it is copied in once (audited), then ignored with a warning.
  Without a database it is read as before.
- CODEREVIEW_CONSOLE_LICENSE stays as an override (e.g. when nobody can
  sign in) and the panel says so.
- Without the executors feature the console starts anyway. Review jobs
  are refused with a clear error, checked per job, so a key added in the
  panel applies without a restart. The panel shows "reviews are paused"
  and Setup makes the license step required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

1 participant