Skip to content

Commit fa0597a

Browse files
authored
Add a version label (#613)
* Add a version label to the spilo pods (which might break / complicate inplace upgrades) * Add comment
1 parent c5fcd3d commit fa0597a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

api/v1/postgres_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const (
6262
StandbyMethod = "streaming_host"
6363
// PartitionIDLabelName Name of the managed-by label
6464
PartitionIDLabelName string = "postgres.database.fits.cloud/partition-id"
65+
// PostgresVersionLabelName Name of the version label
66+
PostgresVersionLabelName string = "postgres.database.fits.cloud/version"
6567

6668
ApplicationLabelName = "application"
6769
ApplicationLabelValue = "spilo"
@@ -679,6 +681,8 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor
679681
// Add the newly introduced label only here, not in p.ToZalandoPostgresqlMatchingLabels() (so that the selectors using p.ToZalandoPostgresqlMatchingLabels() will still work until all postgres resources have that new label)
680682
// TODO once all the custom resources have that new label, move this part to p.ToZalandoPostgresqlMatchingLabels()
681683
z.Labels[PartitionIDLabelName] = p.Spec.PartitionID
684+
// Add the additional version label to the custom resource
685+
z.Labels[PostgresVersionLabelName] = p.Spec.Version
682686

683687
if image != "" {
684688
z.Spec.DockerImage = image

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func main() {
254254
pgParamBlockList[blockedParam] = true
255255
}
256256

257+
// be careful changing this value if you also set the pg.PostgresVersionLabelName inherited_label
257258
viper.SetDefault(majorVersionUpgradeModeFlg, "manual")
258259
majorVersionUpgradeMode = viper.GetString(majorVersionUpgradeModeFlg)
259260

pkg/operatormanager/operatormanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (m *OperatorManager) editConfigMap(cm *corev1.ConfigMap, namespace string,
417417
// set the reference to our custom pod environment secret
418418
cm.Data["pod_environment_secret"] = PodEnvSecretName
419419
// set the list of inherited labels that will be passed on to the pods
420-
s := []string{pg.TenantLabelName, pg.ProjectIDLabelName, pg.UIDLabelName, pg.NameLabelName, pg.PartitionIDLabelName}
420+
s := []string{pg.TenantLabelName, pg.ProjectIDLabelName, pg.UIDLabelName, pg.NameLabelName, pg.PartitionIDLabelName, pg.PostgresVersionLabelName}
421421
// TODO maybe use a precompiled string here
422422
cm.Data["inherited_labels"] = strings.Join(s, ",")
423423

0 commit comments

Comments
 (0)