Skip to content

Conversation

@pangsq
Copy link
Contributor

@pangsq pangsq commented Apr 27, 2021

Imporve the fallback logic in ping. Not try https if the registry is intentionally set to insecure so that we can avoid long delays on http-only registry (which may directly drop the packet to port 443 rather than answer with a RST).

Fixes GoogleContainerTools/kaniko#970

It still keep #279 solved.

@pangsq pangsq changed the title Avoid trying https for ping if the registry is intentionally set to i… Avoid trying https insecure registry Apr 27, 2021
@pangsq pangsq changed the title Avoid trying https insecure registry Avoid trying https for insecure registries Apr 27, 2021
@pangsq pangsq marked this pull request as draft April 28, 2021 02:35
@pangsq pangsq marked this pull request as ready for review April 28, 2021 08:02
…nsecure

Signed-off-by: pangshaoqiang <pangsq9413@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2021

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 75.04%. Comparing base (0976a27) to head (0341a1b).
Report is 409 commits behind head on main.

Files with missing lines Patch % Lines
pkg/name/registry.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1002      +/-   ##
==========================================
- Coverage   75.18%   75.04%   -0.14%     
==========================================
  Files         107      107              
  Lines        5061     5077      +16     
==========================================
+ Hits         3805     3810       +5     
- Misses        711      721      +10     
- Partials      545      546       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@cope cope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

// if the registry matches our localhost heuristic.
var schemes []string
if reg.IsInsecure() {
schemes = []string{"http"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of me thinks we should fall back to https in this case, still, just to avoid breaking something that worked before, but I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I list all conditions below to figure out how this patch will make a difference to the usage.

No. Registry Protocols Insecure Flag Match localhost pattern Protocol Used Before Protocol Used After
1 HTTPS+HTTP HTTPS HTTPS
2 HTTPS+HTTP HTTPS HTTPS
3 HTTPS+HTTP HTTPS HTTP
4 HTTPS+HTTP HTTPS HTTP
5 HTTPS-only HTTPS HTTPS
6 HTTPS-only HTTPS HTTPS
7 HTTPS-only HTTPS failed
8 HTTPS-only HTTPS failed
9 HTTP-only failed failed
10 HTTP-only HTTP HTTP
11 HTTP-only HTTP HTTP
12 HTTP-only HTTP HTTP

The conditions on which performances will be different are No.7/No.8. On these conditions, users just need to unset the insecure flag to make it work. Considering that the insecure flag is default False, these conditions may not happen.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the insecure flag is default False, these conditions may not happen.

My concern is that this option might be set "globally" for a given consumer. If you look at kaniko, they have a bunch of flags that are booleans to enable insecure behavior.

You can imagine someone with a Dockerfile that pulls FROM two different registries: their secure production registry, and an insecure registry running on their network.

If we don't have a fallback to https, pulling from their secure registry would just fail.

Arguably, any decent web server will redirect from http to https, so this might not be a problem in practice, but I wanted to bring it up as a potentially breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agreed that maybe some kaniko users enbale the insecure flag and have secure/insecure registries in one Dockerfile. On that condition, the pulling from thesecure registries would fail. However, in kaniko, users can also use the insecure-registry to config which registries are insecure and the others will still use HTTPS for pulling and pushing.

In my opinion, it is determined that if users set insecure, then we will try HTTP at first. And whether or not we fallback to HTTPS is another consideration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fallback to HTTPS after HTTP is failed is reasonable for this issue.

Signed-off-by: pangshaoqiang <pangsq9413@gmail.com>
Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jonjohnsonjr jonjohnsonjr merged commit 9e56ddd into google:main Jun 11, 2021
jonjohnsonjr added a commit to jonjohnsonjr/go-containerregistry that referenced this pull request Jun 14, 2021
jonjohnsonjr added a commit that referenced this pull request Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshotting is taking > 10 minutes

4 participants