mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 17:33:12 +02:00
init error arrays correctly
This commit is contained in:
@@ -496,17 +496,16 @@ func (c *Cluster) deleteEndpoint(role PostgresRole) error {
|
||||
|
||||
func (c *Cluster) deleteSecrets() error {
|
||||
c.setProcessName("deleting secrets")
|
||||
var errors []string
|
||||
errorCount := 0
|
||||
errors := make([]string, 0)
|
||||
|
||||
for uid, secret := range c.Secrets {
|
||||
err := c.deleteSecret(uid, *secret)
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Sprintf("%v", err))
|
||||
errorCount++
|
||||
}
|
||||
}
|
||||
|
||||
if errorCount > 0 {
|
||||
if len(errors) > 0 {
|
||||
return fmt.Errorf("could not delete all secrets: %v", errors)
|
||||
}
|
||||
|
||||
|
||||
@@ -196,17 +196,15 @@ func TestCheckAndSetGlobalPostgreSQLConfiguration(t *testing.T) {
|
||||
cluster.patroni = p
|
||||
mockPod := newMockPod("192.168.100.1")
|
||||
|
||||
// simulate existing config that differs with cluster.Spec
|
||||
// simulate existing config that differs from cluster.Spec
|
||||
tests := []struct {
|
||||
subtest string
|
||||
pod *v1.Pod
|
||||
patroni acidv1.Patroni
|
||||
pgParams map[string]string
|
||||
restartMaster bool
|
||||
}{
|
||||
{
|
||||
subtest: "Patroni and Postgresql.Parameters differ - restart replica first",
|
||||
pod: mockPod,
|
||||
patroni: acidv1.Patroni{
|
||||
TTL: 30, // desired 20
|
||||
},
|
||||
@@ -218,7 +216,6 @@ func TestCheckAndSetGlobalPostgreSQLConfiguration(t *testing.T) {
|
||||
},
|
||||
{
|
||||
subtest: "multiple Postgresql.Parameters differ - restart replica first",
|
||||
pod: mockPod,
|
||||
patroni: acidv1.Patroni{
|
||||
TTL: 20,
|
||||
},
|
||||
@@ -230,7 +227,6 @@ func TestCheckAndSetGlobalPostgreSQLConfiguration(t *testing.T) {
|
||||
},
|
||||
{
|
||||
subtest: "desired max_connections bigger - restart replica first",
|
||||
pod: mockPod,
|
||||
patroni: acidv1.Patroni{
|
||||
TTL: 20,
|
||||
},
|
||||
@@ -242,7 +238,6 @@ func TestCheckAndSetGlobalPostgreSQLConfiguration(t *testing.T) {
|
||||
},
|
||||
{
|
||||
subtest: "desired max_connections smaller - restart master first",
|
||||
pod: mockPod,
|
||||
patroni: acidv1.Patroni{
|
||||
TTL: 20,
|
||||
},
|
||||
@@ -255,7 +250,7 @@ func TestCheckAndSetGlobalPostgreSQLConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
requireMasterRestart, err := cluster.checkAndSetGlobalPostgreSQLConfiguration(tt.pod, tt.patroni, tt.pgParams)
|
||||
requireMasterRestart, err := cluster.checkAndSetGlobalPostgreSQLConfiguration(mockPod, tt.patroni, tt.pgParams)
|
||||
assert.NoError(t, err)
|
||||
if requireMasterRestart != tt.restartMaster {
|
||||
t.Errorf("%s - %s: unexpect master restart strategy, got %v, expected %v", testName, tt.subtest, requireMasterRestart, tt.restartMaster)
|
||||
|
||||
@@ -88,7 +88,7 @@ func (c *Cluster) syncUnderlyingEBSVolume() error {
|
||||
awsGp3 := aws.String("gp3")
|
||||
awsIo2 := aws.String("io2")
|
||||
|
||||
errors := []string{}
|
||||
errors := make([]string, 0)
|
||||
|
||||
for _, volume := range c.EBSVolumes {
|
||||
var modifyIops *int64
|
||||
|
||||
Reference in New Issue
Block a user