Skip to content

Commit

Permalink
Fix out of range panic in resizePVC fn (#958)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
bartam1 and pregnor authored Apr 7, 2023
1 parent 55c60c6 commit 6871af2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions charts/kafka-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: kafka-operator
version: 0.24.0
version: 0.24.1
description: kafka-operator manages Kafka deployments on Kubernetes
sources:
- https://github.com/banzaicloud/koperator
appVersion: v0.24.0
appVersion: v0.24.1
4 changes: 2 additions & 2 deletions charts/kafka-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Before installing the chart, you must first install the Koperator CustomResource
This is performed in a separate step to allow you to easily uninstall and reinstall Koperator without deleting your installed custom resources.

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

To install the chart:
Expand Down Expand Up @@ -53,7 +53,7 @@ The following table lists the configurable parameters of the Banzaicloud Kafka O
Parameter | Description | Default
--------- | ----------- | -------
`operator.image.repository` | Operator container image repository | `ghcr.io/banzaicloud/kafka-operator`
`operator.image.tag` | Operator container image tag | `v0.24.0`
`operator.image.tag` | Operator container image tag | `v0.24.1`
`operator.image.pullPolicy` | Operator container image pull policy | `IfNotPresent`
`operator.serviceAccount.name` | ServiceAccount used by the operator pod | `kafka-operator`
`operator.serviceAccount.create` | If true, create the `operator.serviceAccount.name` service account | `true`
Expand Down
16 changes: 11 additions & 5 deletions internal/alertmanager/currentalert/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"emperror.dev/errors"
"github.com/go-logr/logr"
"github.com/prometheus/common/model"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -262,20 +263,25 @@ func resizePvc(log logr.Logger, labels model.LabelSet, annotiations model.LabelS

storageConfigs := brokerConfig.StorageConfigs

for n, c := range storageConfigs {
for _, c := range storageConfigs {
modifiableConfig := c.DeepCopy()
if modifiableConfig.MountPath == pvc.Annotations["mountPath"] {
size := *modifiableConfig.PvcSpec.Resources.Requests.Storage()
size.Add(incrementBy)

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

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

0 comments on commit 6871af2

Please sign in to comment.