Bug Description
Notes:
kube-control provider does not publish or grant pre-existing CA secret to new relations
Repository
https://github.com/charmed-kubernetes/interface-kube-control
Related consumer path
https://github.com/canonical/k8s-operator/blob/main/charms/worker/k8s/src/kube_control.py
Summary
When a CA secret labeled ca-certificate already exists before new kube-control relations are added, the provider does not publish ca-certificate-secret-id and does not grant relation access to that CA secret.
Affected code
Expected behavior
For each kube-control relation, set_ca_certificate should:
- Grant the CA secret to the relation
- Publish ca-certificate-secret-id in provider relation data
This should happen even when the CA secret already exists from earlier runs.
Actual behavior
- Creds secrets are created and granted per requirer, and creds secret-id values are published
- CA secret exists and contains valid certificate content
- CA secret has no relation access entries for newly added requirers
- Relation data does not include ca-certificate-secret-id
Root cause
In set_ca_certificate, grant and publication are gated on secret.id.
If the secret is obtained via label lookup, secret.id may be empty on that object instance.
When that happens, grant and relation-data publication are skipped for existing CA secrets.
Why this is a bug
New kube-control requirers cannot read or reference the CA secret, even though token secrets are correctly granted and advertised.
Evidence from live deployment
- Installed package path on unit:
/var/lib/juju/agents/unit-k8s-1/charm/venv/lib/python3.10/site-packages/ops_interface_kube_control-0.3.3.dist-info
- Provider code on unit confirms set_ca_certificate checks secret.id before grant/publish
- CA secret was created earlier (June 8), while affected relations were added later (June 10)
- Creds secrets added on June 10 include relation access entries; CA secret does not
Proposed fix
In set_ca_certificate:
- Resolve secret locator using either secret.id or secret.get_info().id
- If needed, re-fetch by resolved id before grant
- Use resolved id to:
- grant secret to each relation
- publish ca-certificate-secret-id in relation data
Optional hardening
Apply the same id-resolution pattern in sign_auth_request after _refresh_secret_content, to avoid similar edge cases for pre-existing credential secrets.
To Reproduce
- Ensure provider has a pre-existing ca-certificate secret (created before target requirer relation is added)
- Add a new kube-control requirer relation
- Trigger provider reconcile
- Observe:
- creds contains secret-id entries for requirers
- ca-certificate-secret-id is missing from relation data
- CA secret has no relation-scoped access entries
Environment
- Juju: 3.6.2
- k8s charm revision: 1845 (channel 1.35/stable )
- ops.interface_kube_control: 0.3.3 (verified on unit filesystem)
Relevant log output
"Missing required certificates"
`juju secrets` shows a secret with a k8s CA but it does not have anya ccess grant to the kube-control relation requirer
Additional context
No response
Bug Description
Notes:
kube-control provider does not publish or grant pre-existing CA secret to new relations
Repository
https://github.com/charmed-kubernetes/interface-kube-control
Related consumer path
https://github.com/canonical/k8s-operator/blob/main/charms/worker/k8s/src/kube_control.py
Summary
When a CA secret labeled ca-certificate already exists before new kube-control relations are added, the provider does not publish ca-certificate-secret-id and does not grant relation access to that CA secret.
Affected code
Expected behavior
For each kube-control relation, set_ca_certificate should:
This should happen even when the CA secret already exists from earlier runs.
Actual behavior
Root cause
In set_ca_certificate, grant and publication are gated on secret.id.
If the secret is obtained via label lookup, secret.id may be empty on that object instance.
When that happens, grant and relation-data publication are skipped for existing CA secrets.
Why this is a bug
New kube-control requirers cannot read or reference the CA secret, even though token secrets are correctly granted and advertised.
Evidence from live deployment
/var/lib/juju/agents/unit-k8s-1/charm/venv/lib/python3.10/site-packages/ops_interface_kube_control-0.3.3.dist-info
Proposed fix
In set_ca_certificate:
Optional hardening
Apply the same id-resolution pattern in sign_auth_request after _refresh_secret_content, to avoid similar edge cases for pre-existing credential secrets.
To Reproduce
Environment
Relevant log output
Additional context
No response