mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 07:41:30 +02:00
Use deepcopy to propagate the spec to clusters.
Avoid sharing pointers to the same spec data between the informer and the clusters. The only catch is that the error field is cleared during deepcopy, since it is an interface that may contain private fields that cannot be copied, however, the error is only used when the manifest is parsed and before it is queued, therefore, we never refer to that field in the cluster structure.
This commit is contained in:
@@ -348,10 +348,9 @@ func (c *Controller) mergeDeprecatedPostgreSQLSpecParameters(spec *spec.Postgres
|
||||
|
||||
func (c *Controller) queueClusterEvent(informerOldSpec, informerNewSpec *spec.Postgresql, eventType spec.EventType) {
|
||||
var (
|
||||
uid types.UID
|
||||
clusterName spec.NamespacedName
|
||||
clusterError error
|
||||
oldSpec, newSpec *spec.Postgresql
|
||||
uid types.UID
|
||||
clusterName spec.NamespacedName
|
||||
clusterError error
|
||||
)
|
||||
|
||||
if informerOldSpec != nil { //update, delete
|
||||
@@ -380,22 +379,13 @@ func (c *Controller) queueClusterEvent(informerOldSpec, informerNewSpec *spec.Po
|
||||
// in the informer internal state, making it incohherent with the actual Kubernetes object (and, as a side
|
||||
// effect, the modified state will be returned together with subsequent events).
|
||||
|
||||
if informerOldSpec != nil {
|
||||
t := *informerOldSpec
|
||||
oldSpec = &t
|
||||
}
|
||||
if informerNewSpec != nil {
|
||||
t := *informerNewSpec
|
||||
newSpec = &t
|
||||
}
|
||||
|
||||
workerID := c.clusterWorkerID(clusterName)
|
||||
clusterEvent := spec.ClusterEvent{
|
||||
EventTime: time.Now(),
|
||||
EventType: eventType,
|
||||
UID: uid,
|
||||
OldSpec: oldSpec,
|
||||
NewSpec: newSpec,
|
||||
OldSpec: informerOldSpec.Clone(),
|
||||
NewSpec: informerNewSpec.Clone(),
|
||||
WorkerID: workerID,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user