Skip to content

Commit

Permalink
fix: sort node names to get consistent event messages
Browse files Browse the repository at this point in the history
Signed-off-by: Suleyman Akbas <sakbas@redhat.com>
  • Loading branch information
suleymanakbas91 committed Oct 20, 2023
1 parent 297758e commit 69a737f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/controllers/persistent-volume-claim/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -110,6 +111,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
nodeMessage = append(nodeMessage, fmt.Sprintf("node %s has %s free storage", node.Name, prettyByteSize(capacityQuantity.Value())))
}

// sort the message alphabetically so we always publish the same event
slices.Sort(nodeMessage)

// Publish an event if the requested storage is greater than the available capacity
if !found {
msg := fmt.Sprintf("Requested storage (%s) is greater than available capacity on any node (%s).", requestedStorage.String(), strings.Join(nodeMessage, ","))
Expand Down

0 comments on commit 69a737f

Please sign in to comment.