From 8f9ad0668e413c7c330217b231e8cc1279246246 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Mon, 29 Jul 2024 14:33:00 +0200 Subject: [PATCH] Address code review suggestions Signed-off-by: Periklis Tsirakidis --- .../v1beta2/multiclusterobservability_types.go | 16 ++++++++++++++-- .../api/v1beta2/zz_generated.deepcopy.go | 6 +++--- ...rvability-operator.clusterserviceversion.yaml | 8 ++++++-- ...anagement.io_multiclusterobservabilities.yaml | 13 +++++++++---- ...anagement.io_multiclusterobservabilities.yaml | 13 +++++++++---- ...rvability-operator.clusterserviceversion.yaml | 6 +++++- .../pkg/rendering/renderer_mcoa.go | 2 +- .../pkg/rendering/renderer_mcoa_test.go | 6 ++++-- 8 files changed, 51 insertions(+), 19 deletions(-) diff --git a/operators/multiclusterobservability/api/v1beta2/multiclusterobservability_types.go b/operators/multiclusterobservability/api/v1beta2/multiclusterobservability_types.go index 77916586d..035adb0a5 100644 --- a/operators/multiclusterobservability/api/v1beta2/multiclusterobservability_types.go +++ b/operators/multiclusterobservability/api/v1beta2/multiclusterobservability_types.go @@ -60,7 +60,7 @@ type MultiClusterObservabilitySpec struct { type TShirtSize string // PlatformLogsCollectionSpec defines the spec for the addon to collect and forward logs -// from fleet managed clusters. +// from fleet managed clusters using the ClusterLogForwarder custom resource. type PlatformLogsCollectionSpec struct { // Enabled defines a flag to enable/disable the platform log collection. // @@ -70,6 +70,18 @@ type PlatformLogsCollectionSpec struct { Enabled bool `json:"enabled,omitempty"` } +// PlatformLogsSpec defines the spec for the addon to collect, forward and store logs +// from fleet managed clusters. +type PlatformLogsSpec struct { + // Collection defines the spec for the addon to collect and forward logs + // from fleet managed clusters. + // + // +optional + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Collection" + Collection PlatformLogsCollectionSpec `json:"collection,omitempty"` +} + // PlatformCapabilitiesSpec defines the observability capabilities managed by the addon // for platform components. type PlatformCapabilitiesSpec struct { @@ -79,7 +91,7 @@ type PlatformCapabilitiesSpec struct { // +optional // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Logs" - Logs PlatformLogsCollectionSpec `json:"logs,omitempty"` + Logs PlatformLogsSpec `json:"logs,omitempty"` } // ClusterLogForwarderSpec defines the spec for the addon to collect and forward logs diff --git a/operators/multiclusterobservability/api/v1beta2/zz_generated.deepcopy.go b/operators/multiclusterobservability/api/v1beta2/zz_generated.deepcopy.go index 0b75598b1..1184929f5 100644 --- a/operators/multiclusterobservability/api/v1beta2/zz_generated.deepcopy.go +++ b/operators/multiclusterobservability/api/v1beta2/zz_generated.deepcopy.go @@ -431,16 +431,16 @@ func (in *PlatformCapabilitiesSpec) DeepCopy() *PlatformCapabilitiesSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PlatformLogsCollectionSpec) DeepCopyInto(out *PlatformLogsCollectionSpec) { +func (in *PlatformLogsSpec) DeepCopyInto(out *PlatformLogsSpec) { *out = *in } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlatformLogsCollectionSpec. -func (in *PlatformLogsCollectionSpec) DeepCopy() *PlatformLogsCollectionSpec { +func (in *PlatformLogsSpec) DeepCopy() *PlatformLogsSpec { if in == nil { return nil } - out := new(PlatformLogsCollectionSpec) + out := new(PlatformLogsSpec) in.DeepCopyInto(out) return out } diff --git a/operators/multiclusterobservability/bundle/manifests/multicluster-observability-operator.clusterserviceversion.yaml b/operators/multiclusterobservability/bundle/manifests/multicluster-observability-operator.clusterserviceversion.yaml index 1ee2c113c..66a56c648 100644 --- a/operators/multiclusterobservability/bundle/manifests/multicluster-observability-operator.clusterserviceversion.yaml +++ b/operators/multiclusterobservability/bundle/manifests/multicluster-observability-operator.clusterserviceversion.yaml @@ -49,7 +49,7 @@ metadata: } ] capabilities: Basic Install - createdAt: "2024-07-29T07:45:11Z" + createdAt: "2024-07-29T12:28:25Z" operators.operatorframework.io/builder: operator-sdk-v1.34.2 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 name: multicluster-observability-operator.v0.1.0 @@ -90,9 +90,13 @@ spec: logs from platform components running on fleet managed clusters. displayName: Logs path: capabilities.platform.logs + - description: Collection defines the spec for the addon to collect and forward + logs from fleet managed clusters. + displayName: Collection + path: capabilities.platform.logs.collection - description: Enabled defines a flag to enable/disable the platform log collection. displayName: Enable - path: capabilities.platform.logs.enabled + path: capabilities.platform.logs.collection.enabled x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - description: UserWorkloads defines the spec for user workloads observability diff --git a/operators/multiclusterobservability/bundle/manifests/observability.open-cluster-management.io_multiclusterobservabilities.yaml b/operators/multiclusterobservability/bundle/manifests/observability.open-cluster-management.io_multiclusterobservabilities.yaml index a3c96e24f..ce73f6f74 100644 --- a/operators/multiclusterobservability/bundle/manifests/observability.open-cluster-management.io_multiclusterobservabilities.yaml +++ b/operators/multiclusterobservability/bundle/manifests/observability.open-cluster-management.io_multiclusterobservabilities.yaml @@ -10211,10 +10211,15 @@ spec: and storing logs from platform components running on fleet managed clusters. properties: - enabled: - description: Enabled defines a flag to enable/disable - the platform log collection. - type: boolean + collection: + description: Collection defines the spec for the addon + to collect and forward logs from fleet managed clusters. + properties: + enabled: + description: Enabled defines a flag to enable/disable + the platform log collection. + type: boolean + type: object type: object type: object userWorkloads: diff --git a/operators/multiclusterobservability/config/crd/bases/observability.open-cluster-management.io_multiclusterobservabilities.yaml b/operators/multiclusterobservability/config/crd/bases/observability.open-cluster-management.io_multiclusterobservabilities.yaml index 854984e24..401ff8ee8 100644 --- a/operators/multiclusterobservability/config/crd/bases/observability.open-cluster-management.io_multiclusterobservabilities.yaml +++ b/operators/multiclusterobservability/config/crd/bases/observability.open-cluster-management.io_multiclusterobservabilities.yaml @@ -10195,10 +10195,15 @@ spec: and storing logs from platform components running on fleet managed clusters. properties: - enabled: - description: Enabled defines a flag to enable/disable - the platform log collection. - type: boolean + collection: + description: Collection defines the spec for the addon + to collect and forward logs from fleet managed clusters. + properties: + enabled: + description: Enabled defines a flag to enable/disable + the platform log collection. + type: boolean + type: object type: object type: object userWorkloads: diff --git a/operators/multiclusterobservability/config/manifests/bases/multicluster-observability-operator.clusterserviceversion.yaml b/operators/multiclusterobservability/config/manifests/bases/multicluster-observability-operator.clusterserviceversion.yaml index 62fee01dd..89cfd2b92 100644 --- a/operators/multiclusterobservability/config/manifests/bases/multicluster-observability-operator.clusterserviceversion.yaml +++ b/operators/multiclusterobservability/config/manifests/bases/multicluster-observability-operator.clusterserviceversion.yaml @@ -42,9 +42,13 @@ spec: logs from platform components running on fleet managed clusters. displayName: Logs path: capabilities.platform.logs + - description: Collection defines the spec for the addon to collect and forward + logs from fleet managed clusters. + displayName: Collection + path: capabilities.platform.logs.collection - description: Enabled defines a flag to enable/disable the platform log collection. displayName: Enable - path: capabilities.platform.logs.enabled + path: capabilities.platform.logs.collection.enabled x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - description: UserWorkloads defines the spec for user workloads observability diff --git a/operators/multiclusterobservability/pkg/rendering/renderer_mcoa.go b/operators/multiclusterobservability/pkg/rendering/renderer_mcoa.go index a9800fbf2..39d58951b 100644 --- a/operators/multiclusterobservability/pkg/rendering/renderer_mcoa.go +++ b/operators/multiclusterobservability/pkg/rendering/renderer_mcoa.go @@ -176,7 +176,7 @@ func (r *MCORenderer) renderAddonDeploymentConfig( } if cs.Platform != nil { - if cs.Platform.Logs.Enabled { + if cs.Platform.Logs.Collection.Enabled { appendCustomVar(aodc, namePlatformLogsCollection, clfV1) } } diff --git a/operators/multiclusterobservability/pkg/rendering/renderer_mcoa_test.go b/operators/multiclusterobservability/pkg/rendering/renderer_mcoa_test.go index b20bd4ac8..4b33fcd64 100644 --- a/operators/multiclusterobservability/pkg/rendering/renderer_mcoa_test.go +++ b/operators/multiclusterobservability/pkg/rendering/renderer_mcoa_test.go @@ -128,8 +128,10 @@ func TestRenderAddonDeploymentConfig(t *testing.T) { Spec: mcov1beta2.MultiClusterObservabilitySpec{ Capabilities: &mcov1beta2.CapabilitiesSpec{ Platform: &mcov1beta2.PlatformCapabilitiesSpec{ - Logs: mcov1beta2.PlatformLogsCollectionSpec{ - Enabled: true, + Logs: mcov1beta2.PlatformLogsSpec{ + Collection: mcov1beta2.PlatformLogsCollectionSpec{ + Enabled: true, + }, }, }, UserWorkloads: &mcov1beta2.UserWorkloadCapabilitiesSpec{