Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,12 @@ spec:
backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources.requests.storage)
image:
description: The image name to use for pgAdmin instance.
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3197,13 +3197,12 @@ spec:
to the PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: has(self.accessModes) && size(self.accessModes)
> 0
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources) && has(self.resources.requests)
&& has(self.resources.requests.storage)
rule: has(self.resources.requests.storage)
required:
- volumeClaimSpec
type: object
Expand Down Expand Up @@ -6524,13 +6523,12 @@ spec:
to the PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: has(self.accessModes) && size(self.accessModes)
> 0
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources) && has(self.resources.requests)
&& has(self.resources.requests.storage)
rule: has(self.resources.requests.storage)
required:
- volumeClaimSpec
type: object
Expand Down Expand Up @@ -10412,12 +10410,12 @@ spec:
PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: has(self.accessModes) && size(self.accessModes) > 0
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources) && has(self.resources.requests)
&& has(self.resources.requests.storage)
rule: has(self.resources.requests.storage)
metadata:
description: Metadata contains metadata for custom resources
properties:
Expand Down Expand Up @@ -10797,13 +10795,12 @@ spec:
the PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: has(self.accessModes) && size(self.accessModes)
> 0
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources) && has(self.resources.requests)
&& has(self.resources.requests.storage)
rule: has(self.resources.requests.storage)
name:
description: |-
The name for the tablespace, used as the path name for the volume.
Expand Down Expand Up @@ -11238,12 +11235,12 @@ spec:
PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: has(self.accessModes) && size(self.accessModes) > 0
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources) && has(self.resources.requests)
&& has(self.resources.requests.storage)
rule: has(self.resources.requests.storage)
required:
- dataVolumeClaimSpec
type: object
Expand Down Expand Up @@ -17328,6 +17325,12 @@ spec:
PersistentVolume backing this claim.
type: string
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: missing accessModes
rule: 0 < size(self.accessModes)
- message: missing storage request
rule: has(self.resources.requests.storage)
image:
description: |-
Name of a container image that can run pgAdmin 4. Changing this value causes
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/postgrescluster/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func setupNamespace(t testing.TB, cc client.Client) *corev1.Namespace {
return require.Namespace(t, cc)
}

