@@ -134,7 +134,6 @@ func (c *Cluster) syncPublication(dbName string, databaseSlotsList map[string]za
134
134
} else if currentTables != tableList {
135
135
alterPublications [slotName ] = tableList
136
136
}
137
- (* slotsToSync )[slotName ] = slotAndPublication .Slot
138
137
}
139
138
140
139
// check if there is any deletion
@@ -148,24 +147,30 @@ func (c *Cluster) syncPublication(dbName string, databaseSlotsList map[string]za
148
147
return nil
149
148
}
150
149
150
+ var errorMessage error = nil
151
151
for publicationName , tables := range createPublications {
152
152
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
154
155
}
156
+ (* slotsToSync )[publicationName ] = databaseSlotsList [publicationName ].Slot
155
157
}
156
158
for publicationName , tables := range alterPublications {
157
159
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
159
162
}
163
+ (* slotsToSync )[publicationName ] = databaseSlotsList [publicationName ].Slot
160
164
}
161
165
for _ , publicationName := range deletePublications {
162
- (* slotsToSync )[publicationName ] = nil
163
166
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
165
169
}
170
+ (* slotsToSync )[publicationName ] = nil
166
171
}
167
172
168
- return nil
173
+ return errorMessage
169
174
}
170
175
171
176
func (c * Cluster ) generateFabricEventStream (appId string ) * zalandov1.FabricEventStream {
@@ -390,15 +395,15 @@ func (c *Cluster) syncStreams() error {
390
395
}
391
396
392
397
// finally sync stream CRDs
393
- err = c .createOrUpdateStreams ()
398
+ err = c .createOrUpdateStreams (slotsToSync )
394
399
if err != nil {
395
400
return err
396
401
}
397
402
398
403
return nil
399
404
}
400
405
401
- func (c * Cluster ) createOrUpdateStreams () error {
406
+ func (c * Cluster ) createOrUpdateStreams (createdSlots map [ string ] map [ string ] string ) error {
402
407
403
408
// fetch different application IDs from streams section
404
409
// there will be a separate event stream resource for each ID
@@ -413,7 +418,7 @@ func (c *Cluster) createOrUpdateStreams() error {
413
418
return fmt .Errorf ("could not list of FabricEventStreams: %v" , err )
414
419
}
415
420
416
- for _ , appId := range appIds {
421
+ for idx , appId := range appIds {
417
422
streamExists := false
418
423
419
424
// update stream when it exists and EventStreams array differs
@@ -435,6 +440,12 @@ func (c *Cluster) createOrUpdateStreams() error {
435
440
}
436
441
437
442
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
+ }
438
449
c .logger .Infof ("event streams with applicationId %s do not exist, create it" , appId )
439
450
streamCRD , err := c .createStreams (appId )
440
451
if err != nil {
0 commit comments