@@ -219,6 +219,10 @@ def write_config(namespace: str) -> object:
219
219
orig_config = prep_submitted_config (clone_yaml_files (yaml_documents ))
220
220
221
221
update_routes_flag = False
222
+
223
+ warning_message = ""
224
+ all_failed_routes = []
225
+ has_incompatible_routes = False
222
226
223
227
for index , gw_config in enumerate (yaml_documents ):
224
228
log .info ("[%s] Parsing file %s" % (namespace , index ))
@@ -240,19 +244,17 @@ def write_config(namespace: str) -> object:
240
244
# Enrich the rate-limiting plugin with the appropriate Redis details
241
245
plugins_transformations (namespace , gw_config )
242
246
243
- # Check Kong 3.x compatibility
244
- is_compatible , warning , kong2_config = check_kong3_compatibility (namespace , gw_config )
245
- if is_compatible :
246
- log .info ("[%s] Kong 3 compatibility check passed" % (namespace ))
247
- # If Kong 3 compatibility check passed, use the downgraded Kong 2 config
248
- # This is a temporary measure and can be removed once Kong 3 is deployed
247
+ # Check Kong 3 compatibility
248
+ is_compatible , warning_message , failed_routes , kong2_config = check_kong3_compatibility (namespace , gw_config )
249
+
250
+ # Track incompatible routes
251
+ if not is_compatible :
252
+ has_incompatible_routes = True
253
+ all_failed_routes .extend (failed_routes )
254
+
255
+ # Use kong2_config (which has compatibility tags) regardless of compatibility status
256
+ if kong2_config :
249
257
gw_config = kong2_config
250
- else :
251
- log .info ("[%s] Kong 3 compatibility warning: %s" % (namespace , warning ))
252
- # Add warning to the final results
253
- if 'warnings' not in locals ():
254
- warnings = []
255
- warnings .append ("Kong 3 Compatibility Warning: %s" % warning )
256
258
257
259
# After enrichments, dump config to file
258
260
with open ("%s/%s" % (tempFolder , 'config-%02d.yaml' % index ), 'w' ) as file :
@@ -423,8 +425,18 @@ def write_config(namespace: str) -> object:
423
425
record_gateway_event (event_id , 'published' , 'completed' , namespace , blob = orig_config )
424
426
425
427
results = mask (out .decode ('utf-8' ))
426
- if 'warnings' in locals () and warnings :
427
- results = results + "\n \n " + "\n " .join (warnings )
428
+
429
+ # Add Kong 3 compatibility warning if needed
430
+ if has_incompatible_routes :
431
+ # Add unique failed routes
432
+ unique_failed_routes = sorted (set (all_failed_routes ))
433
+ route_list = "\n " .join (f" - { route } " for route in unique_failed_routes )
434
+ warning_message = warning_message + "\n " + route_list
435
+
436
+ # Note: When all routes are compatible, no special response is given.
437
+ # To add the success message (contained in warning_message), move this
438
+ # line out of the if block above.
439
+ results = results + warning_message
428
440
429
441
return make_response (jsonify (message = message , results = results ))
430
442
0 commit comments