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

suggestion: fallback config diagnostics server #6184

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

czeslavo
Copy link
Contributor

@czeslavo czeslavo commented Jun 11, 2024

  • Extracts GeneratedCacheMetadataCollector for easier metadata collection (deduplication of excluded/backfilled objects was needed) and isolation
  • Adds unit tests for the diagnostics server and fallback config generator
  • Changes the response schema to include both excluded and backfilled objects at the same time (as that is a valid scenario: an object can be first excluded, then backfilled or not depending on the last valid cache state)
  • Ensures we push diagnostics only if they're enabled (c.diagnostic.FallbackCacheMetadata is not nil)
  • Extracts diagnostics server response schema types to a separate file for readability
  • Extracts config dump and fallback diagnostics retrieval handling methods in the server
  • Added status field to the response to clearly indicate whether the fallback config generation was triggered or not
  • Fixes cosmetic issues

Sample responses from manual testing:

excluded + backfilled

{
  "status": "triggered",
  "brokenObjects": [
    {
      "group": "configuration.konghq.com",
      "kind": "KongPlugin",
      "namespace": "default",
      "name": "rate-limit-consumer",
      "id": "0a823310-7b01-4e8e-b85e-1ebb160ddc3e"
    }
  ],
  "excludedObjects": [
    {
      "group": "configuration.konghq.com",
      "kind": "KongPlugin",
      "version": "v1",
      "namespace": "default",
      "name": "rate-limit-consumer",
      "id": "0a823310-7b01-4e8e-b85e-1ebb160ddc3e",
      "causingObjects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    },
    {
      "group": "gateway.networking.k8s.io",
      "kind": "HTTPRoute",
      "version": "v1",
      "namespace": "default",
      "name": "route-b",
      "id": "21c65967-909a-4a18-b875-c8d5652ee538",
      "causingObjects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    }
  ],
  "backfilledObjects": [
    {
      "group": "gateway.networking.k8s.io",
      "kind": "HTTPRoute",
      "version": "v1",
      "namespace": "default",
      "name": "route-b",
      "id": "21c65967-909a-4a18-b875-c8d5652ee538",
      "causingObjects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    },
    {
      "group": "configuration.konghq.com",
      "kind": "KongPlugin",
      "version": "v1",
      "namespace": "default",
      "name": "rate-limit-consumer",
      "id": "0a823310-7b01-4e8e-b85e-1ebb160ddc3e",
      "causingObjects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    },
    {
      "group": "configuration.konghq.com",
      "kind": "KongConsumer",
      "version": "v1",
      "namespace": "default",
      "name": "bob",
      "id": "bd24d998-2b37-46b4-896e-634c910226d6",
      "causingObjects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    }
  ]
}

only excluded

{
  "status": "triggered",
  "brokenObjects": [
    "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
  ],
  "excludedObjects": [
    {
      "resource": "configuration.konghq.com/v1, Kind=KongPlugin",
      "namespace": "default",
      "name": "rate-limit-consumer",
      "id": "0a823310-7b01-4e8e-b85e-1ebb160ddc3e",
      "causing_objects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    },
    {
      "resource": "gateway.networking.k8s.io/v1, Kind=HTTPRoute",
      "namespace": "default",
      "name": "route-b",
      "id": "21c65967-909a-4a18-b875-c8d5652ee538",
      "causing_objects": [
        "configuration.konghq.com/KongPlugin:default/rate-limit-consumer"
      ]
    }
  ]
}

no fallback triggered

{
  "status": "not_triggered"
}

@czeslavo czeslavo self-assigned this Jun 11, 2024
@czeslavo czeslavo added this to the KIC v3.2.x milestone Jun 11, 2024
@czeslavo czeslavo marked this pull request as ready for review June 11, 2024 13:53
@czeslavo czeslavo requested a review from a team as a code owner June 11, 2024 13:53
@czeslavo czeslavo merged commit 2731af4 into feat/diag-fallback-more Jun 11, 2024
44 checks passed
@czeslavo czeslavo deleted the feat/diag-fallback-suggestions branch June 11, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant