Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][spike] feat: build fallback config #4735

Closed
wants to merge 5 commits into from
Closed

Conversation

czeslavo
Copy link
Contributor

What this PR does / why we need it:

It's a rough PoC that implements a way to recover from an invalid configuration (in DB-less mode). How it works:

  • build a configuration out of the current Kubernetes cache state (current config),
  • (optional) detect issues of the built configuration upfront for errors that Kong doesn't catch properly today (e.g. multiple instances of the same plugin type used by a single service/route returns no detailed errors pointing to the affected entities in the flat errors response) - it's not implemented in this PoC.
  • try to apply the configuration to Kong,
  • Kong rejects the configuration (i.e. there was an error that we weren't able to catch before sending it)
  • take the last known good configuration and build an undirected graph from it that reflects relations between entities (every entity is a vertex, and every relation is an edge)
  • do the same for the current configuration (the one we know has errors)
  • find connected components of both graphs that include the error-affected entities (e.g. if a Plugin has an invalid configuration and it's attached to a Service, we'd get a component consisting of the Plugin, the Service, and Routes attached to the Service)
  • build a fallback config by
    • copying the current configuration graph
    • removing the component that includes the affected entity
    • adding the component that includes the affected entity (or any of the entities from the faulty component) from the last known good config (if it was found)
  • send the fallback config to Kong and expect success (in the case of failure - fallback to using the last known good config as whole)

Which issue this PR fixes:

Aims to prepare a solution that could solve #2195.

@czeslavo czeslavo self-assigned this Sep 27, 2023
@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (11cfdb9) 67.9% compared to head (b66ca85) 0.0%.
Report is 391 commits behind head on main.

❗ Current head b66ca85 differs from pull request most recent head b85a741. Consider uploading reports for the commit b85a741 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##            main   #4735      +/-   ##
========================================
- Coverage   67.9%       0   -68.0%     
========================================
  Files        164       0     -164     
  Lines      19289       0   -19289     
========================================
- Hits       13107       0   -13107     
+ Misses      5414       0    -5414     
+ Partials     768       0     -768     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant