From 1d6935cefbabe9e0b5f45276db2303375f7ce433 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Tue, 1 Oct 2024 07:50:58 -0700 Subject: [PATCH] registry: remove ping v1 The ping v1 happens when the ping v2 fails, however, it causes the ping v2 error to be skipped and not output to the user. As result, when a registry has v1 and v2 enabled, and there are, for example, intermittent connectivity issues making the ping v2 fail, the user is presented with a misleading error saying "can't talk to V1 registry." Since the only use of v1 is for the search API as a workaround for docker.io, and new container registries setups are very unlikely to be v1-only, there is little utility in keeping this v1 detection in the attempt to help the user realize their setup is v1-only, hence not compatible. On the contratry, it just presents the user with a misleading error in certain circumstances. Signed-off-by: Carlos Rodriguez-Fernandez --- docker/docker_client.go | 31 ------------------------------- docker/errors.go | 3 --- types/types.go | 4 ---- 3 files changed, 38 deletions(-) diff --git a/docker/docker_client.go b/docker/docker_client.go index 97d97fed5f..72be506d5f 100644 --- a/docker/docker_client.go +++ b/docker/docker_client.go @@ -934,37 +934,6 @@ func (c *dockerClient) detectPropertiesHelper(ctx context.Context) error { if err != nil && c.tlsClientConfig.InsecureSkipVerify { err = ping("http") } - if err != nil { - err = fmt.Errorf("pinging container registry %s: %w", c.registry, err) - if c.sys != nil && c.sys.DockerDisableV1Ping { - return err - } - // best effort to understand if we're talking to a V1 registry - pingV1 := func(scheme string) bool { - pingURL, err := url.Parse(fmt.Sprintf(resolvedPingV1URL, scheme, c.registry)) - if err != nil { - return false - } - resp, err := c.makeRequestToResolvedURL(ctx, http.MethodGet, pingURL, nil, nil, -1, noAuth, nil) - if err != nil { - logrus.Debugf("Ping %s err %s (%#v)", pingURL.Redacted(), err.Error(), err) - return false - } - defer resp.Body.Close() - logrus.Debugf("Ping %s status %d", pingURL.Redacted(), resp.StatusCode) - if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusUnauthorized { - return false - } - return true - } - isV1 := pingV1("https") - if !isV1 && c.tlsClientConfig.InsecureSkipVerify { - isV1 = pingV1("http") - } - if isV1 { - err = ErrV1NotSupported - } - } return err } diff --git a/docker/errors.go b/docker/errors.go index 4392f9d182..b813f0005e 100644 --- a/docker/errors.go +++ b/docker/errors.go @@ -10,9 +10,6 @@ import ( ) var ( - // ErrV1NotSupported is returned when we're trying to talk to a - // docker V1 registry. - ErrV1NotSupported = errors.New("can't talk to a V1 container registry") // ErrTooManyRequests is returned when the status code returned is 429 ErrTooManyRequests = errors.New("too many requests to registry") ) diff --git a/types/types.go b/types/types.go index 7d6097346a..287ef1663c 100644 --- a/types/types.go +++ b/types/types.go @@ -640,10 +640,6 @@ type SystemContext struct { DockerBearerRegistryToken string // if not "", an User-Agent header is added to each request when contacting a registry. DockerRegistryUserAgent string - // if true, a V1 ping attempt isn't done to give users a better error. Default is false. - // Note that this field is used mainly to integrate containers/image into projectatomic/docker - // in order to not break any existing docker's integration tests. - DockerDisableV1Ping bool // If true, dockerImageDestination.SupportedManifestMIMETypes will omit the Schema1 media types from the supported list DockerDisableDestSchema1MIMETypes bool // If true, the physical pull source of docker transport images logged as info level