Skip to content

Commit 073925e

Browse files
vparfonovopenshift-merge-bot[bot]
authored andcommitted
LOG-6532: fix validation rule for Loki Tuning to allow it to be empty without failing validation Signed-off-by: Vitalii Parfonov <[email protected]>
1 parent aaede90 commit 073925e

File tree

6 files changed

+96
-5
lines changed

6 files changed

+96
-5
lines changed

api/observability/v1/output_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ type LokiStackAuthentication struct {
782782

783783
// LokiStack provides optional extra properties for `type: lokistack`
784784
// +kubebuilder:validation:XValidation:rule="!has(self.labelKeys) || !has(self.dataModel) || self.dataModel == 'Viaq'", message="'labelKeys' cannot be set when data model is 'Otel'"
785-
// +kubebuilder:validation:XValidation:rule="!has(self.tuning) || self.tuning.compression != 'snappy' || !has(self.dataModel) || self.dataModel == 'Viaq'", message="'snappy' compression cannot be used when data model is 'Otel'"
785+
// +kubebuilder:validation:XValidation:rule="!has(self.tuning) || !has(self.tuning.compression) || self.tuning.compression != 'snappy' || !has(self.dataModel) || self.dataModel == 'Viaq'", message="'snappy' compression cannot be used when data model is 'Otel'"
786786
type LokiStack struct {
787787
// Authentication sets credentials for authenticating the requests.
788788
//

bundle/manifests/observability.openshift.io_clusterlogforwarders.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2078,8 +2078,9 @@ spec:
20782078
== ''Viaq'''
20792079
- message: '''snappy'' compression cannot be used when data
20802080
model is ''Otel'''
2081-
rule: '!has(self.tuning) || self.tuning.compression != ''snappy''
2082-
|| !has(self.dataModel) || self.dataModel == ''Viaq'''
2081+
rule: '!has(self.tuning) || !has(self.tuning.compression)
2082+
|| self.tuning.compression != ''snappy'' || !has(self.dataModel)
2083+
|| self.dataModel == ''Viaq'''
20832084
name:
20842085
description: Name used to refer to the output from a `pipeline`.
20852086
pattern: ^[a-z][a-z0-9-]*[a-z0-9]$

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -2078,8 +2078,9 @@ spec:
20782078
== ''Viaq'''
20792079
- message: '''snappy'' compression cannot be used when data
20802080
model is ''Otel'''
2081-
rule: '!has(self.tuning) || self.tuning.compression != ''snappy''
2082-
|| !has(self.dataModel) || self.dataModel == ''Viaq'''
2081+
rule: '!has(self.tuning) || !has(self.tuning.compression)
2082+
|| self.tuning.compression != ''snappy'' || !has(self.dataModel)
2083+
|| self.dataModel == ''Viaq'''
20832084
name:
20842085
description: Name used to refer to the output from a `pipeline`.
20852086
pattern: ^[a-z][a-z0-9-]*[a-z0-9]$

test/e2e/collection/apivalidations/api_validations_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ var _ = Describe("", func() {
4747
_, err = buffer.ReadFrom(reader)
4848
assert(buffer.String(), err)
4949
},
50+
Entry("should pass for LokiStack with empty tuning", "lokistack-empty-tuning.yaml", func(out string, err error) {
51+
Expect(err).ToNot(HaveOccurred())
52+
}),
53+
Entry("should fail for LokiStack with snappy compression", "lokistack-snappy-compression-otel.yaml", func(out string, err error) {
54+
Expect(err.Error()).To(MatchRegexp(".'snappy' compression cannot be used when data model is 'Otel'"))
55+
}),
5056
Entry("should pass for syslog with valid udp URL", "syslog_valid_url_udp.yaml", func(out string, err error) {
5157
Expect(err).ToNot(HaveOccurred())
5258
}),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: observability.openshift.io/v1
2+
kind: ClusterLogForwarder
3+
metadata:
4+
name: clf-validation-test
5+
spec:
6+
outputs:
7+
- lokiStack:
8+
authentication:
9+
token:
10+
from: serviceAccount
11+
target:
12+
name: lokistack-dev
13+
namespace: openshift-logging
14+
tuning: { }
15+
dataModel: Otel
16+
name: logging-loki-otel
17+
tls:
18+
ca:
19+
configMapName: openshift-service-ca.crt
20+
key: service-ca.crt
21+
type: lokiStack
22+
- lokiStack:
23+
authentication:
24+
token:
25+
from: serviceAccount
26+
target:
27+
name: lokistack-dev
28+
namespace: openshift-logging
29+
tuning: { }
30+
dataModel: Viaq
31+
name: logging-loki-viaq
32+
tls:
33+
ca:
34+
configMapName: openshift-service-ca.crt
35+
key: service-ca.crt
36+
type: lokiStack
37+
pipelines:
38+
- inputRefs:
39+
- application
40+
- infrastructure
41+
- audit
42+
name: logs-to-loki-otel
43+
outputRefs:
44+
- logging-loki-otel
45+
- inputRefs:
46+
- application
47+
name: logs-to-loki-viaq
48+
outputRefs:
49+
- logging-loki-viaq
50+
serviceAccount:
51+
name: clf-validation-test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: observability.openshift.io/v1
2+
kind: ClusterLogForwarder
3+
metadata:
4+
name: clf-validation-test
5+
spec:
6+
outputs:
7+
- lokiStack:
8+
authentication:
9+
token:
10+
from: serviceAccount
11+
target:
12+
name: lokistack-dev
13+
namespace: openshift-logging
14+
tuning:
15+
compression: snappy
16+
dataModel: Otel
17+
name: logging-loki
18+
tls:
19+
ca:
20+
configMapName: openshift-service-ca.crt
21+
key: service-ca.crt
22+
type: lokiStack
23+
pipelines:
24+
- inputRefs:
25+
- application
26+
- infrastructure
27+
- audit
28+
name: logs-to-loki
29+
outputRefs:
30+
- logging-loki
31+
serviceAccount:
32+
name: clf-validation-test

0 commit comments

Comments
 (0)