- priorityTicker.Stop()
-
- // The container state should be 'Complete'
- var container Container
- err = arv.Get("containers", uuid, nil, &container)
- if container.State == "Running" {
- log.Printf("After crunch-run process termination, the state is still 'Running' for %v. Updating it to 'Complete'", uuid)
- err = arv.Update("containers", uuid,
- arvadosclient.Dict{
- "container": arvadosclient.Dict{"state": "Complete"}},
- nil)
- if err != nil {
- log.Printf("Error updating container state to Complete for %v: %q", uuid, err)
- }
+ // If the container is not finalized, then change it to "Cancelled".
+ err := dispatcher.Arv.Get("containers", uuid, nil, &container)
+ if err != nil {
+ dispatcher.Logger.Warnf("error getting final container state: %v", err)
+ }
+ if container.State == dispatch.Locked || container.State == dispatch.Running {
+ dispatcher.Logger.Warnf("after %q process termination, container state for %v is %q; updating it to %q",
+ *crunchRunCommand, uuid, container.State, dispatch.Cancelled)
+ dispatcher.UpdateState(uuid, dispatch.Cancelled)
+ }
+
+ // drain any subsequent status changes
+ for range status {