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

drainv2: Job Watcher Testing #3961

Merged
merged 9 commits into from
Mar 19, 2018
Merged

Conversation

schmichael
Copy link
Member

No description provided.

@schmichael schmichael requested a review from dadgar March 10, 2018 00:27
Chan must be buffered to avoid skipping triggering altogether

Also made timing in a test a bit more lenient
They must be synchronous or they'll spin in a tight loop
@schmichael schmichael changed the title [WIP] Drain v2 Testing drainv2: Job Watcher Testing Mar 16, 2018
@@ -90,21 +90,28 @@ func NewDrainingJobWatcher(ctx context.Context, limiter *rate.Limiter, state *st
}

// RegisterJob marks the given job as draining and adds it to being watched.
func (w *drainingJobWatcher) RegisterJob(job structs.JobNs) {
func (w *drainingJobWatcher) RegisterJobs(jobs []structs.JobNs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should switch this to NamespacedID. I didn't see it originally. We should add the String() method tho

@@ -184,7 +190,7 @@ func (w *drainingJobWatcher) watch() {

// Lookup the job
job, err := w.state.JobByID(nil, jns.Namespace, jns.ID)
if err != nil {
if err != nil || job == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm if the job is nil shouldn't we do a deregisterJob. That would be the job stop purge case

@@ -390,10 +397,13 @@ func handleTaskGroup(snap *state.StateSnapshot, tg *structs.TaskGroup,
numToDrain := healthy - thresholdCount
numToDrain = helper.IntMin(len(drainable), numToDrain)
if numToDrain <= 0 {
fmt.Printf("------- Not draining any allocs\n")
fmt.Printf("------- Not draining any allocs: drainable:%d healthy:%d thresholdCount:%d\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these at this point? If still being used ignore


// assertOps asserts how many allocs should be drained and migrated.
// The drains and migrations - if any - are returned.
assertOps := func(drained, migrated int) (drains *DrainRequest, migrations []*structs.Allocation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pull this out into a helper

Also drop the New func as it's easy to swap the order of arguments since
they're both strings.
@schmichael schmichael merged commit b4e5979 into f-drainv2-node-drainer Mar 19, 2018
@schmichael schmichael deleted the f-drainv2-testing branch March 19, 2018 17:58
@dadgar dadgar restored the f-drainv2-testing branch March 19, 2018 18:04
@schmichael schmichael deleted the f-drainv2-testing branch August 28, 2018 17:18
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants