@@ -1051,7 +1051,7 @@ DBUSERS:
1051
1051
1052
1052
func (c * Cluster ) syncDatabases () error {
1053
1053
c .setProcessName ("syncing databases" )
1054
-
1054
+ errors := make ([] string , 0 )
1055
1055
createDatabases := make (map [string ]string )
1056
1056
alterOwnerDatabases := make (map [string ]string )
1057
1057
preparedDatabases := make ([]string , 0 )
@@ -1097,12 +1097,12 @@ func (c *Cluster) syncDatabases() error {
1097
1097
1098
1098
for databaseName , owner := range createDatabases {
1099
1099
if err = c .executeCreateDatabase (databaseName , owner ); err != nil {
1100
- return err
1100
+ errors = append ( errors , err . Error ())
1101
1101
}
1102
1102
}
1103
1103
for databaseName , owner := range alterOwnerDatabases {
1104
1104
if err = c .executeAlterDatabaseOwner (databaseName , owner ); err != nil {
1105
- return err
1105
+ errors = append ( errors , err . Error ())
1106
1106
}
1107
1107
}
1108
1108
@@ -1118,24 +1118,32 @@ func (c *Cluster) syncDatabases() error {
1118
1118
// set default privileges for prepared database
1119
1119
for _ , preparedDatabase := range preparedDatabases {
1120
1120
if err := c .initDbConnWithName (preparedDatabase ); err != nil {
1121
- return fmt .Errorf ("could not init database connection to %s" , preparedDatabase )
1121
+ errors = append (errors , fmt .Sprintf ("could not init database connection to %s" , preparedDatabase ))
1122
+ continue
1122
1123
}
1123
1124
1124
1125
for _ , owner := range c .getOwnerRoles (preparedDatabase , c .Spec .PreparedDatabases [preparedDatabase ].DefaultUsers ) {
1125
1126
if err = c .execAlterGlobalDefaultPrivileges (owner , preparedDatabase ); err != nil {
1126
- return err
1127
+ errors = append ( errors , err . Error ())
1127
1128
}
1128
1129
}
1129
1130
}
1130
1131
1132
+ if len (errors ) > 0 {
1133
+ return fmt .Errorf ("error(s) while syncing databases: %v" , strings .Join (errors , `', '` ))
1134
+ }
1135
+
1131
1136
return nil
1132
1137
}
1133
1138
1134
1139
func (c * Cluster ) syncPreparedDatabases () error {
1135
1140
c .setProcessName ("syncing prepared databases" )
1141
+ errors := make ([]string , 0 )
1142
+
1136
1143
for preparedDbName , preparedDB := range c .Spec .PreparedDatabases {
1137
1144
if err := c .initDbConnWithName (preparedDbName ); err != nil {
1138
- return fmt .Errorf ("could not init connection to database %s: %v" , preparedDbName , err )
1145
+ errors = append (errors , fmt .Sprintf ("could not init connection to database %s: %v" , preparedDbName , err ))
1146
+ continue
1139
1147
}
1140
1148
1141
1149
c .logger .Debugf ("syncing prepared database %q" , preparedDbName )
@@ -1145,24 +1153,30 @@ func (c *Cluster) syncPreparedDatabases() error {
1145
1153
preparedSchemas = map [string ]acidv1.PreparedSchema {"data" : {DefaultRoles : util .True ()}}
1146
1154
}
1147
1155
if err := c .syncPreparedSchemas (preparedDbName , preparedSchemas ); err != nil {
1148
- return err
1156
+ errors = append (errors , err .Error ())
1157
+ continue
1149
1158
}
1150
1159
1151
1160
// install extensions
1152
1161
if err := c .syncExtensions (preparedDB .Extensions ); err != nil {
1153
- return err
1162
+ errors = append ( errors , err . Error ())
1154
1163
}
1155
1164
1156
1165
if err := c .closeDbConn (); err != nil {
1157
1166
c .logger .Errorf ("could not close database connection: %v" , err )
1158
1167
}
1159
1168
}
1160
1169
1170
+ if len (errors ) > 0 {
1171
+ return fmt .Errorf ("error(s) while syncing prepared databases: %v" , strings .Join (errors , `', '` ))
1172
+ }
1173
+
1161
1174
return nil
1162
1175
}
1163
1176
1164
1177
func (c * Cluster ) syncPreparedSchemas (databaseName string , preparedSchemas map [string ]acidv1.PreparedSchema ) error {
1165
1178
c .setProcessName ("syncing prepared schemas" )
1179
+ errors := make ([]string , 0 )
1166
1180
1167
1181
currentSchemas , err := c .getSchemas ()
1168
1182
if err != nil {
@@ -1185,17 +1199,21 @@ func (c *Cluster) syncPreparedSchemas(databaseName string, preparedSchemas map[s
1185
1199
owner = dbOwner
1186
1200
}
1187
1201
if err = c .executeCreateDatabaseSchema (databaseName , schemaName , dbOwner , owner ); err != nil {
1188
- return err
1202
+ errors = append ( errors , err . Error ())
1189
1203
}
1190
1204
}
1191
1205
}
1192
1206
1207
+ if len (errors ) > 0 {
1208
+ return fmt .Errorf ("error(s) while syncing schemas of prepared databases: %v" , strings .Join (errors , `', '` ))
1209
+ }
1210
+
1193
1211
return nil
1194
1212
}
1195
1213
1196
1214
func (c * Cluster ) syncExtensions (extensions map [string ]string ) error {
1197
1215
c .setProcessName ("syncing database extensions" )
1198
-
1216
+ errors := make ([] string , 0 )
1199
1217
createExtensions := make (map [string ]string )
1200
1218
alterExtensions := make (map [string ]string )
1201
1219
@@ -1215,15 +1233,19 @@ func (c *Cluster) syncExtensions(extensions map[string]string) error {
1215
1233
1216
1234
for extName , schema := range createExtensions {
1217
1235
if err = c .executeCreateExtension (extName , schema ); err != nil {
1218
- return err
1236
+ errors = append ( errors , err . Error ())
1219
1237
}
1220
1238
}
1221
1239
for extName , schema := range alterExtensions {
1222
1240
if err = c .executeAlterExtension (extName , schema ); err != nil {
1223
- return err
1241
+ errors = append ( errors , err . Error ())
1224
1242
}
1225
1243
}
1226
1244
1245
+ if len (errors ) > 0 {
1246
+ return fmt .Errorf ("error(s) while syncing database extensions: %v" , strings .Join (errors , `', '` ))
1247
+ }
1248
+
1227
1249
return nil
1228
1250
}
1229
1251
0 commit comments