Skip to content

Prevent deleting a silo's last certificate - #11510

Merged
david-crespo merged 1 commit into
mainfrom
keep-last-silo-cert
Nov 3, 2026
Merged

david-crespo merged 1 commit into
mainfrom
keep-last-silo-cert

Conversation

@david-crespo

Copy link
Copy Markdown
Contributor

Closes #11272

Deleting a silo's only certificate leaves Nexus unable to serve TLS for the silo's domain, so nobody in the silo can reach the API to upload a replacement. #11470 mitigates this by making it so fleet admins can fix this from a different silo, but it can still be a problem if it happens to the fleet admins' own silo.

This PR makes certificate_delete error out unless another certificate exists for the same silo. The check is an EXISTS subquery in the same UPDATE that sets time_deleted, avoiding a TOCTOU race that would let two concurrent deletes on the last two certs both succeed. (#11109 does the same thing for unassigning a service's last IP pool.)

The error is a 400. 409 could make sense, but 400 is the convention for refusing to delete; it's what we do for non-empty projects and silos, VPCs with subnets, IP pools with ranges, attached floating IPs and disks, etc.

@smklein

smklein commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

as an FYI, you may also be interested in #11238, which overlaps here

@david-crespo

Copy link
Copy Markdown
Contributor Author

Saw it — am I right that they're complementary and don't conflict?

@smklein

smklein commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Saw it — am I right that they're complementary and don't conflict?

I believe that's the case! If anything I might be able to make the guarantees in the diagnosis engine a little stronger with this PR

@david-crespo

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@sudomateo sudomateo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this locally using the API, CLI, and Terraform and it works as expected. I expect most Terraform users will create the silo using oxide_system_silo, which creates the first certificate. Then, they would use oxide_system_certificate to rotate the certificate which would put them at 2 total certificates. Then, future rotatations would delete/create the 2nd certificate, leaving the 1st always there as a fallback. This is all to say that I don't see the Terraform users hitting this "delete last certificate" error and I confirmed this all works as expected, so approved!

@david-crespo
david-crespo merged commit 8ec9af4 into main Nov 3, 2026
19 checks passed
@david-crespo
david-crespo deleted the keep-last-silo-cert branch November 3, 2026 16:34
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.

Prevent last working TLS certificate from being deleted

3 participants