You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gateway/gateway-controller/pkg/utils/api_deployment.go
+61-5Lines changed: 61 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -340,7 +340,13 @@ func (s *APIDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
340
340
iferr:=s.db.SaveConfig(storedCfg); err!=nil {
341
341
// Check if it's a conflict (API already exists)
342
342
ifstorage.IsConflictError(err) {
343
-
returnfalse, fmt.Errorf("%w: configuration with name '%s' and version '%s' already exists", storage.ErrConflict, storedCfg.GetName(), storedCfg.GetVersion())
343
+
logger.Info("API configuration already exists in database, updating instead",
344
+
zap.String("api_id", storedCfg.ID),
345
+
zap.String("name", storedCfg.GetName()),
346
+
zap.String("version", storedCfg.GetVersion()))
347
+
348
+
// Try to update instead
349
+
returns.updateExistingConfig(storedCfg, logger)
344
350
} else {
345
351
returnfalse, fmt.Errorf("failed to save config to database: %w", err)
346
352
}
@@ -351,10 +357,13 @@ func (s *APIDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
351
357
iferr:=s.store.Add(storedCfg); err!=nil {
352
358
// Check if it's a conflict (API already exists)
353
359
ifstorage.IsConflictError(err) {
354
-
ifs.db!=nil {
355
-
_=s.db.DeleteConfig(storedCfg.ID)
356
-
}
357
-
returnfalse, fmt.Errorf("%w: configuration with name '%s' and version '%s' already exists", storage.ErrConflict, storedCfg.GetName(), storedCfg.GetVersion())
360
+
logger.Info("API configuration already exists in memory, updating instead",
361
+
zap.String("api_id", storedCfg.ID),
362
+
zap.String("name", storedCfg.GetName()),
363
+
zap.String("version", storedCfg.GetVersion()))
364
+
365
+
// Try to update instead
366
+
returns.updateExistingConfig(storedCfg, logger)
358
367
} else {
359
368
// Rollback database write (only if persistent mode)
360
369
ifs.db!=nil {
@@ -367,6 +376,53 @@ func (s *APIDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
367
376
returnfalse, nil// Successfully created new config
368
377
}
369
378
379
+
// updateExistingConfig updates an existing API configuration
Copy file name to clipboardExpand all lines: gateway/gateway-controller/pkg/utils/mcp_deployment.go
+63-5Lines changed: 63 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -200,7 +200,13 @@ func (s *MCPDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
200
200
iferr:=s.db.SaveConfig(storedCfg); err!=nil {
201
201
// Check if it's a conflict (Configuration already exists)
202
202
ifstorage.IsConflictError(err) {
203
-
returnfalse, fmt.Errorf("%w: configuration with name '%s' and version '%s' already exists", storage.ErrConflict, storedCfg.GetName(), storedCfg.GetVersion())
203
+
logger.Info("MCP configuration already exists in database, updating instead",
204
+
zap.String("id", storedCfg.ID),
205
+
zap.String("name", storedCfg.GetName()),
206
+
zap.String("version", storedCfg.GetVersion()))
207
+
208
+
// Try to update instead
209
+
returns.updateExistingConfig(storedCfg, logger)
204
210
} else {
205
211
returnfalse, fmt.Errorf("failed to save config to database: %w", err)
206
212
}
@@ -211,10 +217,13 @@ func (s *MCPDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
211
217
iferr:=s.store.Add(storedCfg); err!=nil {
212
218
// Check if it's a conflict (API already exists)
213
219
ifstorage.IsConflictError(err) {
214
-
ifs.db!=nil {
215
-
_=s.db.DeleteConfig(storedCfg.ID)
216
-
}
217
-
returnfalse, fmt.Errorf("%w: configuration with name '%s' and version '%s' already exists", storage.ErrConflict, storedCfg.GetName(), storedCfg.GetVersion())
220
+
logger.Info("MCP configuration already exists in memory, updating instead",
221
+
zap.String("id", storedCfg.ID),
222
+
zap.String("name", storedCfg.GetName()),
223
+
zap.String("version", storedCfg.GetVersion()))
224
+
225
+
// Try to update instead
226
+
returns.updateExistingConfig(storedCfg, logger)
218
227
} else {
219
228
// Rollback database write (only if persistent mode)
220
229
ifs.db!=nil {
@@ -226,3 +235,52 @@ func (s *MCPDeploymentService) saveOrUpdateConfig(storedCfg *models.StoredConfig
226
235
227
236
returnfalse, nil// Successfully created new config
228
237
}
238
+
239
+
// updateExistingConfig updates an existing API configuration
0 commit comments