Browse code

Shutdown leaks an error when the container was never started

I found that sometimes tasks would end up in a rejected state when
trying to update them quickly. The problem was that Shutdown could fail
if called before the container was started. Instead of returning an
error in this case, Shutdown should succeed. This allows tasks to
progress to the "shutdown" state as expected.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

Aaron Lehmann authored on 2017/02/17 10:52:02
Showing 1 changed files
... ...
@@ -317,8 +317,10 @@ func (r *controller) Shutdown(ctx context.Context) error {
317 317
 
318 318
 	// remove container from service binding
319 319
 	if err := r.adapter.deactivateServiceBinding(); err != nil {
320
-		log.G(ctx).WithError(err).Errorf("failed to deactivate service binding for container %s", r.adapter.container.name())
321
-		return err
320
+		log.G(ctx).WithError(err).Warningf("failed to deactivate service binding for container %s", r.adapter.container.name())
321
+		// Don't return an error here, because failure to deactivate
322
+		// the service binding is expected if the container was never
323
+		// started.
322 324
 	}
323 325
 
324 326
 	if err := r.adapter.shutdown(ctx); err != nil {