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

Conversation

tty47
Copy link

@tty47 tty47 commented Nov 8, 2023

hello team!

small one, it fixes to add duplicates to the queue, that happened because the watcher sends an event for every container in the pod, but we only need it once.

cheers! 🚀

closes: https://github.com/celestiaorg/devops/issues/577

cc: @celestiaorg/devops

Signed-off-by: Jose Ramon Mañes <[email protected]>
@tty47 tty47 added the fix Fixes label Nov 8, 2023
@tty47 tty47 self-assigned this Nov 8, 2023
@tty47 tty47 requested a review from Bidon15 November 8, 2023 11:18
pkg/k8s/statefulsets.go Outdated Show resolved Hide resolved
pkg/k8s/statefulsets.go Outdated Show resolved Hide resolved
pkg/k8s/statefulsets.go Outdated Show resolved Hide resolved
@tty47 tty47 requested review from smuu and Bidon15 November 9, 2023 11:18
Copy link
Member

@Bidon15 Bidon15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one and we are good to go 🔥

Comment on lines 47 to 52
for event := range watcher.ResultChan() {
// Check if the event object is of type *v1.StatefulSet
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
if strings.HasPrefix(statefulSet.Name, "da") {
// Check if the StatefulSet is valid based on the conditions
if isStatefulSetValid(statefulSet) {
// Perform necessary actions, such as adding the node to the Redis queue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design wise, you can do the following:

  1. Check if not ok, fail fast with error and exit the for loop
  2. If ok, then you have a second if outside of the boundaries of the first if else one(where you have the ok checker)
  3. If you want to check all the objects in the channel, you need to store the error messages one by one and then exit the for loop. So far, as I understood the code, you are not intending to do so

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this part of the code, but the point 3, we will only receive one event per STS at a time, which means that in case this STS has any issues, we return the error immediately, wdyt?

@tty47 tty47 requested review from Bidon15 and sysrex November 10, 2023 14:15
Copy link
Member

@mojtaba-esk mojtaba-esk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Bidon15 Bidon15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you see how more neat it looks!
Wonderful job 💪

@tty47 tty47 merged commit 51f8e1d into main Nov 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants