Skip to content

token-vendor: let public-key.publish name the owning Robot - #1000

Open
drigz wants to merge 1 commit into
mainfrom
spr/drigz/token-vendor-let-public-keypublish-name-the-owning-robot
Open

drigz wants to merge 1 commit into
mainfrom
spr/drigz/token-vendor-let-public-keypublish-name-the-owning-robot

Conversation

@drigz

@drigz drigz commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Since #978, token-vendor gives a key's ConfigMap an owner reference to the
Robot CR derived from its device ID (robot-), so the key is deleted
along with the Robot. This doesn't work when the device ID doesn't match a
Robot CR. For example, you might publish a key for
robot- so that a new robot can fetch its config, but also publish
a key robot-. No Robot called
ever exists, so the ConfigMap never gets an owner and leaks.

Add an optional robot-name parameter to public-key.publish to name the
owning Robot CR explicitly. It's stored in the cloudrobotics.com/robot-name
label, and the ConfigMap informer indexes keys by their owner's name, so the
owner reference is also set if the Robot CR is created after the key is
published.

Callers that don't pass robot-name keep the current behavior.

Only tested via unit tests, I'm planning to test the client against the nightly
so might need to follow up to fix this.

Alternative considered: The client could also patch the created ConfigMap
after calling into the token-vendor, but that couples the client to the backend
representation.

TAG=agy
CONV=4b9dee19-63da-4d08-af67-f0eebad7d73c

Since #978, token-vendor gives a key's ConfigMap an owner reference to the
Robot CR derived from its device ID (robot-<name>), so the key is deleted
along with the Robot. This doesn't work when the device ID doesn't match a
Robot CR. For example, the device-manager publishes a bootstrap key as
robot-node-<uuid> so that a new node can fetch its config, but the node can
join a cluster with a different name (eg vmpool's vmp-...). No Robot called
node-<uuid> ever exists, so the ConfigMap never gets an owner and leaks.

Add an optional robot-name parameter to public-key.publish to name the
owning Robot CR explicitly. It's stored in the cloudrobotics.com/robot-name
label, and the ConfigMap informer indexes keys by their owner's name, so the
owner reference is also set if the Robot CR is created after the key is
published.

Callers that don't pass robot-name keep the current behavior. The
device-manager will start passing it once this is rolled out.

TAG=agy
CONV=4b9dee19-63da-4d08-af67-f0eebad7d73c


Created using jj-spr
@drigz

drigz commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

This PR is a standalone change.

@drigz
drigz requested a review from ensonic September 23, 2026 15:39
return nil
}
// TODO(rodrigoq): The cache can be stale if the Robot CR was just deleted
// and re-created, eg when the device-manager replaces a cluster. Then the

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.

Can where phase this more genericly?

}

// A key can be owned by a Robot CR that doesn't match its device ID, eg when a
// device registers as robot-node-<uuid> but joins a cluster with another name.

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.

tbh, I don't understand the "but joins a cluster with another name" part.

deleted when the Robot CR is deleted. Defaults to the device-id without the
robot- prefix. Set this if the device-id doesn't match a Robot CR, eg for a
device that registers under its node name but joins a cluster with another
name.

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.

Same here - "joins a cluster with another name" sounds like multi-node cluster related, but in that case we would not register a new key for the additional nodes, right.

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