Skip to content

Prevent deleting a silo's last certificate - #11510

Open
david-crespo wants to merge 1 commit into
mainfrom
keep-last-silo-cert
Open

david-crespo wants to merge 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.

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.

Prevent last working TLS certificate from being deleted

2 participants