Skip to content

com.github.dockerjava.api.model.PullResponseItem#isPullSuccessIndicated fails to check for "Exists" status #2010

Closed

Description

@AndyGee

com.github.dockerjava.api.model.PullResponseItem#isPullSuccessIndicated checks for several success states, but misses "Exists" and treats this status as a failure.

Caused by: com.github.dockerjava.api.exception.DockerClientException: Could not pull image: Exists

If would be great if the success status codes could be a configurable list that the library user could append to.

Activity

  1. AndyGee commented on Nov 22, 2022

    @AndyGee
    Author

    Quick fix was to create this class in my test classpath:

    package com.github.dockerjava.api.model;
    
    import com.fasterxml.jackson.annotation.JsonIgnore;
    
    /**
     * Represents a pull response stream item
     */
    public class PullResponseItem extends com.github.dockerjava.api.model.ResponseItem {
    
      private static final long serialVersionUID = -2575482839766823293L;
    
      private static final String LEGACY_REGISTRY = "this image was pulled from a legacy registry";
    
      private static final String DOWNLOADED_NEWER_IMAGE = "Downloaded newer image";
    
      private static final String IMAGE_UP_TO_DATE = "Image is up to date";
    
      private static final String DOWNLOAD_COMPLETE = "Download complete";
    
      private static final String DOWNLOADED_SWARM = ": downloaded";
    
      private static final String EXISTS = "Exists";
    
      /**
       * Returns whether the status indicates a successful pull operation
       *
       * @returns true: status indicates that pull was successful, false: status doesn't indicate a successful pull
       */
      @JsonIgnore
      public boolean isPullSuccessIndicated() {
        if (isErrorIndicated() || getStatus() == null) {
          return false;
        }
    
        return (
          getStatus().contains(DOWNLOAD_COMPLETE)
            || getStatus().contains(IMAGE_UP_TO_DATE)
            || getStatus().contains(DOWNLOADED_NEWER_IMAGE)
            || getStatus().contains(LEGACY_REGISTRY)
            || getStatus().contains(DOWNLOADED_SWARM)
            || getStatus().contains(EXISTS));
      }
    }
  2. eddumelendez commented on Nov 23, 2022

    @eddumelendez
    Member

    @AndyGee thanks for reporting this issue! is the full status Already exists? I look at moby and just found that one.

  3. AndyGee commented on Jan 23, 2023

    @AndyGee
    Author

    @eddumelendez Sorry for the late reply. On Win at least, it is "Exists" - However, I'm currently using the above workaround in all our projects, which are also built on ios and ubuntu based systems.

  4. AndyGee commented on Jan 23, 2023

    @AndyGee
    Author

    @eddumelendez another workaround is of course to delete the image, but that's kind of drastic ;-) - Interestingly the IMAGE_UP_TO_DATE is not the status here, which is what I'd expect given that the image is actually up to date.

  5. AndyGee commented on Jan 23, 2023

    @AndyGee
    Author

    image

  6. stale commented on Apr 26, 2023

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  7. stale commented on Aug 12, 2023

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions