Skip to content

Commit 995c60b

Browse files
author
Jonathan S. Katz
committed
Ensure one can add tablespaces on an upgraded cluster
The "tablespaceMounts" portion of the CR would be "null" on an upgrade, which in turn would cause the unmarshaled map to be "nil". By initializing the map when a tablespace is being added to a cluster that was ugpraded from an earlier version of the PostgreSQL Operator, one can ensure successful addition and execution.
1 parent be873bd commit 995c60b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,12 @@ func UpdateCluster(request *msgs.UpdateClusterRequest) msgs.UpdateClusterRespons
17641764
cluster.Spec.EnableBackrestMemoryLimit = false
17651765
}
17661766

1767+
// if TablespaceMounts happens to be nil (e.g. an upgraded cluster), and
1768+
// the tablespaces are being updated, set it here
1769+
if len(request.Tablespaces) > 0 && cluster.Spec.TablespaceMounts == nil {
1770+
cluster.Spec.TablespaceMounts = map[string]crv1.PgStorageSpec{}
1771+
}
1772+
17671773
// extract the parameters for the TablespaceMounts and put them in the
17681774
// format that is required by the pgcluster CRD
17691775
for _, tablespace := range request.Tablespaces {

0 commit comments

Comments
 (0)