mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-03 18:22:09 +02:00
add resource annotation and ignore recovery type (#2817)
* add resource annotation and ignore recovery type * Update docs/reference/cluster_manifest.md --------- Co-authored-by: Ida Novindasari <idanovinda@gmail.com>
This commit is contained in:
co-authored by
Ida Novindasari
parent
301462c415
commit
80ef38f7f0
+28
-3
@@ -178,16 +178,35 @@ func (c *Cluster) syncPublication(dbName string, databaseSlotsList map[string]za
|
||||
|
||||
func (c *Cluster) generateFabricEventStream(appId string) *zalandov1.FabricEventStream {
|
||||
eventStreams := make([]zalandov1.EventStream, 0)
|
||||
resourceAnnotations := map[string]string{}
|
||||
|
||||
for _, stream := range c.Spec.Streams {
|
||||
if stream.ApplicationId != appId {
|
||||
continue
|
||||
}
|
||||
if stream.CPU != nil {
|
||||
cpu, exists := resourceAnnotations[constants.EventStreamCpuAnnotationKey]
|
||||
if exists {
|
||||
isSmaller, _ := util.IsSmallerQuantity(cpu, *stream.CPU)
|
||||
if isSmaller {
|
||||
resourceAnnotations[constants.EventStreamCpuAnnotationKey] = *stream.CPU
|
||||
}
|
||||
}
|
||||
}
|
||||
if stream.Memory != nil {
|
||||
memory, exists := resourceAnnotations[constants.EventStreamMemoryAnnotationKey]
|
||||
if exists {
|
||||
isSmaller, _ := util.IsSmallerQuantity(memory, *stream.Memory)
|
||||
if isSmaller {
|
||||
resourceAnnotations[constants.EventStreamMemoryAnnotationKey] = *stream.Memory
|
||||
}
|
||||
}
|
||||
}
|
||||
for tableName, table := range stream.Tables {
|
||||
streamSource := c.getEventStreamSource(stream, tableName, table.IdColumn)
|
||||
streamFlow := getEventStreamFlow(table.PayloadColumn)
|
||||
streamSink := getEventStreamSink(stream, table.EventType)
|
||||
streamRecovery := getEventStreamRecovery(stream, table.RecoveryEventType, table.EventType)
|
||||
streamRecovery := getEventStreamRecovery(stream, table.RecoveryEventType, table.EventType, table.IgnoreRecovery)
|
||||
|
||||
eventStreams = append(eventStreams, zalandov1.EventStream{
|
||||
EventStreamFlow: streamFlow,
|
||||
@@ -207,7 +226,7 @@ func (c *Cluster) generateFabricEventStream(appId string) *zalandov1.FabricEvent
|
||||
Name: fmt.Sprintf("%s-%s", c.Name, strings.ToLower(util.RandomPassword(5))),
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.labelsSet(true),
|
||||
Annotations: c.AnnotationsToPropagate(c.annotationsSet(nil)),
|
||||
Annotations: c.AnnotationsToPropagate(c.annotationsSet(resourceAnnotations)),
|
||||
OwnerReferences: c.ownerReferences(),
|
||||
},
|
||||
Spec: zalandov1.FabricEventStreamSpec{
|
||||
@@ -247,7 +266,7 @@ func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1.EventS
|
||||
}
|
||||
}
|
||||
|
||||
func getEventStreamRecovery(stream acidv1.Stream, recoveryEventType, eventType string) zalandov1.EventStreamRecovery {
|
||||
func getEventStreamRecovery(stream acidv1.Stream, recoveryEventType, eventType string, ignoreRecovery *bool) zalandov1.EventStreamRecovery {
|
||||
if (stream.EnableRecovery != nil && !*stream.EnableRecovery) ||
|
||||
(stream.EnableRecovery == nil && recoveryEventType == "") {
|
||||
return zalandov1.EventStreamRecovery{
|
||||
@@ -255,6 +274,12 @@ func getEventStreamRecovery(stream acidv1.Stream, recoveryEventType, eventType s
|
||||
}
|
||||
}
|
||||
|
||||
if ignoreRecovery != nil && *ignoreRecovery {
|
||||
return zalandov1.EventStreamRecovery{
|
||||
Type: constants.EventStreamRecoveryIgnoreType,
|
||||
}
|
||||
}
|
||||
|
||||
if stream.EnableRecovery != nil && *stream.EnableRecovery && recoveryEventType == "" {
|
||||
recoveryEventType = fmt.Sprintf("%s-%s", eventType, constants.EventStreamRecoverySuffix)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user