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

fix(torch): processing duplications #3

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Changes from 1 commit
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
25 changes: 18 additions & 7 deletions pkg/k8s/statefulsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,28 @@ func WatchStatefulSets() error {
return err
}

// Variable to keep track of the last processed name
lastProcessedName := ""
tty47 marked this conversation as resolved.
Show resolved Hide resolved

// Watch for events on the watcher channel
for event := range watcher.ResultChan() {
if statefulSet, ok := event.Object.(*v1.StatefulSet); ok {
//log.Info("StatefulSet containers: ", statefulSet.Spec.Template.Spec.Containers)

// check if the node is DA, if so, send it to the queue to generate the multi address
// Check if the name has the "da" prefix
if strings.HasPrefix(statefulSet.Name, "da") {
tty47 marked this conversation as resolved.
Show resolved Hide resolved
err := redis.Producer(statefulSet.Name, queueK8SNodes)
if err != nil {
log.Error("ERROR adding the node to the queue: ", err)
return err
// Check if the name is different from the last processed one
if statefulSet.Name != lastProcessedName {
// Process the name and perform necessary actions
err := redis.Producer(statefulSet.Name, queueK8SNodes)
if err != nil {
log.Error("ERROR adding the node to the queue: ", err)
return err
}

// Update the last processed name to don't process it more than once.
lastProcessedName = statefulSet.Name
} else {
// cleanup the previous processed to add it in future iterations.
lastProcessedName = ""
}
tty47 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down