Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image pruner: Determine protocol just once #14914

Merged
merged 2 commits into from
Aug 17, 2017

Conversation

miminar
Copy link

@miminar miminar commented Jun 27, 2017

Determine the registry protocol once. Do not change to other protocol during the run. This will produce nicer output without unrelated protocol fallback errors.

A follow-up for #14114 and #14405
Resolves #15291

@miminar miminar changed the title imagesprune: Determina protocol just once Image pruner: Determine protocol just once Jun 27, 2017
@miminar
Copy link
Author

miminar commented Jun 27, 2017

[test][testextended][extended:core(registry|imageapi|ImagePrune|ImageQuota)]

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Overall looks good, some nits.

func (drp *defaultRegistryPinger) ping(registry string) error {
healthCheck := func(proto, registry string) error {
func (drp *defaultRegistryPinger) ping(registry string) (string, error) {
registryURL, err := tryProtocolsWithRegistryURL(registry, drp.insecure, func(u url.URL) error {
// TODO: `/healthz` route is deprecated by `/`; remove it in future versions
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we check / and fallback to /healthz only if the former fail? This way we'll support both.

Copy link
Author

Choose a reason for hiding this comment

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

We can. Resolved.

protos = []string{"https"}
}
registry = url.Host
glog.V(4).Infof("url: %#+v", url)
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a development debug, can you make it more friendly?

Copy link
Author

Choose a reason for hiding this comment

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

You're right. Ditched.

glog.V(4).Infof("Trying protocol %s for the registry url %s", proto, registry)
default:
glog.V(4).Infof("Falling back to protocol %s for the registry url %s", proto, registry)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is bad, just log the fact, you'll figure out when looking at logs, that this is a retry. There's no point in hardcoding this switch.

Copy link
Author

Choose a reason for hiding this comment

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

As you wish. I liked it better this way though.

}

if err != nil {
// TODO: remove the first
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover?

Copy link
Author

Choose a reason for hiding this comment

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

Yep. Removed.

// tryProtocolsWithRegistryURL runs given callback with different protocols until no error is returned. The
// https protocol is the first attempt. If it fails and allowInsecure is true, http will be the next. Obtained
// errors will be concatenated and returned.
func tryProtocolsWithRegistryURL(registry string, allowInsecure bool, callback func(registryURL url.URL) error) (*url.URL, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

callback here suggests an actual callback method, but it's not. It's the heart of this method, an action performed by this function. I'd suggest renaming the variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

action maybe?

Copy link
Author

Choose a reason for hiding this comment

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

Good suggesion. Changed.

@soltysh
Copy link
Contributor

soltysh commented Jun 28, 2017

Although it looks like your changes are failing tests, so you need to address that one.

@miminar
Copy link
Author

miminar commented Jun 29, 2017

Tests should be passing now.

@miminar miminar force-pushed the secure-image-prune branch 3 times, most recently from 30b4a6c to 093d03b Compare June 29, 2017 11:11
@soltysh
Copy link
Contributor

soltysh commented Jun 29, 2017

LGTM!

@miminar
Copy link
Author

miminar commented Jun 29, 2017

One last unit test fix.

@miminar
Copy link
Author

miminar commented Jul 3, 2017

Flake #14129 re-[test]

@miminar
Copy link
Author

miminar commented Jul 3, 2017

@mfojtik merge please. Waiting for code unfreeze.

@miminar miminar force-pushed the secure-image-prune branch 2 times, most recently from 704189d to 58876ea Compare July 3, 2017 15:15
@miminar
Copy link
Author

miminar commented Jul 3, 2017

I reformatted logging messages again and made a small change to defaulting to insecure connection.

Since now internal docker registry URL may be a DNS, let's not default to insecure connection if --registry-url override is empty. As long as a local IP is used as internal URL, insecure fall-back will be allowed.

@openshift openshift deleted a comment from openshift-bot Jul 3, 2017
@miminar miminar force-pushed the secure-image-prune branch 5 times, most recently from 7de7ae1 to c3bfb0b Compare July 4, 2017 16:00
@miminar
Copy link
Author

miminar commented Jul 24, 2017

Fixed broken formatting of help message.

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 5cc9d12

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/906/) (Base Commit: 74121fa) (PR Branch Commit: 5cc9d12) (Extended Tests: core(registry|imageapi|ImagePrune|ImageQuota))

@fabianofranz
Copy link
Member

/test extended_templates

@miminar
Copy link
Author

miminar commented Aug 8, 2017

Yum flakes #8571 and #10162. Flake #15432

@miminar
Copy link
Author

miminar commented Aug 8, 2017

/retest

@fabianofranz
Copy link
Member

/approve

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 8, 2017
@miminar
Copy link
Author

miminar commented Aug 14, 2017

Jenkins job not found.
/retest

@miminar
Copy link
Author

miminar commented Aug 14, 2017

/test extended_image_registry

@miminar
Copy link
Author

miminar commented Aug 14, 2017

Flakes #15432 and #15763

@miminar
Copy link
Author

miminar commented Aug 14, 2017

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@miminar
Copy link
Author

miminar commented Aug 15, 2017

Flake #15432 again.
/retest

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 15, 2017

@miminar: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/check 47551a8 link /test check
ci/openshift-jenkins/extended_image_registry 90e575c link /test extended_image_registry

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@miminar
Copy link
Author

miminar commented Aug 15, 2017

/test extended_conformance_gce
/test check

Michal Minář added 2 commits August 15, 2017 16:56
Determine the registry protocol once. Do not change to other protocol
during the run. This will produce nicer output without unrelated
protocol fallback errors.

Do not default to insecure connection when the --registry-url is empty.

Move registry client initialization just before the start of the pruner
- so we can precisely determine whether to allow for insecure fall-back
based on collected images and image streams.

Move ping() outside of pruner. Instead, determine the registry URL
before the pruner starts and assume it won't change during the run.

Signed-off-by: Michal Minář <[email protected]>
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2017
@miminar
Copy link
Author

miminar commented Aug 16, 2017

Rebased. @soltysh may I have your lgtm one more time?

@soltysh
Copy link
Contributor

soltysh commented Aug 16, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 16, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabianofranz, miminar, soltysh

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue

@openshift-merge-robot openshift-merge-robot merged commit 86abb1f into openshift:master Aug 17, 2017
openshift-merge-robot added a commit that referenced this pull request Sep 14, 2017
Automatic merge from submit-queue

[3.6][Backport] Prune images (not)securely

Back-porting:
- #14114 
- #14405
- #14914
- #15899

Resolves [bz#1476779](https://bugzilla.redhat.com/show_bug.cgi?id=1476779)
@miminar miminar deleted the secure-image-prune branch October 10, 2017 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants