Skip to content

Commit

Permalink
create outgoing requests to its own function
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
  • Loading branch information
jsternberg committed Oct 7, 2024
1 parent b6f6182 commit 760b53e
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions solver/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,27 +779,7 @@ func (e *edge) createInputRequests(desiredState edgeStatusType, f *pipeFactory,

// outgoing request is needed
if dep.state < desiredStateDep {
addNew := true
if dep.req != nil && !dep.req.Status().Completed {
if dep.req.Request().desiredState != desiredStateDep {
debugSchedulerCancelInputRequest(e, dep, desiredStateDep)
dep.req.Cancel()
} else {
debugSchedulerSkipInputRequestBasedOnExistingRequest(e, dep, desiredStateDep)
addNew = false
}
}
if addNew {
debugSchedulerAddInputRequest(e, dep, desiredStateDep)
req := f.NewInputRequest(e.edge.Vertex.Inputs()[int(dep.index)], &edgeRequest{
currentState: dep.edgeState,
desiredState: desiredStateDep,
currentKeys: len(dep.keys),
})
e.depRequests[req] = dep
dep.req = req
addedNew = true
}
addedNew = e.createOutgoingRequest(dep, desiredStateDep, f) || addedNew
} else {
debugSchedulerSkipInputRequestBasedOnDepState(e, dep, desiredStateDep)
}
Expand Down Expand Up @@ -871,6 +851,27 @@ func (e *edge) desiredStateDep(dep *dep, desiredState edgeStatusType, force bool
return dep.state
}

func (e *edge) createOutgoingRequest(dep *dep, desiredStateDep edgeStatusType, f *pipeFactory) (addedNew bool) {
if dep.req != nil && !dep.req.Status().Completed {
if dep.req.Request().desiredState == desiredStateDep {
debugSchedulerSkipInputRequestBasedOnExistingRequest(e, dep, desiredStateDep)
return false
}
debugSchedulerCancelInputRequest(e, dep, desiredStateDep)
dep.req.Cancel()
}

debugSchedulerAddInputRequest(e, dep, desiredStateDep)
req := f.NewInputRequest(e.edge.Vertex.Inputs()[int(dep.index)], &edgeRequest{
currentState: dep.edgeState,
desiredState: desiredStateDep,
currentKeys: len(dep.keys),
})
e.depRequests[req] = dep
dep.req = req
return true
}

// execIfPossible creates a request for getting the edge result if there is
// enough state
func (e *edge) execIfPossible(f *pipeFactory) bool {
Expand Down

0 comments on commit 760b53e

Please sign in to comment.