Skip to content

Commit

Permalink
Add support for configurable MaxUnavailable setting on update strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Oct 24, 2024
1 parent b7922da commit d6227ee
Show file tree
Hide file tree
Showing 20 changed files with 2,119 additions and 814 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test: manifests generate fmt vet ginkgo ## Run tests.
$(SHELL) -c "\
eval \$$($(GOBIN)/setup-envtest use -p env ${TEST_K8S_VERSION}); \
export TEST_USING_ENVTEST=true; \
$(GINKGO) --label-filter=envtest -vv --no-color --procs 3 -output-dir=${PWD} -keep-separate-reports -race --junit-report=test-results-junit.xml --randomize-suites --randomize-all -timeout 10m ./... -covermode=count -coverprofile cover.out \
$(GINKGO) --label-filter=envtest -vv --no-color --procs=3 -output-dir=${PWD} -keep-separate-reports -race --junit-report=test-results-junit.xml --randomize-suites --randomize-all -timeout 10m ./... -covermode=count -coverprofile cover.out \
"

run-e2e-tests-local-kind: manifests generate fmt vet ## Run tests.
Expand Down
14 changes: 12 additions & 2 deletions api/v1alpha1/humiocluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

const (
Expand Down Expand Up @@ -290,6 +291,11 @@ type HumioUpdateStrategy struct {
// If pods are failing, they bypass the zone limitation and are restarted immediately - ignoring the zone.
// Zone awareness is enabled by default.
EnableZoneAwareness *bool `json:"enableZoneAwareness,omitempty"`

// MaxUnavailable is the maximum number of pods that can be unavailable during a rolling update.
// This can be configured to an absolute number or a percentage, e.g. "maxUnavailable: 5" or "maxUnavailable: 25%".
// By default, the max unavailable pods is 1.
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
}

type HumioNodePoolSpec struct {
Expand Down Expand Up @@ -388,10 +394,14 @@ type HumioNodePoolStatus struct {
Name string `json:"name"`
// State will be empty before the cluster is bootstrapped. From there it can be "Running", "Upgrading", "Restarting" or "Pending"
State string `json:"state,omitempty"`
// DesiredPodRevision holds the desired pod revision for pods of the given node pool.
DesiredPodRevision int `json:"desiredPodRevision,omitempty"`
// ZoneUnderMaintenance holds the name of the availability zone currently under maintenance
ZoneUnderMaintenance string `json:"zoneUnderMaintenance,omitempty"`
// DesiredPodRevision holds the desired pod revision for pods of the given node pool.
DesiredPodRevision int `json:"desiredPodRevision,omitempty"`
// DesiredPodHash holds a hashed representation of the pod spec
DesiredPodHash string `json:"desiredPodHash,omitempty"`
// DesiredBootstrapTokenHash holds a SHA256 of the value set in environment variable BOOTSTRAP_ROOT_TOKEN_HASHED
DesiredBootstrapTokenHash string `json:"desiredBootstrapTokenHash,omitempty"`
}

// HumioClusterStatus defines the observed state of HumioCluster
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions charts/humio-operator/crds/core.humio.com_humioclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13089,6 +13089,15 @@ spec:
If pods are failing, they bypass the zone limitation and are restarted immediately - ignoring the zone.
Zone awareness is enabled by default.
type: boolean
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of pods that can be unavailable during a rolling update.
This can be configured to an absolute number or a percentage, e.g. "maxUnavailable: 5" or "maxUnavailable: 25%".
By default, the max unavailable pods is 1.
x-kubernetes-int-or-string: true
minReadySeconds:
description: MinReadySeconds is the minimum time in
seconds that a pod must be ready before the next pod
Expand Down Expand Up @@ -15001,6 +15010,15 @@ spec:
If pods are failing, they bypass the zone limitation and are restarted immediately - ignoring the zone.
Zone awareness is enabled by default.
type: boolean
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of pods that can be unavailable during a rolling update.
This can be configured to an absolute number or a percentage, e.g. "maxUnavailable: 5" or "maxUnavailable: 25%".
By default, the max unavailable pods is 1.
x-kubernetes-int-or-string: true
minReadySeconds:
description: MinReadySeconds is the minimum time in seconds that
a pod must be ready before the next pod can be deleted when
Expand Down Expand Up @@ -15064,6 +15082,14 @@ spec:
items:
description: HumioNodePoolStatus shows the status of each node pool
properties:
desiredBootstrapTokenHash:
description: DesiredBootstrapTokenHash holds a SHA256 of the
value set in environment variable BOOTSTRAP_ROOT_TOKEN_HASHED
type: string
desiredPodHash:
description: DesiredPodHash holds a hashed representation of
the pod spec
type: string
desiredPodRevision:
description: DesiredPodRevision holds the desired pod revision
for pods of the given node pool.
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/core.humio.com_humioclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13089,6 +13089,15 @@ spec:
If pods are failing, they bypass the zone limitation and are restarted immediately - ignoring the zone.
Zone awareness is enabled by default.
type: boolean
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of pods that can be unavailable during a rolling update.
This can be configured to an absolute number or a percentage, e.g. "maxUnavailable: 5" or "maxUnavailable: 25%".
By default, the max unavailable pods is 1.
x-kubernetes-int-or-string: true
minReadySeconds:
description: MinReadySeconds is the minimum time in
seconds that a pod must be ready before the next pod
Expand Down Expand Up @@ -15001,6 +15010,15 @@ spec:
If pods are failing, they bypass the zone limitation and are restarted immediately - ignoring the zone.
Zone awareness is enabled by default.
type: boolean
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of pods that can be unavailable during a rolling update.
This can be configured to an absolute number or a percentage, e.g. "maxUnavailable: 5" or "maxUnavailable: 25%".
By default, the max unavailable pods is 1.
x-kubernetes-int-or-string: true
minReadySeconds:
description: MinReadySeconds is the minimum time in seconds that
a pod must be ready before the next pod can be deleted when
Expand Down Expand Up @@ -15064,6 +15082,14 @@ spec:
items:
description: HumioNodePoolStatus shows the status of each node pool
properties:
desiredBootstrapTokenHash:
description: DesiredBootstrapTokenHash holds a SHA256 of the
value set in environment variable BOOTSTRAP_ROOT_TOKEN_HASHED
type: string
desiredPodHash:
description: DesiredPodHash holds a hashed representation of
the pod spec
type: string
desiredPodRevision:
description: DesiredPodRevision holds the desired pod revision
for pods of the given node pool.
Expand Down
1 change: 0 additions & 1 deletion controllers/humiobootstraptoken_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ func (r *HumioBootstrapTokenReconciler) ensureBootstrapTokenHashedToken(ctx cont
if err != nil {
return err
}
// TODO: make tokenHash constant
updatedSecret.Data = map[string][]byte{BootstrapTokenSecretHashedTokenName: []byte(secretData.HashedToken), BootstrapTokenSecretSecretName: []byte(secretData.Secret)}

if err = r.Update(ctx, updatedSecret); err != nil {
Expand Down
25 changes: 8 additions & 17 deletions controllers/humiocluster_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@ limitations under the License.

package controllers

import (
"strconv"

corev1 "k8s.io/api/core/v1"
)

const (
certHashAnnotation = "humio.com/certificate-hash"
PodHashAnnotation = "humio.com/pod-hash"
PodRevisionAnnotation = "humio.com/pod-revision"
envVarSourceHashAnnotation = "humio.com/env-var-source-hash"
pvcHashAnnotation = "humio_pvc_hash"
// #nosec G101
bootstrapTokenHashAnnotation = "humio.com/bootstrap-token-hash"
// Set on Pod and Certificate objects
certHashAnnotation = "humio.com/certificate-hash"

// Set on Pod objects
PodHashAnnotation = "humio.com/pod-hash"
PodRevisionAnnotation = "humio.com/pod-revision"
BootstrapTokenHashAnnotation = "humio.com/bootstrap-token-hash" // #nosec G101
envVarSourceHashAnnotation = "humio.com/env-var-source-hash"
)

func (r *HumioClusterReconciler) setPodRevision(pod *corev1.Pod, newRevision int) {
pod.Annotations[PodRevisionAnnotation] = strconv.Itoa(newRevision)
}
Loading

0 comments on commit d6227ee

Please sign in to comment.