{volume|deployment}watcher: check for nil batcher

This commit is contained in:
Mahmood Ali
2020-05-26 14:54:27 -04:00
parent 72ce1573b0
commit fb22b97062
2 changed files with 11 additions and 2 deletions

View File

@@ -366,7 +366,11 @@ func (w *Watcher) FailDeployment(req *structs.DeploymentFailRequest, resp *struc
// createUpdate commits the given allocation desired transition and evaluation
// to Raft but batches the commit with other calls.
func (w *Watcher) createUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) (uint64, error) {
return w.allocUpdateBatcher.CreateUpdate(allocs, eval).Results()
b := w.allocUpdateBatcher
if b == nil {
return 0, notEnabled
}
return b.CreateUpdate(allocs, eval).Results()
}
// upsertJob commits the given job to Raft

View File

@@ -2,6 +2,7 @@ package volumewatcher
import (
"context"
"errors"
"sync"
"time"
@@ -233,5 +234,9 @@ func (w *Watcher) removeLocked(volID, namespace string) {
// updatesClaims sends the claims to the batch updater and waits for
// the results
func (w *Watcher) updateClaims(claims []structs.CSIVolumeClaimRequest) (uint64, error) {
return w.volumeUpdateBatcher.CreateUpdate(claims).Results()
b := w.volumeUpdateBatcher
if b == nil {
return 0, errors.New("volume watcher is not enabled")
}
return b.CreateUpdate(claims).Results()
}