Skip to content

Commit d4f10fa

Browse files
jcantrillopenshift-merge-bot[bot]
authored andcommitted
LOG-7618: Modify lokistack datamodel to default to 'Otel' in lieu of 'Viaq'
1 parent ca54f0c commit d4f10fa

File tree

13 files changed

+184
-23
lines changed

13 files changed

+184
-23
lines changed

api/observability/v1/output_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,10 @@ type LokiStack struct {
834834
//
835835
// There are two different models to choose from:
836836
//
837-
// - Viaq
837+
// - Viaq (DEPRECATED: To be ignored in a future release)
838838
// - Otel
839839
//
840-
// When the data model is not set, it currently defaults to the "Viaq" data model.
840+
// When the data model is not set, it currently defaults to the "Otel" data model.
841841
//
842842
// +kubebuilder:validation:Optional
843843
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Data Model"

bundle/manifests/cluster-logging.clusterserviceversion.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ metadata:
8282
categories: OpenShift Optional, Logging & Tracing, Observability
8383
certified: "false"
8484
containerImage: quay.io/openshift-logging/cluster-logging-operator:latest
85-
createdAt: "2025-09-03T01:08:59Z"
85+
createdAt: "2025-09-11T16:25:19Z"
8686
description: The Red Hat OpenShift Logging Operator for OCP provides a means for
8787
configuring and managing log collection and forwarding.
8888
features.operators.openshift.io/cnf: "false"
@@ -1167,10 +1167,10 @@ spec:
11671167
11681168
There are two different models to choose from:
11691169
1170-
- Viaq
1170+
- Viaq (DEPRECATED: To be ignored in a future release)
11711171
- Otel
11721172
1173-
When the data model is not set, it currently defaults to the "Viaq" data model.
1173+
When the data model is not set, it currently defaults to the "Otel" data model.
11741174
displayName: Data Model
11751175
path: outputs[0].lokiStack.dataModel
11761176
- description: |-

bundle/manifests/observability.openshift.io_clusterlogforwarders.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,10 +2838,10 @@ spec:
28382838
28392839
There are two different models to choose from:
28402840
2841-
- Viaq
2841+
- Viaq (DEPRECATED: To be ignored in a future release)
28422842
- Otel
28432843
2844-
When the data model is not set, it currently defaults to the "Viaq" data model.
2844+
When the data model is not set, it currently defaults to the "Otel" data model.
28452845
enum:
28462846
- Viaq
28472847
- Otel

config/crd/bases/observability.openshift.io_clusterlogforwarders.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,10 +2838,10 @@ spec:
28382838
28392839
There are two different models to choose from:
28402840
2841-
- Viaq
2841+
- Viaq (DEPRECATED: To be ignored in a future release)
28422842
- Otel
28432843
2844-
When the data model is not set, it currently defaults to the "Viaq" data model.
2844+
When the data model is not set, it currently defaults to the "Otel" data model.
28452845
enum:
28462846
- Viaq
28472847
- Otel

config/manifests/bases/cluster-logging.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,10 +1090,10 @@ spec:
10901090
10911091
There are two different models to choose from:
10921092
1093-
- Viaq
1093+
- Viaq (DEPRECATED: To be ignored in a future release)
10941094
- Otel
10951095
1096-
When the data model is not set, it currently defaults to the "Viaq" data model.
1096+
When the data model is not set, it currently defaults to the "Otel" data model.
10971097
displayName: Data Model
10981098
path: outputs[0].lokiStack.dataModel
10991099
- description: |-

docs/reference/operator/api_observability_v1.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,10 +2758,10 @@ Type:: object
27582758

27592759
There are two different models to choose from:
27602760

2761-
- Viaq
2761+
- Viaq (DEPRECATED: To be ignored in a future release)
27622762
- Otel
27632763

2764-
When the data model is not set, it currently defaults to the "Viaq" data model.
2764+
When the data model is not set, it currently defaults to the "Otel" data model.
27652765

27662766
|labelKeys|object| LabelKeys can be used to customize which log record keys are mapped to Loki stream labels.
27672767

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package initialize
2+
3+
import (
4+
obs "github.com/openshift/cluster-logging-operator/api/observability/v1"
5+
"github.com/openshift/cluster-logging-operator/internal/constants"
6+
"github.com/openshift/cluster-logging-operator/internal/utils"
7+
"github.com/openshift/cluster-logging-operator/internal/validations/observability/common"
8+
)
9+
10+
// MigrateOutputs initializes the outputs for a ClusterLogForwarder
11+
func MigrateOutputs(forwarder obs.ClusterLogForwarder, options utils.Options) obs.ClusterLogForwarder {
12+
enabled := common.IsEnabledAnnotation(forwarder, constants.AnnotationOtlpOutputTechPreview)
13+
for _, o := range forwarder.Spec.Outputs {
14+
if enabled {
15+
if o.Type == obs.OutputTypeLokiStack && o.LokiStack != nil && o.LokiStack.DataModel == "" {
16+
o.LokiStack.DataModel = obs.LokiStackDataModelOpenTelemetry
17+
}
18+
} else if o.Type == obs.OutputTypeLokiStack && o.LokiStack != nil {
19+
o.LokiStack.DataModel = obs.LokiStackDataModelViaq
20+
}
21+
}
22+
return forwarder
23+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package initialize
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
obs "github.com/openshift/cluster-logging-operator/api/observability/v1"
7+
"github.com/openshift/cluster-logging-operator/internal/constants"
8+
"github.com/openshift/cluster-logging-operator/internal/utils"
9+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
)
11+
12+
var _ = Describe("migrateOutputs", func() {
13+
var (
14+
initContext utils.Options
15+
)
16+
BeforeEach(func() {
17+
initContext = utils.Options{}
18+
})
19+
Context("for LokiStack outputs", func() {
20+
21+
Context("when the OTLP Tech-preview feature is not enabled", func() {
22+
It("should set the datamodel to 'Viaq' regardless of of the value spec'd for the datamodel", func() {
23+
forwarder := obs.ClusterLogForwarder{
24+
Spec: obs.ClusterLogForwarderSpec{
25+
Outputs: []obs.OutputSpec{
26+
{
27+
Name: "anOutput",
28+
Type: obs.OutputTypeLokiStack,
29+
LokiStack: &obs.LokiStack{
30+
DataModel: obs.LokiStackDataModelOpenTelemetry,
31+
}},
32+
},
33+
},
34+
}
35+
result := MigrateOutputs(forwarder, initContext)
36+
Expect(result.Spec.Outputs).To(HaveLen(1))
37+
Expect(result.Spec.Outputs[0]).To(Equal(obs.OutputSpec{
38+
Name: "anOutput",
39+
Type: obs.OutputTypeLokiStack,
40+
LokiStack: &obs.LokiStack{
41+
DataModel: obs.LokiStackDataModelViaq,
42+
},
43+
}))
44+
})
45+
46+
})
47+
48+
Context("when the OTLP Tech-preview feature is enabled", func() {
49+
50+
It("should set the datamodel to 'Otel' when the datamodel is not spec'd", func() {
51+
forwarder := obs.ClusterLogForwarder{
52+
ObjectMeta: v1.ObjectMeta{
53+
Annotations: map[string]string{
54+
constants.AnnotationOtlpOutputTechPreview: "enabled",
55+
},
56+
},
57+
Spec: obs.ClusterLogForwarderSpec{
58+
Outputs: []obs.OutputSpec{
59+
{
60+
Name: "anOutput",
61+
Type: obs.OutputTypeLokiStack,
62+
LokiStack: &obs.LokiStack{},
63+
},
64+
},
65+
},
66+
}
67+
result := MigrateOutputs(forwarder, initContext)
68+
Expect(result.Spec.Outputs).To(HaveLen(1))
69+
Expect(result.Spec.Outputs[0]).To(Equal(obs.OutputSpec{
70+
Name: "anOutput",
71+
Type: obs.OutputTypeLokiStack,
72+
LokiStack: &obs.LokiStack{
73+
DataModel: obs.LokiStackDataModelOpenTelemetry,
74+
},
75+
}))
76+
})
77+
It("should honor the datamodel 'ViaQ' when the datamodel is spec'd to ViaQ", func() {
78+
forwarder := obs.ClusterLogForwarder{
79+
ObjectMeta: v1.ObjectMeta{
80+
Annotations: map[string]string{
81+
constants.AnnotationOtlpOutputTechPreview: "true",
82+
},
83+
},
84+
Spec: obs.ClusterLogForwarderSpec{
85+
Outputs: []obs.OutputSpec{
86+
{
87+
Name: "anOutput",
88+
Type: obs.OutputTypeLokiStack,
89+
LokiStack: &obs.LokiStack{
90+
DataModel: obs.LokiStackDataModelViaq,
91+
},
92+
},
93+
},
94+
},
95+
}
96+
result := MigrateOutputs(forwarder, initContext)
97+
Expect(result.Spec.Outputs).To(HaveLen(1))
98+
Expect(result.Spec.Outputs[0]).To(Equal(obs.OutputSpec{
99+
Name: "anOutput",
100+
Type: obs.OutputTypeLokiStack,
101+
LokiStack: &obs.LokiStack{
102+
DataModel: obs.LokiStackDataModelViaq,
103+
},
104+
}))
105+
})
106+
It("should honor the datamodel 'Otel' when the datamodel is spec'd to Otel", func() {
107+
forwarder := obs.ClusterLogForwarder{
108+
ObjectMeta: v1.ObjectMeta{
109+
Annotations: map[string]string{
110+
constants.AnnotationOtlpOutputTechPreview: "true",
111+
},
112+
},
113+
Spec: obs.ClusterLogForwarderSpec{
114+
Outputs: []obs.OutputSpec{
115+
{
116+
Name: "anOutput",
117+
Type: obs.OutputTypeLokiStack,
118+
LokiStack: &obs.LokiStack{
119+
DataModel: obs.LokiStackDataModelOpenTelemetry,
120+
},
121+
},
122+
},
123+
},
124+
}
125+
result := MigrateOutputs(forwarder, initContext)
126+
Expect(result.Spec.Outputs).To(HaveLen(1))
127+
Expect(result.Spec.Outputs[0]).To(Equal(obs.OutputSpec{
128+
Name: "anOutput",
129+
Type: obs.OutputTypeLokiStack,
130+
LokiStack: &obs.LokiStack{
131+
DataModel: obs.LokiStackDataModelOpenTelemetry,
132+
},
133+
}))
134+
})
135+
})
136+
137+
})
138+
})

internal/api/initialize/initializations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
var clfInitializers = []func(spec obs.ClusterLogForwarder, migrateContext utils.Options) obs.ClusterLogForwarder{
1717
Resources,
1818
MigrateInputs,
19+
MigrateOutputs,
1920
}
2021

2122
// ClusterLogForwarder initializes the forwarder for fields that must be set and are inferred from settings already defined.

internal/controller/observability/clusterlogforwarder_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func initialize(cxt internalcontext.ForwarderContext) (internalcontext.Forwarder
176176
cxt.AdditionalContext = utils.Options{}
177177
migrated := internalinit.ClusterLogForwarder(*cxt.Forwarder, cxt.AdditionalContext)
178178
cxt.Forwarder = &migrated
179-
180179
if cxt.Secrets, err = MapSecrets(cxt.Client, cxt.Forwarder.Namespace, cxt.Forwarder.Spec.Inputs, cxt.Forwarder.Spec.Outputs); err != nil {
181180
return cxt, err
182181
}

0 commit comments

Comments
 (0)