Skip to content

Commit 535f16a

Browse files
committed
Round 19 fix: surface transient configmap read failures
_read_perm_configmap_resources now uses run_command_with_code and raises on non-NotFound failures (network blip, RBAC denied, kubectl throttled, etc.) instead of silently treating them as 'configmap is empty'. The revoke path previously saw an empty current_resources on a transient failure, computed remaining_resources = [], and then _write_perm_configmap_resources deleted the configmap and skipped the create branch — silently wiping every grant. Update has the same pattern but always writes the new permission file's resources, so a transient read failure there only dropped old entries.
1 parent 70c39c9 commit 535f16a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

provider-kubeconfig.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def _parse_permission_rules(self, perms):
9595
def _read_perm_configmap_resources(self, sa, namespace, kubeconfig):
9696
cfg_map_name = sa + "-perms"
9797
cfg_map_filename = sa + "-perms.txt"
98-
out, _ = run_command("kubectl get configmap " + cfg_map_name + " -o json -n " + namespace + kubeconfig)
98+
out, err, rc = run_command_with_code(
99+
"kubectl get configmap " + cfg_map_name + " -o json -n " + namespace + kubeconfig
100+
)
101+
if rc != 0 and "(NotFound)" not in err:
102+
raise RuntimeError(f"Failed to read configmap {cfg_map_name!r}: {err.strip()}")
99103
kubeplus_perms = []
100104
if out:
101105
json_op = json.loads(out)

0 commit comments

Comments
 (0)