diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 4b0b3cb2..be22ec6c 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -2071,7 +2071,9 @@ func (c *Cluster) getPasswordForUser(username string) (string, error) { } c.multisiteClient = client } - reqTimeoutCtx, _ := context.WithTimeout(context.TODO(), time.Duration(2)*time.Second) + reqTimeoutCtx, cancel := context.WithTimeout(context.TODO(), time.Duration(2)*time.Second) + defer cancel() + credentialsKey := fmt.Sprintf("/multisite/%s/%s/credentials/%s", c.Namespace, c.Name, username) response, err := c.multisiteClient.Get(reqTimeoutCtx, credentialsKey) if err != nil { diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 77726142..a8786561 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -2132,7 +2132,7 @@ func (c *Cluster) generatePodAnnotations(spec *cpov1.PostgresSpec) map[string]st for k, v := range c.OpConfig.CustomPodAnnotations { annotations[k] = v } - if spec != nil || spec.PodAnnotations != nil { + if spec != nil && spec.PodAnnotations != nil { for k, v := range spec.PodAnnotations { annotations[k] = v } @@ -2812,7 +2812,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policyv1.PodDisruptionBudget { pdbEnabled := c.OpConfig.EnablePodDisruptionBudget // if PodDisruptionBudget is disabled or if there are no DB pods, set the budget to 0. - if (pdbEnabled != nil && !(*pdbEnabled)) || c.Spec.NumberOfInstances <= 0 { + if (pdbEnabled != nil && !(*pdbEnabled)) || c.Spec.NumberOfInstances <= 1 { minAvailable = intstr.FromInt(0) } @@ -2826,7 +2826,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policyv1.PodDisruptionBudget { Spec: policyv1.PodDisruptionBudgetSpec{ MinAvailable: &minAvailable, Selector: &metav1.LabelSelector{ - MatchLabels: c.roleLabelsSet(false, Master), + MatchLabels: c.labelsSetWithType(false, "postgresql"), //c.roleLabelsSet(false, Master), }, }, } diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index d91669c2..4554a506 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -1108,7 +1108,7 @@ func (c *Cluster) updateSecret( } if updateSecret { - c.logger.Debugln("%s", updateSecretMsg) + c.logger.Debugf("%s", updateSecretMsg) if _, err = c.KubeClient.Secrets(secret.Namespace).Update(context.TODO(), secret, metav1.UpdateOptions{}); err != nil { return fmt.Errorf("could not update secret %s: %v", secretName, err) } diff --git a/pkg/cluster/util.go b/pkg/cluster/util.go index 51271955..3a54bc1e 100644 --- a/pkg/cluster/util.go +++ b/pkg/cluster/util.go @@ -205,7 +205,7 @@ func logNiceDiff(log *logrus.Entry, old, new interface{}) { nice := nicediff.Diff(string(o), string(n), true) for _, s := range strings.Split(nice, "\n") { // " is not needed in the value to understand - log.Debugf(strings.ReplaceAll(s, "\"", "")) + log.Debugf("%s", strings.ReplaceAll(s, "\"", "")) } } @@ -512,8 +512,6 @@ func (c *Cluster) waitForPrimaryLoadBalancerIp() error { } return len(svc.Status.LoadBalancer.Ingress) > 0, nil }) - - return nil } func (c *Cluster) getPrimaryLoadBalancerIp() (string, error) {