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

tasks sort order changing, causing unnecessary restarts #177

Closed
rasputnik opened this issue Nov 4, 2015 · 5 comments
Closed

tasks sort order changing, causing unnecessary restarts #177

rasputnik opened this issue Nov 4, 2015 · 5 comments

Comments

@rasputnik
Copy link
Contributor

We've been running bamboo 0.2.12 against marathon 0.7.5 happily for months, but today
our haproxies have been reloading every minute or so - although the state of marathon is
not changing.

Did some investigation (diffing haproxy.cfg, marathon and bamboo state URLs) it seems the order of tasks returned by http://our-marathon:8080/v2/tasks is changing - for reasons I can't understand.

This causes the generated haproxy.cfg to differ enough for bamboo to reload configuration.

our haproxy template is here:
https://gist.github.com/rasputnik/3c4a846b5aedcef6ea02

Is there any way for me to sort the tasks (in the ' {{ range $page, $task := .Tasks }}' block) using bamboos templating?

Or am I going to have to patch our bamboo to ensure these tasks remain in order?

@rasputnik
Copy link
Contributor Author

Odd, it looks like we already sort the taskList we get from marathon here:

https://github.com/QubitProducts/bamboo/blob/v0.2.12/services/marathon/marathon.go#L140

but for some reason it gets jumbled up again by the time it's merged into the main bamboo state.

Can anyone give me a clue what's going on here?

@rasputnik
Copy link
Contributor Author

I've filed this ticket against marathon for some clarification of what should be expected from the rest api:
mesosphere/marathon#2567

@rasputnik
Copy link
Contributor Author

Marathon line is that the tasks are returned in random order and it's consumers responsibility to sort them. I'm still digging around to find how the tasks become jumbled, since they're definitely sorted on line 140.

@rasputnik
Copy link
Contributor Author

Liberal use of glog.Infof confirms the Tasks within the apps are not sorted when returned by createApps. The marathonTasks are sorted when passed to the function, I'm not seeing where they get jumbled.

Also appears that https://github.com/QubitProducts/bamboo/blob/v0.2.12/services/marathon/marathon.go#L235 is not sorting the Task list, just the parent Apps.

@rasputnik
Copy link
Contributor Author

found 2 little bugs

  • sorting marathonTasks by .Id instead of .StagedAt resolves this consistently - unsure if there is an issue due to .StagedAt being a String so sorting inconsistently (our clocks recently changed so timezones may come into play), but this reliably fixes things for us
  • big chunks of marathon.go use []MarathonTask instead of MarathonTaskList, which may be causing sorts to happen oddly

PR incoming (just verifying the modified code handles normal deployments correctly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant