@@ -134,7 +134,6 @@ func (c *Cluster) syncPublication(dbName string, databaseSlotsList map[string]za
134134 } else if currentTables != tableList {
135135 alterPublications [slotName ] = tableList
136136 }
137- (* slotsToSync )[slotName ] = slotAndPublication .Slot
138137 }
139138
140139 // check if there is any deletion
@@ -148,24 +147,30 @@ func (c *Cluster) syncPublication(dbName string, databaseSlotsList map[string]za
148147 return nil
149148 }
150149
150+ var errorMessage error = nil
151151 for publicationName , tables := range createPublications {
152152 if err = c .executeCreatePublication (publicationName , tables ); err != nil {
153- return fmt .Errorf ("creation of publication %q failed: %v" , publicationName , err )
153+ errorMessage = fmt .Errorf ("creation of publication %q failed: %v" , publicationName , err )
154+ continue
154155 }
156+ (* slotsToSync )[publicationName ] = databaseSlotsList [publicationName ].Slot
155157 }
156158 for publicationName , tables := range alterPublications {
157159 if err = c .executeAlterPublication (publicationName , tables ); err != nil {
158- return fmt .Errorf ("update of publication %q failed: %v" , publicationName , err )
160+ errorMessage = fmt .Errorf ("update of publication %q failed: %v" , publicationName , err )
161+ continue
159162 }
163+ (* slotsToSync )[publicationName ] = databaseSlotsList [publicationName ].Slot
160164 }
161165 for _ , publicationName := range deletePublications {
162- (* slotsToSync )[publicationName ] = nil
163166 if err = c .executeDropPublication (publicationName ); err != nil {
164- return fmt .Errorf ("deletion of publication %q failed: %v" , publicationName , err )
167+ errorMessage = fmt .Errorf ("deletion of publication %q failed: %v" , publicationName , err )
168+ continue
165169 }
170+ (* slotsToSync )[publicationName ] = nil
166171 }
167172
168- return nil
173+ return errorMessage
169174}
170175
171176func (c * Cluster ) generateFabricEventStream (appId string ) * zalandov1.FabricEventStream {
@@ -390,15 +395,15 @@ func (c *Cluster) syncStreams() error {
390395 }
391396
392397 // finally sync stream CRDs
393- err = c .createOrUpdateStreams ()
398+ err = c .createOrUpdateStreams (slotsToSync )
394399 if err != nil {
395400 return err
396401 }
397402
398403 return nil
399404}
400405
401- func (c * Cluster ) createOrUpdateStreams () error {
406+ func (c * Cluster ) createOrUpdateStreams (createdSlots map [ string ] map [ string ] string ) error {
402407
403408 // fetch different application IDs from streams section
404409 // there will be a separate event stream resource for each ID
@@ -413,7 +418,7 @@ func (c *Cluster) createOrUpdateStreams() error {
413418 return fmt .Errorf ("could not list of FabricEventStreams: %v" , err )
414419 }
415420
416- for _ , appId := range appIds {
421+ for idx , appId := range appIds {
417422 streamExists := false
418423
419424 // update stream when it exists and EventStreams array differs
@@ -435,6 +440,12 @@ func (c *Cluster) createOrUpdateStreams() error {
435440 }
436441
437442 if ! streamExists {
443+ // check if there is any slot with the applicationId
444+ slotName := getSlotName (c .Spec .Streams [idx ].Database , appId )
445+ if _ , exists := createdSlots [slotName ]; ! exists {
446+ c .logger .Warningf ("no slot %s with applicationId %s exists, skipping event stream creation" , slotName , appId )
447+ continue
448+ }
438449 c .logger .Infof ("event streams with applicationId %s do not exist, create it" , appId )
439450 streamCRD , err := c .createStreams (appId )
440451 if err != nil {
0 commit comments