Skip to content

Commit c58059e

Browse files
committed
more fixes
1 parent 5d48239 commit c58059e

25 files changed

Lines changed: 101 additions & 115 deletions

internal/controller/pgupgrade/jobs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (r *PGUpgradeReconciler) generateUpgradeJob(
178178
job.Spec.Template.Spec.ImagePullSecrets = upgrade.Spec.ImagePullSecrets
179179

180180
// Attempt the upgrade exactly once.
181-
job.Spec.BackoffLimit = initialize.Int32(0)
181+
job.Spec.BackoffLimit = new(int32(0))
182182
job.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyNever
183183

184184
// When enabled, calculate the number of CPUs for pg_upgrade.
@@ -335,7 +335,7 @@ func (r *PGUpgradeReconciler) generateRemoveDataJob(
335335
job.Spec.Template.Spec.ImagePullSecrets = upgrade.Spec.ImagePullSecrets
336336

337337
// Attempt the removal exactly once.
338-
job.Spec.BackoffLimit = initialize.Int32(0)
338+
job.Spec.BackoffLimit = new(int32(0))
339339
job.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyNever
340340

341341
// Replace all containers with one that removes the data.

internal/controller/postgrescluster/cluster_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2222

2323
"github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime"
24-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2524
"github.com/percona/percona-postgresql-operator/v2/internal/naming"
2625
"github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp"
2726
"github.com/percona/percona-postgresql-operator/v2/internal/testing/require"
@@ -143,14 +142,14 @@ func TestCustomLabels(t *testing.T) {
143142
InitContainer: &v1beta1.InitContainerSpec{
144143
Image: "some-image",
145144
},
146-
Replicas: initialize.Int32(1),
145+
Replicas: new(int32(1)),
147146
DataVolumeClaimSpec: testVolumeClaimSpec(),
148147
}, {
149148
Name: "daisy-instance2",
150149
InitContainer: &v1beta1.InitContainerSpec{
151150
Image: "some-image",
152151
},
153-
Replicas: initialize.Int32(1),
152+
Replicas: new(int32(1)),
154153
DataVolumeClaimSpec: testVolumeClaimSpec(),
155154
}}
156155
cluster.Spec.Metadata = &v1beta1.Metadata{
@@ -197,7 +196,7 @@ func TestCustomLabels(t *testing.T) {
197196
InitContainer: &v1beta1.InitContainerSpec{
198197
Image: "some-image",
199198
},
200-
Replicas: initialize.Int32(1),
199+
Replicas: new(int32(1)),
201200
DataVolumeClaimSpec: testVolumeClaimSpec(),
202201
Metadata: &v1beta1.Metadata{
203202
Labels: map[string]string{"my.instance.label": "max"},
@@ -207,7 +206,7 @@ func TestCustomLabels(t *testing.T) {
207206
InitContainer: &v1beta1.InitContainerSpec{
208207
Image: "some-image",
209208
},
210-
Replicas: initialize.Int32(1),
209+
Replicas: new(int32(1)),
211210
DataVolumeClaimSpec: testVolumeClaimSpec(),
212211
Metadata: &v1beta1.Metadata{
213212
Labels: map[string]string{"my.instance.label": "lucy"},
@@ -393,14 +392,14 @@ func TestCustomAnnotations(t *testing.T) {
393392
InitContainer: &v1beta1.InitContainerSpec{
394393
Image: "some-image",
395394
},
396-
Replicas: initialize.Int32(1),
395+
Replicas: new(int32(1)),
397396
DataVolumeClaimSpec: testVolumeClaimSpec(),
398397
}, {
399398
Name: "daisy-instance2",
400399
InitContainer: &v1beta1.InitContainerSpec{
401400
Image: "some-image",
402401
},
403-
Replicas: initialize.Int32(1),
402+
Replicas: new(int32(1)),
404403
DataVolumeClaimSpec: testVolumeClaimSpec(),
405404
}}
406405
cluster.Spec.Metadata = &v1beta1.Metadata{
@@ -448,7 +447,7 @@ func TestCustomAnnotations(t *testing.T) {
448447
InitContainer: &v1beta1.InitContainerSpec{
449448
Image: "some-image",
450449
},
451-
Replicas: initialize.Int32(1),
450+
Replicas: new(int32(1)),
452451
DataVolumeClaimSpec: testVolumeClaimSpec(),
453452
Metadata: &v1beta1.Metadata{
454453
Annotations: map[string]string{"my.instance.annotation": "max"},
@@ -458,7 +457,7 @@ func TestCustomAnnotations(t *testing.T) {
458457
InitContainer: &v1beta1.InitContainerSpec{
459458
Image: "some-image",
460459
},
461-
Replicas: initialize.Int32(1),
460+
Replicas: new(int32(1)),
462461
DataVolumeClaimSpec: testVolumeClaimSpec(),
463462
Metadata: &v1beta1.Metadata{
464463
Annotations: map[string]string{"my.instance.annotation": "lucy"},
@@ -584,7 +583,7 @@ func TestGenerateClusterPrimaryService(t *testing.T) {
584583
cluster := &v1beta1.PostgresCluster{}
585584
cluster.Namespace = "ns2"
586585
cluster.Name = "pg5"
587-
cluster.Spec.Port = initialize.Int32(2600)
586+
cluster.Spec.Port = new(int32(2600))
588587

589588
// K8SPG-430
590589
cluster.Labels = map[string]string{
@@ -719,7 +718,7 @@ func TestGenerateClusterReplicaServiceIntent(t *testing.T) {
719718
cluster := &v1beta1.PostgresCluster{}
720719
cluster.Namespace = "ns1"
721720
cluster.Name = "pg2"
722-
cluster.Spec.Port = initialize.Int32(9876)
721+
cluster.Spec.Port = new(int32(9876))
723722

724723
// K8SPG-430
725724
cluster.Labels = map[string]string{

internal/controller/postgrescluster/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"sigs.k8s.io/yaml"
2222

2323
"github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime"
24-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
24+
2525
"github.com/percona/percona-postgresql-operator/v2/internal/naming"
2626
"github.com/percona/percona-postgresql-operator/v2/internal/testing/require"
2727
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
@@ -120,7 +120,7 @@ func testCluster() *v1beta1.PostgresCluster {
120120
InitContainer: &v1beta1.InitContainerSpec{
121121
Image: "some-image",
122122
},
123-
Replicas: initialize.Int32(1),
123+
Replicas: new(int32(1)),
124124
DataVolumeClaimSpec: testVolumeClaimSpec(),
125125
}},
126126
Backups: v1beta1.Backups{

internal/controller/postgrescluster/instance.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ func generateInstanceStatefulSetIntent(_ context.Context,
13331333

13341334
// Don't clutter the namespace with extra ControllerRevisions.
13351335
// The "controller-revision-hash" label still exists on the Pod.
1336-
sts.Spec.RevisionHistoryLimit = initialize.Int32(0)
1336+
sts.Spec.RevisionHistoryLimit = new(int32(0))
13371337

13381338
// Give the Pod a stable DNS record based on its name.
13391339
// - https://docs.k8s.io/concepts/workloads/controllers/statefulset/#stable-network-id
@@ -1370,24 +1370,24 @@ func generateInstanceStatefulSetIntent(_ context.Context,
13701370
// is always the first to startup and the last to shutdown.
13711371
if cluster.Status.StartupInstance == "" {
13721372
// there is no designated startup instance; all instances should run.
1373-
sts.Spec.Replicas = initialize.Int32(1)
1373+
sts.Spec.Replicas = new(int32(1))
13741374
} else if cluster.Status.StartupInstance != sts.Name {
13751375
// there is a startup instance defined, but not this instance; do not run.
1376-
sts.Spec.Replicas = initialize.Int32(0)
1376+
sts.Spec.Replicas = new(int32(0))
13771377
} else if cluster.Spec.Shutdown != nil && *cluster.Spec.Shutdown &&
13781378
numInstancePods <= 1 {
13791379
// this is the last instance of the shutdown sequence; do not run.
1380-
sts.Spec.Replicas = initialize.Int32(0)
1380+
sts.Spec.Replicas = new(int32(0))
13811381
} else {
13821382
// this is the designated instance, but
13831383
// - others are still running during shutdown, or
13841384
// - it is time to startup.
1385-
sts.Spec.Replicas = initialize.Int32(1)
1385+
sts.Spec.Replicas = new(int32(1))
13861386
}
13871387

13881388
// K8SPG-771
13891389
if suspend {
1390-
sts.Spec.Replicas = initialize.Int32(0)
1390+
sts.Spec.Replicas = new(int32(0))
13911391
}
13921392

13931393
// Restart containers any time they stop, die, are killed, etc.

internal/controller/postgrescluster/instance_rollout_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"sigs.k8s.io/controller-runtime/pkg/client"
2424
"sigs.k8s.io/controller-runtime/pkg/client/fake"
2525

26-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2726
"github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp"
2827
pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming"
2928
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
@@ -211,7 +210,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
211210
t.Run("Steady", func(t *testing.T) {
212211
cluster := new(v1beta1.PostgresCluster)
213212
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
214-
{Name: "00", Replicas: initialize.Int32(1)},
213+
{Name: "00", Replicas: new(int32(1))},
215214
}
216215
instances := []*Instance{
217216
{
@@ -256,7 +255,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
256255
t.Run("SingletonOutdated", func(t *testing.T) {
257256
cluster := new(v1beta1.PostgresCluster)
258257
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
259-
{Name: "00", Replicas: initialize.Int32(1)},
258+
{Name: "00", Replicas: new(int32(1))},
260259
}
261260
instances := []*Instance{
262261
{
@@ -301,7 +300,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
301300
t.Run("ManyOutdated", func(t *testing.T) {
302301
cluster := new(v1beta1.PostgresCluster)
303302
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
304-
{Name: "00", Replicas: initialize.Int32(2)},
303+
{Name: "00", Replicas: new(int32(2))},
305304
}
306305
instances := []*Instance{
307306
{
@@ -371,7 +370,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
371370
t.Run("ManyOutdatedWithPrimary", func(t *testing.T) {
372371
cluster := new(v1beta1.PostgresCluster)
373372
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
374-
{Name: "00", Replicas: initialize.Int32(2)},
373+
{Name: "00", Replicas: new(int32(2))},
375374
}
376375
instances := []*Instance{
377376
{
@@ -442,7 +441,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
442441
t.Run("ManyOutdatedWithNotReady", func(t *testing.T) {
443442
cluster := new(v1beta1.PostgresCluster)
444443
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
445-
{Name: "00", Replicas: initialize.Int32(2)},
444+
{Name: "00", Replicas: new(int32(2))},
446445
}
447446
instances := []*Instance{
448447
{
@@ -512,7 +511,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
512511
t.Run("ManyOutdatedWithTerminating", func(t *testing.T) {
513512
cluster := new(v1beta1.PostgresCluster)
514513
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
515-
{Name: "00", Replicas: initialize.Int32(2)},
514+
{Name: "00", Replicas: new(int32(2))},
516515
}
517516
instances := []*Instance{
518517
{
@@ -583,7 +582,7 @@ func TestReconcilerRolloutInstances(t *testing.T) {
583582
t.Run("ManyOutdatedWithOrphan", func(t *testing.T) {
584583
cluster := new(v1beta1.PostgresCluster)
585584
cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{
586-
{Name: "00", Replicas: initialize.Int32(2)},
585+
{Name: "00", Replicas: new(int32(2))},
587586
}
588587
instances := []*Instance{
589588
{

internal/controller/postgrescluster/instance_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3636

3737
"github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime"
38-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
3938
"github.com/percona/percona-postgresql-operator/v2/internal/logging"
4039
"github.com/percona/percona-postgresql-operator/v2/internal/naming"
4140
"github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp"
@@ -281,7 +280,7 @@ func TestStoreDesiredRequest(t *testing.T) {
281280
Spec: v1beta1.PostgresClusterSpec{
282281
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
283282
Name: "red",
284-
Replicas: initialize.Int32(1),
283+
Replicas: new(int32(1)),
285284
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
286285
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
287286
Resources: corev1.VolumeResourceRequirements{
@@ -290,7 +289,7 @@ func TestStoreDesiredRequest(t *testing.T) {
290289
}}},
291290
}, {
292291
Name: "blue",
293-
Replicas: initialize.Int32(1),
292+
Replicas: new(int32(1)),
294293
}}}}
295294

296295
t.Run("BadRequestNoBackup", func(t *testing.T) {
@@ -1670,7 +1669,7 @@ func TestGenerateInstanceStatefulSetIntent(t *testing.T) {
16701669
DisableDefaultPodScheduling: new(true),
16711670
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
16721671
Name: "instance1",
1673-
Replicas: initialize.Int32(1),
1672+
Replicas: new(int32(1)),
16741673
DataVolumeClaimSpec: testVolumeClaimSpec(),
16751674
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{{
16761675
MaxSkew: int32(1),
@@ -2137,7 +2136,7 @@ func TestCleanupDisruptionBudgets(t *testing.T) {
21372136
t.Run("cleanup leftover pdb", func(t *testing.T) {
21382137
leftoverPDB := generatePDB(t, cluster, &v1beta1.PostgresInstanceSetSpec{
21392138
Name: "old-instance",
2140-
Replicas: initialize.Int32(1),
2139+
Replicas: new(int32(1)),
21412140
}, new(intstr.FromInt32(1)))
21422141
assert.NilError(t, createPDB(leftoverPDB))
21432142

0 commit comments

Comments
 (0)