Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 397c124

Browse files
authored
Fix unnecessary reconcile caused by envoy pdb struct
1 parent 730f578 commit 397c124

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

api/v1beta1/kafkacluster_types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ type EnvoyConfig struct {
251251
// Envoy admin port
252252
AdminPort *int32 `json:"adminPort,omitempty"`
253253
// DisruptionBudget is the pod disruption budget attached to Envoy Deployment(s)
254-
DisruptionBudget DisruptionBudgetWithStrategy `json:"disruptionBudget,omitempty"`
254+
DisruptionBudget *DisruptionBudgetWithStrategy `json:"disruptionBudget,omitempty"`
255255
}
256256

257257
// IstioIngressConfig defines the config for the Istio Ingress Controller
@@ -585,6 +585,14 @@ func (eConfig *EnvoyConfig) GetAnnotations() map[string]string {
585585
return util.CloneMap(eConfig.Annotations)
586586
}
587587

588+
//GetDistruptionBudget returns DisruptionBudget to use for Envoy generated Pods
589+
func (eConfig *EnvoyConfig) GetDistruptionBudget() DisruptionBudgetWithStrategy {
590+
if eConfig.DisruptionBudget != nil {
591+
return *eConfig.DisruptionBudget
592+
}
593+
return DisruptionBudgetWithStrategy{}
594+
}
595+
588596
// GetReplicas returns replicas used by the Envoy deployment
589597
func (eConfig *EnvoyConfig) GetReplicas() int32 {
590598
if eConfig.Replicas == 0 {

api/v1beta1/zz_generated.deepcopy.go

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

pkg/resources/envoy/envoy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (r *Reconciler) Reconcile(log logr.Logger) error {
6868
r.deployment,
6969
)
7070

71-
if r.KafkaCluster.Spec.EnvoyConfig.DisruptionBudget.DisruptionBudget.Create {
71+
if r.KafkaCluster.Spec.EnvoyConfig.GetDistruptionBudget().DisruptionBudget.Create {
7272
externalListernerResources = append(externalListernerResources, r.podDisruptionBudget)
7373
}
7474
for name, ingressConfig := range ingressConfigs {

pkg/resources/envoy/poddisruptionbudget.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (r *Reconciler) podDisruptionBudget(log logr.Logger, extListener v1beta1.Ex
4141
var deploymentName string = util.GenerateEnvoyResourceName(envoyutils.EnvoyDeploymentName, envoyutils.EnvoyDeploymentNameWithScope,
4242
extListener, ingressConfig, ingressConfigName, r.KafkaCluster.GetName())
4343

44-
pdbConfig := r.KafkaCluster.Spec.EnvoyConfig.DisruptionBudget
44+
pdbConfig := r.KafkaCluster.Spec.EnvoyConfig.GetDistruptionBudget()
4545

4646
// We use intstr.Parse so that the proper structure is used when passing to PDB spec validator, otherwise
4747
// an improper regex will be used to verify the value

0 commit comments

Comments
 (0)