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

Commit 6871af2

Browse files
bartam1pregnor
andauthored
Fix out of range panic in resizePVC fn (#958)
* Fix out of range slice in resizePVC * Fix comment and remove else * Fix unnecessary trailing newline * release(Helm): bumped chart (0.24.0->)0.24.1 --------- Co-authored-by: Patrik Egyed <[email protected]>
1 parent 55c60c6 commit 6871af2

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

charts/kafka-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
name: kafka-operator
3-
version: 0.24.0
3+
version: 0.24.1
44
description: kafka-operator manages Kafka deployments on Kubernetes
55
sources:
66
- https://github.com/banzaicloud/koperator
7-
appVersion: v0.24.0
7+
appVersion: v0.24.1

charts/kafka-operator/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Before installing the chart, you must first install the Koperator CustomResource
1212
This is performed in a separate step to allow you to easily uninstall and reinstall Koperator without deleting your installed custom resources.
1313

1414
```
15-
kubectl create --validate=false -f https://github.com/banzaicloud/koperator/releases/download/v0.24.0/kafka-operator.crds.yaml
15+
kubectl create --validate=false -f https://github.com/banzaicloud/koperator/releases/download/v0.24.1/kafka-operator.crds.yaml
1616
```
1717

1818
To install the chart:
@@ -53,7 +53,7 @@ The following table lists the configurable parameters of the Banzaicloud Kafka O
5353
Parameter | Description | Default
5454
--------- | ----------- | -------
5555
`operator.image.repository` | Operator container image repository | `ghcr.io/banzaicloud/kafka-operator`
56-
`operator.image.tag` | Operator container image tag | `v0.24.0`
56+
`operator.image.tag` | Operator container image tag | `v0.24.1`
5757
`operator.image.pullPolicy` | Operator container image pull policy | `IfNotPresent`
5858
`operator.serviceAccount.name` | ServiceAccount used by the operator pod | `kafka-operator`
5959
`operator.serviceAccount.create` | If true, create the `operator.serviceAccount.name` service account | `true`

internal/alertmanager/currentalert/process.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"emperror.dev/errors"
2424
"github.com/go-logr/logr"
2525
"github.com/prometheus/common/model"
26+
"golang.org/x/exp/slices"
2627
corev1 "k8s.io/api/core/v1"
2728
"k8s.io/apimachinery/pkg/api/resource"
2829
"k8s.io/apimachinery/pkg/types"
@@ -262,20 +263,25 @@ func resizePvc(log logr.Logger, labels model.LabelSet, annotiations model.LabelS
262263

263264
storageConfigs := brokerConfig.StorageConfigs
264265

265-
for n, c := range storageConfigs {
266+
for _, c := range storageConfigs {
266267
modifiableConfig := c.DeepCopy()
267268
if modifiableConfig.MountPath == pvc.Annotations["mountPath"] {
268269
size := *modifiableConfig.PvcSpec.Resources.Requests.Storage()
269270
size.Add(incrementBy)
270271

271272
modifiableConfig.PvcSpec.Resources.Requests["storage"] = size
272273

274+
// When the storage is in a brokerConfigGroup we don't resize the storage there because in that case
275+
// all of the brokers that are using this brokerConfigGroup would have their storages resized.
276+
// We add the storage into the broker.BrokerConfig.StorageConfigs in this way only the PVC belonging to that specific broker will be resized.
273277
if broker.BrokerConfig == nil {
274-
broker.BrokerConfig = &v1beta1.BrokerConfig{
275-
StorageConfigs: []v1beta1.StorageConfig{*modifiableConfig},
276-
}
278+
broker.BrokerConfig = &v1beta1.BrokerConfig{}
279+
}
280+
idx := slices.IndexFunc(broker.BrokerConfig.StorageConfigs, func(c v1beta1.StorageConfig) bool { return c.MountPath == pvc.Annotations["mountPath"] })
281+
if idx == -1 {
282+
broker.BrokerConfig.StorageConfigs = append(broker.BrokerConfig.StorageConfigs, *modifiableConfig)
277283
} else {
278-
broker.BrokerConfig.StorageConfigs[n] = *modifiableConfig
284+
broker.BrokerConfig.StorageConfigs[idx] = *modifiableConfig
279285
}
280286
}
281287
}

0 commit comments

Comments
 (0)