Skip to content

Commit e141e26

Browse files
committed
fix ci
1 parent 17fb2d8 commit e141e26

File tree

8 files changed

+51
-11
lines changed

8 files changed

+51
-11
lines changed

api/v1alpha1/pulsarnamespace_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ type InactiveTopicPolicies struct {
133133

134134
// PulsarNamespaceSpec defines the desired state of a Pulsar namespace.
135135
// It corresponds to the configuration options available in Pulsar's namespace admin API.
136+
// +kubebuilder:validation:XValidation:rule="!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime) || has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)",message="backlogQuotaRetentionPolicy is required when configuring backlog quota"
136137
type PulsarNamespaceSpec struct {
137138
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
138139
// Important: Run "make" to regenerate code after modifying this file

api/v1alpha1/pulsartopic_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
// PulsarTopicSpec defines the desired state of PulsarTopic.
2929
// It corresponds to the configuration options available in Pulsar's topic admin API.
30+
// +kubebuilder:validation:XValidation:rule="!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime) || has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)",message="backlogQuotaRetentionPolicy is required when configuring backlog quota"
3031
type PulsarTopicSpec struct {
3132
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3233
// Important: Run "make" to regenerate code after modifying this file

charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ spec:
519519
- connectionRef
520520
- name
521521
type: object
522+
x-kubernetes-validations:
523+
- message: backlogQuotaRetentionPolicy is required when configuring backlog
524+
quota
525+
rule: '!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime)
526+
|| has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)'
522527
status:
523528
description: PulsarNamespaceStatus defines the observed state of PulsarNamespace
524529
properties:

charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ spec:
552552
- connectionRef
553553
- name
554554
type: object
555+
x-kubernetes-validations:
556+
- message: backlogQuotaRetentionPolicy is required when configuring backlog
557+
quota
558+
rule: '!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime)
559+
|| has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)'
555560
status:
556561
description: PulsarTopicStatus defines the observed state of PulsarTopic
557562
properties:

config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ spec:
519519
- connectionRef
520520
- name
521521
type: object
522+
x-kubernetes-validations:
523+
- message: backlogQuotaRetentionPolicy is required when configuring backlog
524+
quota
525+
rule: '!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime)
526+
|| has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)'
522527
status:
523528
description: PulsarNamespaceStatus defines the observed state of PulsarNamespace
524529
properties:

config/crd/bases/resource.streamnative.io_pulsartopics.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ spec:
552552
- connectionRef
553553
- name
554554
type: object
555+
x-kubernetes-validations:
556+
- message: backlogQuotaRetentionPolicy is required when configuring backlog
557+
quota
558+
rule: '!(has(self.backlogQuotaLimitSize) || has(self.backlogQuotaLimitTime)
559+
|| has(self.backlogQuotaType)) || has(self.backlogQuotaRetentionPolicy)'
555560
status:
556561
description: PulsarTopicStatus defines the observed state of PulsarTopic
557562
properties:

pkg/admin/impl.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,28 @@ func buildBacklogQuota(limitTime *rutils.Duration, limitSize *resource.Quantity,
613613
if retentionPolicyStr == nil {
614614
return nil, "", fmt.Errorf("backlogQuotaRetentionPolicy is required when configuring backlog quota")
615615
}
616+
if limitTime == nil && limitSize == nil {
617+
return nil, "", fmt.Errorf("backlogQuotaLimitTime or backlogQuotaLimitSize is required when configuring backlog quota")
618+
}
616619
retentionPolicy, err := utils.ParseRetentionPolicy(*retentionPolicyStr)
617620
if err != nil {
618621
return nil, "", err
619622
}
620623

621-
backlogQuotaType := utils.DestinationStorage
622-
if backlogQuotaTypeStr != nil {
624+
var backlogQuotaType utils.BacklogQuotaType
625+
switch {
626+
case backlogQuotaTypeStr != nil:
623627
parsedType, err := utils.ParseBacklogQuotaType(*backlogQuotaTypeStr)
624628
if err != nil {
625629
return nil, "", err
626630
}
627631
backlogQuotaType = parsedType
632+
case limitSize != nil:
633+
backlogQuotaType = utils.DestinationStorage
634+
case limitTime != nil:
635+
backlogQuotaType = utils.MessageAge
636+
default:
637+
backlogQuotaType = utils.DestinationStorage
628638
}
629639

630640
backlogQuota := utils.BacklogQuota{

tests/utils/spec.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func MakePulsarNamespace(namespace, name, namespaceName, connectionName string,
6767
var du rsutils.Duration = "1d"
6868
limitTime := &du
6969
ttl := &du
70+
backlogPolicy := ptr.To("producer_request_hold")
71+
backlogType := ptr.To("destination_storage")
7072
return &v1alpha1.PulsarNamespace{
7173
ObjectMeta: metav1.ObjectMeta{
7274
Namespace: namespace,
@@ -77,10 +79,12 @@ func MakePulsarNamespace(namespace, name, namespaceName, connectionName string,
7779
ConnectionRef: corev1.LocalObjectReference{
7880
Name: connectionName,
7981
},
80-
BacklogQuotaLimitTime: limitTime,
81-
BacklogQuotaLimitSize: &backlogSize,
82-
Bundles: &bundle,
83-
MessageTTL: ttl,
82+
BacklogQuotaLimitTime: limitTime,
83+
BacklogQuotaLimitSize: &backlogSize,
84+
BacklogQuotaRetentionPolicy: backlogPolicy,
85+
BacklogQuotaType: backlogType,
86+
Bundles: &bundle,
87+
MessageTTL: ttl,
8488
TopicAutoCreationConfig: &v1alpha1.TopicAutoCreationConfig{
8589
Allow: true,
8690
Type: "partitioned",
@@ -97,6 +101,8 @@ func MakePulsarNamespaceWithRateLimiting(namespace, name, namespaceName, connect
97101
var du rsutils.Duration = "12h"
98102
limitTime := &du
99103
ttl := &du
104+
backlogPolicy := ptr.To("producer_request_hold")
105+
backlogType := ptr.To("destination_storage")
100106

101107
return &v1alpha1.PulsarNamespace{
102108
ObjectMeta: metav1.ObjectMeta{
@@ -108,11 +114,13 @@ func MakePulsarNamespaceWithRateLimiting(namespace, name, namespaceName, connect
108114
ConnectionRef: corev1.LocalObjectReference{
109115
Name: connectionName,
110116
},
111-
BacklogQuotaLimitTime: limitTime,
112-
BacklogQuotaLimitSize: &backlogSize,
113-
Bundles: &bundle,
114-
MessageTTL: ttl,
115-
LifecyclePolicy: policy,
117+
BacklogQuotaLimitTime: limitTime,
118+
BacklogQuotaLimitSize: &backlogSize,
119+
BacklogQuotaRetentionPolicy: backlogPolicy,
120+
BacklogQuotaType: backlogType,
121+
Bundles: &bundle,
122+
MessageTTL: ttl,
123+
LifecyclePolicy: policy,
116124

117125
// Rate limiting configurations
118126
DispatchRate: &v1alpha1.DispatchRate{

0 commit comments

Comments
 (0)