From 72f42fc0023a08136ffe9e56a537dc2242f7cfbe Mon Sep 17 00:00:00 2001 From: Stefan Hauth Date: Tue, 4 Feb 2025 18:33:56 +0100 Subject: [PATCH] Add possibility to enable Live Debugger module in ActiveGate. --- pkg/api/v1beta3/dynakube/activegate/spec.go | 6 ++++++ .../dynakube/activegate/capability/capability.go | 11 +++++++++++ .../activegate/capability/capability_test.go | 12 ++++++++++++ test/features/activegate/activegate.go | 1 + test/helpers/components/dynakube/options.go | 1 + 5 files changed, 31 insertions(+) diff --git a/pkg/api/v1beta3/dynakube/activegate/spec.go b/pkg/api/v1beta3/dynakube/activegate/spec.go index 992072897a..ff1231c57c 100644 --- a/pkg/api/v1beta3/dynakube/activegate/spec.go +++ b/pkg/api/v1beta3/dynakube/activegate/spec.go @@ -43,6 +43,11 @@ var ( ShortName: "dynatrace-api", ArgumentName: "restInterface", } + DebuggingCapability = Capability{ + DisplayName: "debugging", + ShortName: "debugging", + ArgumentName: "debugging", + } ) var CapabilityDisplayNames = map[CapabilityDisplayName]struct{}{ @@ -50,6 +55,7 @@ var CapabilityDisplayNames = map[CapabilityDisplayName]struct{}{ KubeMonCapability.DisplayName: {}, MetricsIngestCapability.DisplayName: {}, DynatraceApiCapability.DisplayName: {}, + DebuggingCapability.DisplayName: {}, } type ActiveGate struct { diff --git a/pkg/controllers/dynakube/activegate/capability/capability.go b/pkg/controllers/dynakube/activegate/capability/capability.go index 2d34468f3c..6224713353 100644 --- a/pkg/controllers/dynakube/activegate/capability/capability.go +++ b/pkg/controllers/dynakube/activegate/capability/capability.go @@ -19,6 +19,7 @@ var ( activegate.RoutingCapability.DisplayName: routingBase, activegate.MetricsIngestCapability.DisplayName: metricsIngestBase, activegate.DynatraceApiCapability.DisplayName: dynatraceApiBase, + activegate.DebuggingCapability.DisplayName: debuggingBase, } ) @@ -153,6 +154,16 @@ func dynatraceApiBase() *capabilityBase { return &c } +func debuggingBase() *capabilityBase { + c := capabilityBase{ + shortName: activegate.DebuggingCapability.ShortName, + argName: activegate.DebuggingCapability.ArgumentName, + displayName: string(activegate.DebuggingCapability.DisplayName), + } + + return &c +} + func GenerateActiveGateCapabilities(dk *dynakube.DynaKube) []Capability { return []Capability{ NewMultiCapability(dk), diff --git a/pkg/controllers/dynakube/activegate/capability/capability_test.go b/pkg/controllers/dynakube/activegate/capability/capability_test.go index c05bb186d9..8b551b9265 100644 --- a/pkg/controllers/dynakube/activegate/capability/capability_test.go +++ b/pkg/controllers/dynakube/activegate/capability/capability_test.go @@ -18,6 +18,7 @@ const ( testApiUrl = "https://demo.dev.dynatracelabs.com/api" expectedShortName = "activegate" expectedArgName = "MSGrouter,kubernetes_monitoring,metrics_ingest,restInterface" + expectedArgNameWithDebugging = "MSGrouter,kubernetes_monitoring,metrics_ingest,restInterface,debugging" expectedArgNameWithExtensions = "MSGrouter,kubernetes_monitoring,metrics_ingest,restInterface,extension_controller" expectedArgNameWithExtensionsOnly = "extension_controller" expectedArgNameWithOTLPingest = "MSGrouter,kubernetes_monitoring,metrics_ingest,restInterface,log_analytics_collector,generic_ingest_enabled,otlp_ingest" @@ -181,6 +182,17 @@ func TestNewMultiCapabilityWithOTLPingestAndTelemetryService(t *testing.T) { }) } +func TestNewMultiCapabilityWithDebugging(t *testing.T) { + t.Run(`creates new multicapability with debugging capability enabled`, func(t *testing.T) { + dk := buildDynakube(append(capabilities, activegate.DebuggingCapability.DisplayName), false, false, false) + mc := NewMultiCapability(dk) + require.NotNil(t, mc) + assert.True(t, mc.Enabled()) + assert.Equal(t, expectedShortName, mc.ShortName()) + assert.Equal(t, expectedArgNameWithDebugging, mc.ArgName()) + }) +} + func TestBuildServiceDomainNameForDNSEntryPoint(t *testing.T) { actual := buildServiceDomainName("test-name", "test-namespace", "test-component-feature") assert.NotEmpty(t, actual) diff --git a/test/features/activegate/activegate.go b/test/features/activegate/activegate.go index a887bcf145..54ca51fe0f 100644 --- a/test/features/activegate/activegate.go +++ b/test/features/activegate/activegate.go @@ -192,6 +192,7 @@ func assertExpectedModulesAreActive(t *testing.T, log string) { "kubernetes_monitoring", "odin_collector", "metrics_ingest", + "debugging", } head := strings.SplitAfter(log, "[, ModulesManager] Modules:") diff --git a/test/helpers/components/dynakube/options.go b/test/helpers/components/dynakube/options.go index a0a89f3cb5..9f62a73cc0 100644 --- a/test/helpers/components/dynakube/options.go +++ b/test/helpers/components/dynakube/options.go @@ -65,6 +65,7 @@ func WithActiveGate() Option { activegate.DynatraceApiCapability.DisplayName, activegate.RoutingCapability.DisplayName, activegate.MetricsIngestCapability.DisplayName, + activegate.DebuggingCapability.DisplayName, }, } }