Skip to content

Commit

Permalink
PR feedback, v1
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminjb committed Nov 8, 2024
1 parent 496247d commit ea35ac4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions internal/controller/pgupgrade/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (r *PGUpgradeReconciler) generateUpgradeJob(

job.Annotations = Merge(upgrade.Spec.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: database.Name,
naming.DefaultContainerAnnotation: database.Name,
})

// Copy the pod template from the startup instance StatefulSet. This includes
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *PGUpgradeReconciler) generateRemoveDataJob(

job.Annotations = Merge(upgrade.Spec.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: database.Name,
naming.DefaultContainerAnnotation: database.Name,
})

// Copy the pod template from the sts instance StatefulSet. This includes
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ func generateInstanceStatefulSetIntent(_ context.Context,
cluster.Spec.Metadata.GetAnnotationsOrNil(),
spec.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: naming.ContainerDatabase,
naming.DefaultContainerAnnotation: naming.ContainerDatabase,
},
)
sts.Spec.Template.Labels = naming.Merge(
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 @@ -260,7 +260,7 @@ func (r *Reconciler) reconcilePGAdminStatefulSet(
cluster.Spec.Metadata.GetAnnotationsOrNil(),
cluster.Spec.UserInterface.PGAdmin.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: naming.ContainerPGAdmin,
naming.DefaultContainerAnnotation: naming.ContainerPGAdmin,
},
)
sts.Spec.Template.Labels = naming.Merge(
Expand Down
10 changes: 5 additions & 5 deletions internal/controller/postgrescluster/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (r *Reconciler) generateRepoHostIntent(ctx context.Context, postgresCluster
postgresCluster.Spec.Metadata.GetAnnotationsOrNil(),
postgresCluster.Spec.Backups.PGBackRest.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: naming.PGBackRestRepoContainerName,
naming.DefaultContainerAnnotation: naming.PGBackRestRepoContainerName,
},
)
labels := naming.Merge(
Expand Down Expand Up @@ -810,10 +810,10 @@ func generateBackupJobSpecIntent(ctx context.Context, postgresCluster *v1beta1.P
}

if annotations != nil {
annotations[naming.DefaultContainerLabel] = naming.PGBackRestRepoContainerName
annotations[naming.DefaultContainerAnnotation] = naming.PGBackRestRepoContainerName
} else {
annotations = map[string]string{
naming.DefaultContainerLabel: naming.PGBackRestRepoContainerName,
naming.DefaultContainerAnnotation: naming.PGBackRestRepoContainerName,
}
}

Expand Down Expand Up @@ -1285,8 +1285,8 @@ func (r *Reconciler) generateRestoreJobIntent(cluster *v1beta1.PostgresCluster,
cluster.Spec.Metadata.GetAnnotationsOrNil(),
cluster.Spec.Backups.PGBackRest.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.PGBackRestConfigHash: configHash,
naming.DefaultContainerLabel: naming.PGBackRestRestoreContainerName,
naming.PGBackRestConfigHash: configHash,
naming.DefaultContainerAnnotation: naming.PGBackRestRestoreContainerName,
})
labels := naming.Merge(
cluster.Spec.Metadata.GetLabelsOrNil(),
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (r *Reconciler) generatePGBouncerDeployment(
cluster.Spec.Metadata.GetAnnotationsOrNil(),
cluster.Spec.Proxy.PGBouncer.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: naming.ContainerPGBouncer,
naming.DefaultContainerAnnotation: naming.ContainerPGBouncer,
},
)
deploy.Spec.Template.Labels = naming.Merge(
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 @@ -470,7 +470,7 @@ func (r *Reconciler) reconcileMovePGDataDir(ctx context.Context,
jobSpec := &batchv1.JobSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: labels, Annotations: map[string]string{
naming.DefaultContainerLabel: naming.ContainerJobMovePGDataDir,
naming.DefaultContainerAnnotation: naming.ContainerJobMovePGDataDir,
}},
Spec: corev1.PodSpec{
// Set the image pull secrets, if any exist.
Expand Down Expand Up @@ -589,7 +589,7 @@ func (r *Reconciler) reconcileMoveWALDir(ctx context.Context,
jobSpec := &batchv1.JobSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: labels, Annotations: map[string]string{
naming.DefaultContainerLabel: naming.ContainerJobMovePGWALDir,
naming.DefaultContainerAnnotation: naming.ContainerJobMovePGWALDir,
}},
Spec: corev1.PodSpec{
// Set the image pull secrets, if any exist.
Expand Down Expand Up @@ -713,7 +713,7 @@ func (r *Reconciler) reconcileMoveRepoDir(ctx context.Context,
jobSpec := &batchv1.JobSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: labels, Annotations: map[string]string{
naming.DefaultContainerLabel: naming.ContainerJobMovePGBackRestRepoDir,
naming.DefaultContainerAnnotation: naming.ContainerJobMovePGBackRestRepoDir,
}},
Spec: corev1.PodSpec{
// Set the image pull secrets, if any exist.
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/standalone_pgadmin/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func statefulset(
sts.Spec.Template.Annotations = naming.Merge(
pgadmin.Spec.Metadata.GetAnnotationsOrNil(),
map[string]string{
naming.DefaultContainerLabel: naming.ContainerPGAdmin,
naming.DefaultContainerAnnotation: naming.ContainerPGAdmin,
},
)
sts.Spec.Template.Labels = naming.Merge(
Expand Down
5 changes: 3 additions & 2 deletions internal/naming/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
AuthorizeBackupRemovalAnnotation = annotationPrefix + "authorizeBackupRemoval"

// Used from Kubernetes v1.21+ to define a default container used when the
// `-c` flag is not passed
DefaultContainerLabel = "kubectl.kubernetes.io/default-container"
// `-c` flag is not passed.
// --https://kubernetes.io/docs/reference/labels-annotations-taints/#kubectl-kubernetes-io-default-container
DefaultContainerAnnotation = "kubectl.kubernetes.io/default-container"
)

0 comments on commit ea35ac4

Please sign in to comment.