func testVolumeClaimSpec() corev1.PersistentVolumeClaimSpec {
func testVolumeClaimSpec() v1beta1.VolumeClaimSpec {
// Defines a volume claim spec that can be used to create instances
return corev1.PersistentVolumeClaimSpec{
return v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/postgrescluster/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func TestStoreDesiredRequest(t *testing.T) {
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
Name: "red",
Replicas: initialize.Int32(1),
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Limits: map[corev1.ResourceName]resource.Quantity{
Expand Down Expand Up @@ -1850,7 +1850,7 @@ func TestFindAvailableInstanceNames(t *testing.T) {
expectedInstanceNames: []string{"instance1-def"},
}, {
set: v1beta1.PostgresInstanceSetSpec{Name: "instance1",
WALVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{}},
WALVolumeClaimSpec: &v1beta1.VolumeClaimSpec{}},
fakeObservedInstances: newObservedInstances(
&v1beta1.PostgresCluster{Spec: v1beta1.PostgresClusterSpec{
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{Name: "instance1"}},
Expand All @@ -1877,7 +1877,7 @@ func TestFindAvailableInstanceNames(t *testing.T) {
expectedInstanceNames: []string{},
}, {
set: v1beta1.PostgresInstanceSetSpec{Name: "instance1",
WALVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{}},
WALVolumeClaimSpec: &v1beta1.VolumeClaimSpec{}},
fakeObservedInstances: newObservedInstances(
&v1beta1.PostgresCluster{Spec: v1beta1.PostgresClusterSpec{
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{Name: "instance1"}},
Expand All @@ -1901,7 +1901,7 @@ func TestFindAvailableInstanceNames(t *testing.T) {
expectedInstanceNames: []string{"instance1-def"},
}, {
set: v1beta1.PostgresInstanceSetSpec{Name: "instance1",
WALVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{}},
WALVolumeClaimSpec: &v1beta1.VolumeClaimSpec{}},
fakeObservedInstances: newObservedInstances(
&v1beta1.PostgresCluster{Spec: v1beta1.PostgresClusterSpec{
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{Name: "instance1"}},
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/pgadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (r *Reconciler) reconcilePGAdminDataVolume(
cluster.Spec.Metadata.GetLabelsOrNil(),
labelMap,
)
pvc.Spec = cluster.Spec.UserInterface.PGAdmin.DataVolumeClaimSpec
pvc.Spec = cluster.Spec.UserInterface.PGAdmin.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

err := errors.WithStack(r.setControllerReference(cluster, pvc))

Expand Down
4 changes: 2 additions & 2 deletions internal/controller/postgrescluster/pgadmin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func pgAdminTestCluster(ns corev1.Namespace) *v1beta1.PostgresCluster {
Repos: []v1beta1.PGBackRestRepo{{
Name: "repo1",
Volume: &v1beta1.RepoPVC{
VolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
VolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand All @@ -868,7 +868,7 @@ func pgAdminTestCluster(ns corev1.Namespace) *v1beta1.PostgresCluster {
UserInterface: &v1beta1.UserInterfaceSpec{
PGAdmin: &v1beta1.PGAdminPodSpec{
Image: "test-image",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/postgrescluster/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,8 @@ func (r *Reconciler) reconcileRepos(ctx context.Context,
if repo.Volume == nil {
continue
}
repo, err := r.applyRepoVolumeIntent(ctx, postgresCluster, repo.Volume.VolumeClaimSpec,
repo, err := r.applyRepoVolumeIntent(ctx, postgresCluster,
repo.Volume.VolumeClaimSpec.AsPersistentVolumeClaimSpec(),
repo.Name, repoResources)
if err != nil {
log.Error(err, errMsg)
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/postgrescluster/pgbackrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func fakePostgresCluster(clusterName, namespace, clusterUID string,
Image: "example.com/crunchy-postgres-ha:test",
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
Name: "instance1",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand Down Expand Up @@ -115,7 +115,7 @@ func fakePostgresCluster(clusterName, namespace, clusterUID string,
postgresCluster.Spec.Backups.PGBackRest.Repos[0] = v1beta1.PGBackRestRepo{
Name: "repo1",
Volume: &v1beta1.RepoPVC{
VolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
VolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
Expand Down Expand Up @@ -2268,7 +2268,7 @@ func TestCopyConfigurationResources(t *testing.T) {
Image: "example.com/crunchy-postgres-ha:test",
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
Name: "instance1",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand Down Expand Up @@ -2320,7 +2320,7 @@ func TestCopyConfigurationResources(t *testing.T) {
},
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
Name: "instance1",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/postgrescluster/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ func (r *Reconciler) reconcilePostgresDataVolume(
labelMap,
)

pvc.Spec = instanceSpec.DataVolumeClaimSpec
pvc.Spec = instanceSpec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

// If a source cluster was provided and VolumeSnapshots are turned on in the source cluster and
// there is a VolumeSnapshot available for the source cluster that is ReadyToUse, use it as the
Expand Down Expand Up @@ -910,7 +910,7 @@ func (r *Reconciler) reconcileTablespaceVolumes(
labelMap,
)

pvc.Spec = vol.DataVolumeClaimSpec
pvc.Spec = vol.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

if err == nil {
err = r.handlePersistentVolumeClaimError(cluster,
Expand Down Expand Up @@ -1017,7 +1017,7 @@ func (r *Reconciler) reconcilePostgresWALVolume(
labelMap,
)

pvc.Spec = *instanceSpec.WALVolumeClaimSpec
pvc.Spec = instanceSpec.WALVolumeClaimSpec.AsPersistentVolumeClaimSpec()

if err == nil {
err = r.handlePersistentVolumeClaimError(cluster,
Expand Down
20 changes: 10 additions & 10 deletions internal/controller/postgrescluster/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ func TestSetVolumeSize(t *testing.T) {
instanceSetSpec := func(request, limit string) *v1beta1.PostgresInstanceSetSpec {
return &v1beta1.PostgresInstanceSetSpec{
Name: "some-instance",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
Expand Down Expand Up @@ -911,7 +911,7 @@ func TestSetVolumeSize(t *testing.T) {

pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("4Gi", "3Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand Down Expand Up @@ -948,7 +948,7 @@ resources:
}},
}

pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand Down Expand Up @@ -984,14 +984,14 @@ resources:
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := &v1beta1.PostgresInstanceSetSpec{
Name: "some-instance",
DataVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
DataVolumeClaimSpec: v1beta1.VolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceStorage: resource.MustParse("1Gi"),
}}}}
cluster.Status = desiredStatus("2Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand All @@ -1016,7 +1016,7 @@ resources:

pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("1Gi", "2Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand All @@ -1041,7 +1041,7 @@ resources:
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("1Gi", "3Gi")
cluster.Status = desiredStatus("NotAValidValue")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand All @@ -1068,7 +1068,7 @@ resources:
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("1Gi", "3Gi")
cluster.Status = desiredStatus("2Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand All @@ -1093,7 +1093,7 @@ resources:
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("1Gi", "2Gi")
cluster.Status = desiredStatus("2Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand Down Expand Up @@ -1122,7 +1122,7 @@ resources:
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: naming.InstancePostgresDataVolume(instance)}
spec := instanceSetSpec("4Gi", "5Gi")
cluster.Status = desiredStatus("10Gi")
pvc.Spec = spec.DataVolumeClaimSpec
pvc.Spec = spec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

reconciler.setVolumeSize(ctx, &cluster, pvc, spec.Name)

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (r *Reconciler) createDedicatedSnapshotVolume(ctx context.Context,
return pvc, err
}

pvc.Spec = instanceSpec.DataVolumeClaimSpec
pvc.Spec = instanceSpec.DataVolumeClaimSpec.AsPersistentVolumeClaimSpec()

// Set the snapshot volume to the same size as the pgdata volume. The size should scale with auto-grow.
r.setVolumeSize(ctx, cluster, pvc, instanceSpec.Name)
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/postgrescluster/snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
naming.LabelData: naming.DataPostgres,
},
},
Spec: testVolumeClaimSpec(),
}
spec := testVolumeClaimSpec()
pvc.Spec = spec.AsPersistentVolumeClaimSpec()
assert.NilError(t, r.setControllerReference(cluster, pvc))
assert.NilError(t, r.apply(ctx, pvc))

Expand Down
6 changes: 3 additions & 3 deletions internal/controller/postgrescluster/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (r *Reconciler) configureExistingPGVolumes(
Name: volName,
Namespace: cluster.Namespace,
},
Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec,
Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec.AsPersistentVolumeClaimSpec(),
}

volume.ObjectMeta.Labels = map[string]string{
Expand Down Expand Up @@ -307,7 +307,7 @@ func (r *Reconciler) configureExistingPGWALVolume(
Name: volName,
Namespace: cluster.Namespace,
},
Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec,
Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec.AsPersistentVolumeClaimSpec(),
}

volume.ObjectMeta.Labels = map[string]string{
Expand Down Expand Up @@ -362,7 +362,7 @@ func (r *Reconciler) configureExistingRepoVolumes(
cluster.Spec.Backups.PGBackRest.Repos[0].Name),
},
Spec: cluster.Spec.Backups.PGBackRest.Repos[0].Volume.
VolumeClaimSpec,
VolumeClaimSpec.AsPersistentVolumeClaimSpec(),
}

//volume.ObjectMeta = naming.PGBackRestRepoVolume(cluster, cluster.Spec.Backups.PGBackRest.Repos[0].Name)
Expand Down
Loading
Loading