From 0f2cb122197236b458228d85723e185c8229f1ee Mon Sep 17 00:00:00 2001 From: Alec Thomas <112640918+a-thomas-22@users.noreply.github.com> Date: Sun, 18 Jan 2026 01:09:55 -0600 Subject: [PATCH] Fix nil pointer dereference in syncCriticalOpPodDisruptionBudget When the PDB creation fails with "already exists" error, the pdb variable is nil since the initial Get failed. Using pdb.ObjectMeta would cause a panic. Use the cluster method to get the PDB name instead. --- pkg/cluster/sync.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 5cb3ef555..18af688db 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -548,9 +548,10 @@ func (c *Cluster) syncCriticalOpPodDisruptionBudget(isUpdate bool) error { if !k8sutil.ResourceAlreadyExists(err) { return fmt.Errorf("could not create pod disruption budget for critical operations: %v", err) } - c.logger.Infof("pod disruption budget %q already exists", util.NameFromMeta(pdb.ObjectMeta)) - if pdb, err = c.KubeClient.PodDisruptionBudgets(c.Namespace).Get(context.TODO(), c.criticalOpPodDisruptionBudgetName(), metav1.GetOptions{}); err != nil { - return fmt.Errorf("could not fetch existing %q pod disruption budget", util.NameFromMeta(pdb.ObjectMeta)) + pdbName := c.criticalOpPodDisruptionBudgetName() + c.logger.Infof("pod disruption budget %q already exists", pdbName) + if pdb, err = c.KubeClient.PodDisruptionBudgets(c.Namespace).Get(context.TODO(), pdbName, metav1.GetOptions{}); err != nil { + return fmt.Errorf("could not fetch existing %q pod disruption budget", pdbName) } }