Repository navigation
Restrict daemon reading the pull secret from a merged secret (manual backport 278) - #307
Merged
Merged
Conversation
The tag resolver looked up credentials with an exact match of the registry host in the auths map. Entries written by kubectl create secret docker-registry and docker login use other forms, most commonly https://index.docker.io/v1/ for Docker Hub. Those missed, the resolver silently fell back to anonymous access and tag resolution failed with 401, while the node's container runtime accepted the same secret. Compare keys the way containers/image does for auth files: strip the http(s):// scheme, drop the path when a scheme was present, and map docker.io and registry-1.docker.io to index.docker.io. An exact match still wins, and normalized keys are tried in sorted order so the result is deterministic. Scoped keys without a scheme, such as quay.io/org, are still not matched; the resolver looks up registries only. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit a118d6c)
The daemon will read pull secrets from a single Secret maintained by the controller and mounted into the DaemonSet, with one key per source secret. The new internal/pullsecret package holds the Secret name, the daemon mount directory and the key function, "<namespace>_<name>", so the controller and the daemon cannot drift. A namespace and a Secret name together can exceed the 253-character Secret key limit, and one invalid key would make the API server reject the whole aggregated Secret. Key returns an error in that case, and fetchPullSecretData reports it on the pool as SecretError. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit dd78c7e)
The pool reconciler required a .dockerconfigjson key and passed its
bytes unchanged to the tag resolver and, via the aggregated Secret, to
bootc. Both expect the {"auths": ...} wrapper. A legacy .dockercfg
Secret, which holds the bare auths map and which OpenShift generates for
service accounts, was rejected as missing a key; had it been passed
through, it would have meant silently no credentials.
Add pullsecret.AuthData, which returns the credentials in
.dockerconfigjson format. It goes by the Secret's keys rather than its
type, so an Opaque Secret works too. .dockerconfigjson is returned as
is and wins when both keys are set. .dockercfg is wrapped in
{"auths": ...} without re-encoding its entries, so fields such as
identitytoken and the credential bytes are preserved. Data that is not
a JSON object, including an empty .dockerconfigjson, is reported with
the key name but never with its content. fetchPullSecretData uses it, so
the reconciler normalizes once and the daemon keeps copying bytes
verbatim.
Assisted-by: AI
Signed-off-by: Alice Frosi <afrosi@redhat.com>
(cherry picked from commit fe0d577)
The pool reconciler decided which Secret events to act on by type, accepting only kubernetes.io/dockerconfigjson. That ignored events for the other forms of pull secret that fetchPullSecretData accepts, such as legacy .dockercfg and Opaque Secrets carrying a .dockerconfigjson key, so rotating them was never noticed. Matching on type is also not meaningful for a Secret that is not referenced by any pool, and the mapper listed every pool on each Secret event to find out. Index BootcNodePool by spec.pullSecretRef and map a Secret event to the pools in that index. A referenced Secret now triggers a reconcile whatever its type or content, so data that becomes valid or invalid is always seen, and Secrets no pool references enqueue nothing. The Secret type is immutable, so type changes need no handling. The field index is registered once per manager, in main and in the envtest suite, since a manager rejects duplicate registrations. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit 3bad2ff)
The daemon will stop reading pull secrets through the API and read them from a Secret mounted into the DaemonSet instead. The new PullSecretAggregator maintains that Secret, bootc-pull-secrets in the operator namespace, with one key per source secret referenced by a pool, holding its credentials normalized to .dockerconfigjson format. It lives in internal/pullsecret, next to the key function and the constants it shares with the daemon, so the reconciler and the key format cannot drift apart. It is the Secret's only writer, so pool reconciles cannot conflict on it. Pool, referenced source secret and bootc-pull-secrets events all map to one request, found through the pool index, and each reconcile recomputes the data from scratch, so stale keys disappear and a deleted or edited Secret is repaired. References the pool reconciler reports as SecretError are skipped. The aggregator also reconciles once at startup, so the Secret exists whenever the controller runs; it is kept, with no keys, when no pool references a pull secret. The controller needs create on secrets in its namespace, and update and patch on bootc-pull-secrets only. It now requires the operator namespace to be known, since that is where the Secret lives. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit 359ee69)
The DaemonSet now mounts bootc-pull-secrets, maintained by the controller, at /var/run/bootc-pull-secrets. The volume is optional, as the daemon may start before the Secret exists, and uses no subPath, so the kubelet keeps it up to date. While an update is pending, before staging, syncPullSecret copies the entry for the node's pullSecretRef to /run/ostree/auth.json instead of fetching the Secret through the API. Without a reference or a readable entry, it now removes the auth file instead of leaving stale credentials behind, and bootc falls back to /etc or /usr/lib. A missing entry needs no special handling: the kubelet may take a minute to sync a new or rotated Secret, and a failed stage is retried with backoff and re-reads the file. The daemon tests now use temporary directories for the host root and the mount, so they never touch the real /run/ostree. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit c8eda7b)
The daemon reads pull secrets from the mounted bootc-pull-secrets Secret, so it no longer needs to get Secrets through the API. Remove the rule from its ClusterRole, which allowed every node to read any Secret in the cluster, and the now unused APIReader. The kubelet still reads the mounted Secret: the node authorizer allows a node to read Secrets used by pods scheduled on it. make helm-test now checks that no ClusterRole, the daemon's included, grants access to secrets. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit 3c43ec7)
The controller now creates bootc-pull-secrets in the release namespace. Helm does not know about it, and helm uninstall keeps the namespace created by --create-namespace, so the Secret is left behind. Document deleting the namespace to remove it. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com> (cherry picked from commit c436dae)
HarshwardhanPatil07
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual backport of #278 . The backport required few tweaks because we don't have the bootcoperatorconfig in the release-0.2 branch, but almost stayed the same