Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-22109: Sort node names to get consistent event messages #456

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
"sort"
"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
sort.Strings(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