Skip to content

Commit

Permalink
adding AllowStale = true to the api QueryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Varga committed May 8, 2017
1 parent 9ff3865 commit 8890f5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions backend/nomad_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (c *NomadConnection) watchAlloc(action Action) {

c.Infof("Started watching alloc with id: %s", allocID)

q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}

for {
select {
Expand All @@ -338,7 +338,7 @@ func (c *NomadConnection) watchAlloc(action Action) {
// only broadcast if the LastIndex has changed
if remoteWaitIndex > localWaitIndex {
c.send <- &Action{Type: fetchedAlloc, Payload: alloc, Index: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second, AllowStale: true}
}
}
}
Expand All @@ -355,7 +355,7 @@ func (c *NomadConnection) watchEval(action Action) {

c.Infof("Started watching eval with id: %s", evalID)

q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
select {
case <-c.destroyCh:
Expand All @@ -378,7 +378,7 @@ func (c *NomadConnection) watchEval(action Action) {
// only broadcast if the LastIndex has changed
if remoteWaitIndex > localWaitIndex {
c.send <- &Action{Type: fetchedEval, Payload: eval, Index: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second, AllowStale: true}
}
}
}
Expand Down Expand Up @@ -451,7 +451,7 @@ func (c *NomadConnection) watchNode(action Action) {

c.Infof("Started watching node with id: %s", nodeID)

q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
select {
case <-c.destroyCh:
Expand All @@ -475,7 +475,7 @@ func (c *NomadConnection) watchNode(action Action) {
// only broadcast if the LastIndex has changed
if remoteWaitIndex > localWaitIndex {
c.send <- &Action{Type: fetchedNode, Payload: node, Index: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second, AllowStale: true}
}
}
}
Expand Down Expand Up @@ -544,7 +544,7 @@ func (c *NomadConnection) watchJob(action Action) {

c.Infof("Started watching job with id: %s", jobID)

q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
select {
case <-c.destroyCh:
Expand Down Expand Up @@ -579,7 +579,7 @@ func (c *NomadConnection) watchJob(action Action) {
// only broadcast if the LastIndex has changed
if remoteWaitIndex > localWaitIndex {
c.send <- &Action{Type: fetchedJob, Payload: job, Index: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, WaitTime: 10 * time.Second, AllowStale: true}
}
}
}
Expand Down Expand Up @@ -837,7 +837,7 @@ func (c *NomadConnection) changeTaskGroupCount(action Action) {
taskGroupID := params["taskGroup"].(string)
scaleAction := params["scaleAction"].(string)

job, _, err := c.region.Client.Jobs().Info(jobID, &api.QueryOptions{})
job, _, err := c.region.Client.Jobs().Info(jobID, &api.QueryOptions{AllowStale: true})
if err != nil {
c.Errorf("connection: unable to fetch job info: %s", err)
c.send <- &Action{Type: errorNotification, Payload: fmt.Sprintf("Could not find job: %s", jobID), Index: index}
Expand Down
20 changes: 10 additions & 10 deletions backend/nomad_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (n *NomadRegion) StartWatchers() {
}

func (n *NomadRegion) watchAllocs() {
q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}

for {
allocations, meta, err := n.Client.Allocations().List(q)
Expand All @@ -116,12 +116,12 @@ func (n *NomadRegion) watchAllocs() {

n.allocations = allocations
n.broadcastChannels.allocations.Update(&Action{Type: fetchedAllocs, Payload: allocations, Index: remoteWaitIndex})
q = &api.QueryOptions{WaitIndex: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, AllowStale: true}
}
}

func (n *NomadRegion) watchAllocsShallow() {
q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}

for {
allocations, meta, err := n.Client.Allocations().List(q)
Expand Down Expand Up @@ -149,7 +149,7 @@ func (n *NomadRegion) watchAllocsShallow() {
n.allocationsShallow = allocations
n.broadcastChannels.allocationsShallow.Update(&Action{Type: fetchedAllocs, Payload: allocations, Index: remoteWaitIndex})

q = &api.QueryOptions{WaitIndex: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, AllowStale: true}
}
}

Expand All @@ -161,7 +161,7 @@ func (a ClientNameSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ClientNameSorter) Less(i, j int) bool { return a[i].Name < a[j].Name }

func (n *NomadRegion) watchNodes() {
q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
nodes, meta, err := n.Client.Nodes().List(q)
if err != nil {
Expand All @@ -186,12 +186,12 @@ func (n *NomadRegion) watchNodes() {

n.nodes = nodes
n.broadcastChannels.nodes.Update(&Action{Type: fetchedNodes, Payload: nodes, Index: remoteWaitIndex})
q = &api.QueryOptions{WaitIndex: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, AllowStale: true}
}
}

func (n *NomadRegion) watchEvals() {
q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
evaluations, meta, err := n.Client.Evaluations().List(q)
if err != nil {
Expand All @@ -213,12 +213,12 @@ func (n *NomadRegion) watchEvals() {

n.evaluations = evaluations
n.broadcastChannels.evaluations.Update(&Action{Type: fetchedEvals, Payload: evaluations, Index: remoteWaitIndex})
q = &api.QueryOptions{WaitIndex: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, AllowStale: true}
}
}

func (n *NomadRegion) watchJobs() {
q := &api.QueryOptions{WaitIndex: 1}
q := &api.QueryOptions{WaitIndex: 1, AllowStale: true}
for {
jobs, meta, err := n.Client.Jobs().List(q)
if err != nil {
Expand All @@ -240,7 +240,7 @@ func (n *NomadRegion) watchJobs() {

n.jobs = jobs
n.broadcastChannels.jobs.Update(&Action{Type: fetchedJobs, Payload: jobs, Index: remoteWaitIndex})
q = &api.QueryOptions{WaitIndex: remoteWaitIndex}
q = &api.QueryOptions{WaitIndex: remoteWaitIndex, AllowStale: true}
}
}

Expand Down

0 comments on commit 8890f5c

Please sign in to comment.