Skip to content

Bug 1450291 - Improve logs in image pruning - #14405

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
soltysh:bug1450291
Jun 8, 2017
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
soltysh:bug1450291

Conversation

@soltysh

@soltysh soltysh commented May 30, 2017

Copy link
Copy Markdown
Contributor

This partially address problem from https://bugzilla.redhat.com/show_bug.cgi?id=1450291 and cleans up the logging from my own experience going through them several times past few weeks.

@miminar @mfojtik ptal

@soltysh

soltysh commented May 30, 2017

Copy link
Copy Markdown
Contributor Author

[test]

@mfojtik

mfojtik commented May 30, 2017

Copy link
Copy Markdown
Contributor

LGTM

Comment thread pkg/image/prune/prune.go Outdated
return deleteFromRegistry(registryClient, fmt.Sprintf("%s/v2/%s/manifests/%s", registryURL, repoName, manifest))
}

func getName(o metav1.ObjectMeta) string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could this take runtime.Object instead and access the attributes via o.(metav1.ObjectMetaAccessor).GetObjectMeta()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm.... lemme check this approach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

accessor, err := meta.Accessor(obj) and then using accessor.GetName() and accessor.GetNamespace is probably better. Will got with that.

Comment thread pkg/image/prune/prune.go
return fmt.Errorf("error sending request: %v", err)
if proto != "https" && strings.Contains(err.Error(), "malformed HTTP response") {
return fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled registry without TLS?", err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will conflict with #14114.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll update this now that the other one is in place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Or maybe I should ask in what way it will conflict? This will give you a hint that you should use https when remote end supports that. #14114 will force you to use that, so this error should be seen very rarely, in some weird cases, I guess.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 for the hint. Nevertheless, this should have been captured by the ping() call.

I must have forgotten to modify this code same the way as the ping() (see

if drp.insecure || netutils.IsPrivateAddress(registry) {
) - to exclude HTTP connection from attempts when secure connection is requested. If you want, you can amend it here, otherwise I'll do it after this lands.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By the way, the hint would be useful in the pinger as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You can move it as a followup, in that case.

Comment thread pkg/image/prune/prune.go

if err := p.registryPinger.ping(registryURL); err != nil {
return fmt.Errorf("error communicating with registry: %v", err)
return fmt.Errorf("error communicating with registry %s: %v", registryURL, err)

@miminar miminar May 30, 2017 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is the url always present in the err?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In some it might, in some it won't. I'd rather having it twice sometimes, than none in those cases.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I find these messages already too long and they are quite common. Also I will need to update documentation here. Looking at the current logging, it seems like this statement will sometimes triple the url. Could you please either remove it from the pinger or from here to make sure it's logged at least once but no more than twice?

@soltysh

soltysh commented Jun 1, 2017

Copy link
Copy Markdown
Contributor Author

Rebased and addressed comments. @miminar ptal once again

Comment thread pkg/image/prune/prune.go
if age >= algorithm.keepYoungerThan {
glog.V(4).Infof("Pod %s/%s is not running or pending and age is at least minimum pruning age - skipping", pod.Namespace, pod.Name)
// not pending or running, age is at least minimum pruning age, skip
glog.V(4).Infof("Pod %s is not running nor pending and age exceeds keepYoungerThan (%v) - skipping", getName(pod), age)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

s/age exceeds/age is within/

The name of the variable is misleading 😄.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ha, I was struggling with that log message for a while. Your suggestion is definitely the best!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, no, what I said above is wrong. It has to say exceeds, because we're referring to pods that are not added to graph (skipped), which will allow the images to be pruned (because of lack of strong references).

@miminar

miminar commented Jun 5, 2017

Copy link
Copy Markdown

Cross-linking the future documentation PR openshift/openshift-docs#4471.

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 7edd2ba

@miminar miminar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, I'll do the followup for the deleter.

@soltysh

soltysh commented Jun 5, 2017

Copy link
Copy Markdown
Contributor Author

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

@soltysh

soltysh commented Jun 5, 2017

Copy link
Copy Markdown
Contributor Author

Flake #13559
[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 7edd2ba

@openshift-bot

openshift-bot commented Jun 8, 2017 •

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/923/) (Base Commit: cf5c12f) (Image: devenv-rhel7_6328)

@openshift-bot
openshift-bot merged commit 08cc91a into openshift:master Jun 8, 2017
@soltysh
soltysh deleted the bug1450291 branch June 8, 2017 12:09
openshift-merge-robot added a commit that referenced this pull request Aug 17, 2017
Automatic merge from submit-queue

Image pruner: Determine protocol just once

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
openshift-merge-robot added a commit that referenced this pull request Sep 14, 2017
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.

4 participants