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

feat(telemetry) add Kong router flavor #4762

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Adding a new version? You'll need three changes:
- Get rid of deprecation warning in logs for unsupported label `global: true` for `KongPlugin`,
it'll be treated as any other label without a special meaning.
[#4737](https://github.com/Kong/kubernetes-ingress-controller/pull/4737)
- Telemetry now reports the router flavor.
[#4762](https://github.com/Kong/kubernetes-ingress-controller/pull/4762)

[KIC Annotations reference]: https://docs.konghq.com/kubernetes-ingress-controller/latest/references/annotations/

Expand Down
6 changes: 6 additions & 0 deletions internal/manager/telemetry/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ func SetupAnonymousReports(
if !ok {
return nil, fmt.Errorf("malformed database configuration found in Kong client root")
}
routerFlavor, ok := cfg["router_flavor"].(string)
if !ok {
// version to old to use router flavor, de facto traditional
routerFlavor = "traditional"
}

fixedPayload := Payload{
"v": metadata.Release,
"kv": kongVersion,
"db": kongDB,
"rf": routerFlavor,
"id": instanceIDProvider.GetID(), // universal unique identifier for this system
}

Expand Down
8 changes: 5 additions & 3 deletions test/envtest/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ func TestTelemetry(t *testing.T) {
waitTime = 3 * time.Second
tickTime = 10 * time.Millisecond
)
require.Eventually(t, func() bool {
require.Eventuallyf(t, func() bool {
select {
case report := <-reportChan:
return verifyTelemetryReport(t, k8sVersion, string(report))
case <-time.After(tickTime):
return false
}
}, waitTime, tickTime)
}, waitTime, tickTime, "telemetry report never matched expected value")
}

func configForEnvTestTelemetry(t *testing.T, envcfg *rest.Config, splunkEndpoint string, telemetryPeriod time.Duration) manager.Config {
Expand Down Expand Up @@ -340,7 +340,8 @@ func verifyTelemetryReport(t *testing.T, k8sVersion *version.Info, report string
for _, s := range []string{"id", "uptime"} {
report, err = removeStanzaFromReport(report, s)
if err != nil {
t.Logf("failed to remove stanza %q from report: %s", s, err)
// this normally happens during shutdown, when the report is an empty string
// no point in proceeding if so
return false
}
}
Expand All @@ -361,6 +362,7 @@ func verifyTelemetryReport(t *testing.T, k8sVersion *version.Info, report string
"feature-rewriteuris=false;"+
"hn=%s;"+
"kv=3.3.0;"+
"rf=traditional;"+
"v=NOT_SET;"+
"k8s_arch=%s;"+
"k8s_provider=UNKNOWN;"+
Expand Down