Skip to content

Commit 57ec3fa

Browse files
author
Toni Reina
authored
Update validations for the Toleration message (#273)
- Validate the format of the `key` field only if it isn't empty (the field can be empty when the value for operator is Exists). - Update the comment for the `effect` field. The default isn't `NoSchedule`. - Add an extra validation to check that the `toleration_seconds` field is set only if the `effect` field is `NoExecute`.
1 parent 75a37ce commit 57ec3fa

8 files changed

Lines changed: 71 additions & 61 deletions

File tree

gen/go/qdrant/cloud/cluster/v1/cluster.pb.go

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/openapiv2/qdrant/cloud/cluster/backup/v1/backup.swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/openapiv2/qdrant/cloud/cluster/v1/cluster.swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/openapiv2/qdrant/cloud/hybrid/v1/hybrid_cloud.swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/python/qdrant/cloud/cluster/v1/cluster_pb2.py

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/typescript/qdrant/cloud/cluster/v1/cluster_pb.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/typescript/qdrant/cloud/cluster/v1/cluster_pb.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/qdrant/cloud/cluster/v1/cluster.proto

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,6 @@ message Toleration {
817817
optional string key = 1 [(buf.validate.field).string = {
818818
// A key can be up to 317 characters long (253 for prefix, 1 for '/', 63 for name).
819819
max_len: 317
820-
// Basic pattern, however we do not cover the length constraints here.
821-
pattern: "^([a-z0-9A-Z]([-a-z0-9A-Z]*[a-z0-9A-Z])?(\\.[a-z0-9A-Z]([-a-z0-9A-Z]*[a-z0-9A-Z])?)*\\/)?([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$"
822820
}];
823821
// The operator represents a key's relationship to the value.
824822
// The default is TOLERATION_OPERATOR_EQUAL.
@@ -842,14 +840,19 @@ message Toleration {
842840
// If operator is Equal (2) or not set (defaults to Equal), value must be present.
843841
expression: "(has(this.operator) && this.operator != 2) || has(this.value)"
844842
};
843+
option (buf.validate.message).cel = {
844+
id: "toleration.key_format_when_present"
845+
message: "key must be a valid Kubernetes qualified name when set and non-empty"
846+
expression: "!has(this.key) || this.key == '' || this.key.matches('^([A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])?(\\\\.[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])?)*\\\\/)?([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$')"
847+
};
845848
option (buf.validate.message).cel = {
846849
id: "toleration.key_empty_requires_exists"
847850
message: "operator must be 'Exists' if key is empty"
848851
// If key is not set or empty, operator must be Exists (1).
849852
expression: "(has(this.key) && this.key != '') || this.operator == 1"
850853
};
851854
// The effect indicates the taint effect to match.
852-
// The default is TOLERATION_EFFECT_NO_SCHEDULE.
855+
// If not set, matches all taint effects.
853856
optional TolerationEffect effect = 4 [(buf.validate.field).enum = {
854857
defined_only: true
855858
not_in: [0]
@@ -858,6 +861,11 @@ message Toleration {
858861
optional uint64 toleration_seconds = 5 [(buf.validate.field).uint64 = {
859862
gte: 0 // Ensure the value is non-negative (technically redundant for uint64)
860863
}];
864+
option (buf.validate.message).cel = {
865+
id: "toleration.seconds_only_for_noexecute"
866+
message: "tolerationSeconds is only valid when effect is NoExecute"
867+
expression: "!has(this.toleration_seconds) || this.effect == 3"
868+
};
861869
}
862870

863871
// ClusterStorageConfiguration defines Storage IOPS and Throughput configuration

0 commit comments

Comments
 (0)