Skip to content

Commit

Permalink
Tidy up comments and variables
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Bason <[email protected]>
  • Loading branch information
dbason committed Jul 27, 2023
1 parent ac93df0 commit 4e793b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/functional-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
## Build controller docker image
make docker-build
## Pre-pull opensearch images
## Import controller docker image
k3d image import -c $CLUSTER_NAME controller:latest
Expand Down
6 changes: 0 additions & 6 deletions opensearch-operator/functionaltests/execute_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ k3d cluster create $CLUSTER_NAME --agents 2 --kubeconfig-switch-context=false --
k3d kubeconfig get $CLUSTER_NAME > kubeconfig
export KUBECONFIG=$(pwd)/kubeconfig

## Pre-pull opensearch images
docker pull opensearchproject/opensearch:1.3.0
docker pull opensearchproject/opensearch:2.3.0

## Build controller docker image
cd ..
make docker-build

## Import controller docker image
k3d image import -c $CLUSTER_NAME controller:latest
k3d image import -c $CLUSTER_NAME opensearchproject/opensearch:1.3.0
k3d image import -c $CLUSTER_NAME opensearchproject/opensearch:2.3.0

## Install helm chart
helm install opensearch-operator ../charts/opensearch-operator --set manager.image.repository=controller --set manager.image.tag=latest --set manager.image.pullPolicy=IfNotPresent --namespace default --wait
Expand Down
7 changes: 4 additions & 3 deletions opensearch-operator/pkg/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,14 @@ func ReplicaHostName(currentSts appsv1.StatefulSet, repNum int32) string {
}

func WorkingPodForRollingRestart(ctx context.Context, k8sClient client.Client, sts *appsv1.StatefulSet) (string, error) {
replicas := lo.FromPtrOr(sts.Spec.Replicas, 1)
// Handle the simple case
if lo.FromPtrOr(sts.Spec.Replicas, 1) == sts.Status.UpdatedReplicas+sts.Status.CurrentReplicas {
ordinal := lo.FromPtrOr(sts.Spec.Replicas, 1) - 1 - sts.Status.UpdatedReplicas
if replicas == sts.Status.UpdatedReplicas+sts.Status.CurrentReplicas {
ordinal := replicas - 1 - sts.Status.UpdatedReplicas
return ReplicaHostName(*sts, ordinal), nil
}
// If there are potentially mixed revisions we need to check each pod
for i := lo.FromPtrOr(sts.Spec.Replicas, 1) - 1; i >= 0; i-- {
for i := replicas - 1; i >= 0; i-- {
podName := ReplicaHostName(*sts, i)
pod := &corev1.Pod{}
if err := k8sClient.Get(ctx, types.NamespacedName{Name: podName, Namespace: sts.Namespace}, pod); err != nil {
Expand Down

0 comments on commit 4e793b3

Please sign in to comment.