Skip to content

Commit

Permalink
Rename extensions prometheus enabled flag to extensions enabled (#3796)
Browse files Browse the repository at this point in the history
  • Loading branch information
wepudt authored Sep 18, 2024
1 parent c3d04da commit da71084
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 119 deletions.
11 changes: 3 additions & 8 deletions config/crd/bases/dynatrace.com_dynakubes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.2
controller-gen.kubebuilder.io/version: v0.16.3
name: dynakubes.dynatrace.com
spec:
group: dynatrace.com
Expand Down Expand Up @@ -5003,13 +5003,8 @@ spec:
type: boolean
extensions:
properties:
prometheus:
properties:
enabled:
type: boolean
required:
- enabled
type: object
enabled:
type: boolean
type: object
logModule:
description: General configuration about the LogModule feature.
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/dynatrace.com_edgeconnects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.2
controller-gen.kubebuilder.io/version: v0.16.3
name: edgeconnects.dynatrace.com
spec:
group: dynatrace.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.2
controller-gen.kubebuilder.io/version: v0.16.3
name: dynakubes.dynatrace.com
spec:
conversion:
Expand Down Expand Up @@ -5015,13 +5015,8 @@ spec:
type: boolean
extensions:
properties:
prometheus:
properties:
enabled:
type: boolean
required:
- enabled
type: object
enabled:
type: boolean
type: object
logModule:
description: General configuration about the LogModule feature.
Expand Down Expand Up @@ -7363,7 +7358,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.2
controller-gen.kubebuilder.io/version: v0.16.3
name: edgeconnects.dynatrace.com
spec:
conversion:
Expand Down
12 changes: 6 additions & 6 deletions doc/api/dynakube-api-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
|`tolerations`|Set tolerations for the ActiveGate pods|-|array|
|`topologySpreadConstraints`|Adds TopologySpreadConstraints for the ActiveGate pods|-|array|

### .spec.extensions

|Parameter|Description|Default value|Data type|
|:-|:-|:-|:-|
|`enabled`||-|boolean|

### .spec.metadataEnrichment

|Parameter|Description|Default value|Data type|
Expand All @@ -67,12 +73,6 @@
|`secCompProfile`|The SecComp Profile that will be configured in order to run in secure computing mode for the LogModule pods|-|string|
|`tolerations`|Set tolerations for the LogModule pods|-|array|

### .spec.extensions.prometheus

|Parameter|Description|Default value|Data type|
|:-|:-|:-|:-|
|`enabled`||-|boolean|

### .spec.oneAgent.hostMonitoring

|Parameter|Description|Default value|Data type|
Expand Down
6 changes: 1 addition & 5 deletions pkg/api/v1beta3/dynakube/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import (

type ExtensionsSpec struct {
// +kubebuilder:validation:Optional
Prometheus PrometheusSpec `json:"prometheus,omitempty"`
}

type PrometheusSpec struct {
Enabled bool `json:"enabled"`
Enabled bool `json:"enabled,omitempty"`
}

type ExtensionExecutionControllerSpec struct {
Expand Down
6 changes: 1 addition & 5 deletions pkg/api/v1beta3/dynakube/extensions_props.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ const (
)

func (dk *DynaKube) IsExtensionsEnabled() bool {
return dk.Spec.Extensions.Prometheus.Enabled
}

func (dk *DynaKube) PrometheusEnabled() bool {
return dk.Spec.Extensions.Prometheus.Enabled
return dk.Spec.Extensions.Enabled
}
4 changes: 2 additions & 2 deletions pkg/api/v1beta3/dynakube/validation/eec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const (
errorExtensionExecutionControllerImageNotSpecified = `DynaKube's specification enables the Prometheus feature, make sure you correctly specify the ExtensionExecutionController image.`
)

func extensionControllerImage(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string {
if !dk.PrometheusEnabled() {
func extensionControllerImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
if !dk.IsExtensionsEnabled() {
return ""
}

Expand Down
16 changes: 4 additions & 12 deletions pkg/api/v1beta3/dynakube/validation/eec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ func TestExtensionExecutionControllerImage(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
APIURL: testApiUrl,
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
Templates: dynakube.TemplatesSpec{
ExtensionExecutionController: dynakube.ExtensionExecutionControllerSpec{
Expand All @@ -38,9 +36,7 @@ func TestExtensionExecutionControllerImage(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
APIURL: testApiUrl,
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
Templates: dynakube.TemplatesSpec{
ExtensionExecutionController: dynakube.ExtensionExecutionControllerSpec{
Expand All @@ -61,9 +57,7 @@ func TestExtensionExecutionControllerImage(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
APIURL: testApiUrl,
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
Templates: dynakube.TemplatesSpec{
ExtensionExecutionController: dynakube.ExtensionExecutionControllerSpec{
Expand All @@ -84,9 +78,7 @@ func TestExtensionExecutionControllerImage(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
APIURL: testApiUrl,
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
},
})
Expand Down
16 changes: 0 additions & 16 deletions pkg/api/v1beta3/dynakube/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ func buildDynakube(capabilities []dynakube.CapabilityDisplayName, enableExtensio
Capabilities: capabilities,
},
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: enableExtensions,
},
Enabled: enableExtensions,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type EecModifier struct {
}

func (mod EecModifier) Enabled() bool {
return mod.dk.PrometheusEnabled()
return mod.dk.IsExtensionsEnabled()
}

func (mod EecModifier) Modify(sts *appsv1.StatefulSet) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
)

func TestEecEnabled(t *testing.T) {
t.Run("Prometheus extension is enabled", func(t *testing.T) {
t.Run("Extensions are enabled", func(t *testing.T) {
dk := getBaseDynakube()
dk.Spec.Extensions.Prometheus.Enabled = true
dk.Spec.Extensions.Enabled = true

mod := NewEecVolumeModifier(dk)

assert.True(t, mod.Enabled())
})

t.Run("Prometheus extension is disabled", func(t *testing.T) {
t.Run("Extension are disabled", func(t *testing.T) {
dk := getBaseDynakube()
dk.Spec.Extensions.Prometheus.Enabled = false
dk.Spec.Extensions.Enabled = false

mod := NewEecVolumeModifier(dk)

Expand All @@ -30,7 +30,7 @@ func TestEecEnabled(t *testing.T) {
func TestEecModify(t *testing.T) {
t.Run("Statefulset is successfully modified with eec volume", func(t *testing.T) {
dk := getBaseDynakube()
dk.Spec.Extensions.Prometheus.Enabled = true
dk.Spec.Extensions.Enabled = true

mod := NewEecVolumeModifier(dk)
builder := createBuilderForTesting()
Expand Down
22 changes: 6 additions & 16 deletions pkg/controllers/dynakube/activegate/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
ActiveGate: dynakube.ActiveGateSpec{Capabilities: []dynakube.CapabilityDisplayName{}},
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: false,
},
Enabled: false,
},
},
}
Expand Down Expand Up @@ -275,9 +273,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
},
Spec: dynakube.DynaKubeSpec{
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
},
}
Expand Down Expand Up @@ -310,9 +306,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
ActiveGate: dynakube.ActiveGateSpec{Capabilities: []dynakube.CapabilityDisplayName{}},
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
},
}
Expand Down Expand Up @@ -345,9 +339,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
ActiveGate: dynakube.ActiveGateSpec{Capabilities: []dynakube.CapabilityDisplayName{dynakube.KubeMonCapability.DisplayName}},
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
},
}
Expand Down Expand Up @@ -380,9 +372,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
Spec: dynakube.DynaKubeSpec{
ActiveGate: dynakube.ActiveGateSpec{Capabilities: []dynakube.CapabilityDisplayName{dynakube.KubeMonCapability.DisplayName}},
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
},
}
Expand Down Expand Up @@ -423,7 +413,7 @@ func TestExtensionControllerRequiresActiveGate(t *testing.T) {
require.NoError(t, err)

// disable extensions
r.dk.Spec.Extensions.Prometheus.Enabled = false
r.dk.Spec.Extensions.Enabled = false
r.connectionReconciler = createGenericReconcilerMock(t)
r.versionReconciler = createVersionReconcilerMock(t)
r.pullSecretReconciler = createGenericReconcilerMock(t)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/dynakube/extension/eec/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewReconciler(clt client.Client, apiReader client.Reader, dk *dynakube.Dyna
}

func (r *reconciler) Reconcile(ctx context.Context) error {
if !r.dk.PrometheusEnabled() {
if !r.dk.IsExtensionsEnabled() {
if meta.FindStatusCondition(*r.dk.Conditions(), extensionsControllerStatefulSetConditionType) == nil {
return nil
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/controllers/dynakube/extension/eec/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ func getTestDynakube() *dynakube.DynaKube {
},
Spec: dynakube.DynaKubeSpec{
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
Templates: dynakube.TemplatesSpec{
ExtensionExecutionController: dynakube.ExtensionExecutionControllerSpec{
Expand Down Expand Up @@ -117,9 +115,9 @@ func TestConditions(t *testing.T) {
assert.True(t, errors.IsNotFound(err))
})

t.Run("prometheus is disabled", func(t *testing.T) {
t.Run("extensions are disabled", func(t *testing.T) {
dk := getTestDynakube()
dk.Spec.Extensions.Prometheus.Enabled = false
dk.Spec.Extensions.Enabled = false
conditions.SetStatefulSetCreated(dk.Conditions(), extensionsControllerStatefulSetConditionType, dynakube.ExtensionsExecutionControllerStatefulsetName)

mockK8sClient := fake.NewClient(dk)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/dynakube/extension/otel/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewReconciler(clt client.Client, apiReader client.Reader, dk *dynakube.Dyna
}

func (r *reconciler) Reconcile(ctx context.Context) error {
if !r.dk.PrometheusEnabled() {
if !r.dk.IsExtensionsEnabled() {
if meta.FindStatusCondition(*r.dk.Conditions(), otelControllerStatefulSetConditionType) == nil {
return nil
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/controllers/dynakube/extension/otel/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ func getTestDynakube() *dynakube.DynaKube {
},
Spec: dynakube.DynaKubeSpec{
Extensions: dynakube.ExtensionsSpec{
Prometheus: dynakube.PrometheusSpec{
Enabled: true,
},
Enabled: true,
},
Templates: dynakube.TemplatesSpec{OpenTelemetryCollector: dynakube.OpenTelemetryCollectorSpec{}},
},
Expand All @@ -61,9 +59,9 @@ func getStatefulset(t *testing.T, dk *dynakube.DynaKube) *appsv1.StatefulSet {
}

func TestConditions(t *testing.T) {
t.Run("prometheus is disabled", func(t *testing.T) {
t.Run("extensions are disabled", func(t *testing.T) {
dk := getTestDynakube()
dk.Spec.Extensions.Prometheus.Enabled = false
dk.Spec.Extensions.Enabled = false
conditions.SetStatefulSetCreated(dk.Conditions(), otelControllerStatefulSetConditionType, dynakube.ExtensionsCollectorStatefulsetName)

mockK8sClient := fake.NewClient(dk)
Expand Down
Loading

0 comments on commit da71084

Please sign in to comment.