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

ex: dockergc: various fixes #17479

Merged
merged 6 commits into from
Jan 10, 2018

Conversation

sjenning
Copy link
Contributor

@sjenning sjenning commented Nov 27, 2017

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 27, 2017
@sjenning sjenning changed the title ex: dockergc: remove BindForOutput flags and fixups ex: dockergc: remove BindForOutput flags and other fixups Nov 27, 2017
@@ -429,30 +429,12 @@ _openshift_ex_dockergc()
flags_with_completion=()
flags_completion=()

flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
Copy link
Contributor

Choose a reason for hiding this comment

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

No. Don't do it. This is a common option.

break
}
fmt.Printf("removing container %v (size: %v, age: %v)\n", c.ID, c.SizeRw, age)
glog.Infof("removing container %v (size: %v, age: %v)", c.ID, c.SizeRw, age)
err := client.ContainerRemove(ctx, c.ID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not make any real changes if the --dry-run is used.

break
}
fmt.Printf("removing image %v (size: %v, age: %v)\n", i.ID, i.Size, age)
glog.Infof("removing image %v (size: %v, age: %v)", i.ID, i.Size, age)
_, err := client.ImageRemove(ctx, i.ID, dockertypes.ImageRemoveOptions{PruneChildren: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not make any real changes if the --dry-run is used.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 27, 2017
@sjenning
Copy link
Contributor Author

@legionus ok I added the dry-run flag back. It runs in a single-pass mode with no effect.

I also noticed that I had completely misunderstood how contexts work. I've added a commit to fix that.

@sjenning sjenning added the kind/bug Categorizes issue or PR as related to a bug. label Nov 27, 2017
@sjenning
Copy link
Contributor Author

/retest

1 similar comment
@sjenning
Copy link
Contributor Author

/retest

@sjenning sjenning changed the title ex: dockergc: remove BindForOutput flags and other fixups ex: dockergc: various fixes Nov 28, 2017
@sjenning
Copy link
Contributor Author

/retest

ctx, cancel := c.getTimeoutContext()
defer cancel()
containers, err := c.client.ContainerList(ctx, options)
if ctx.Err() == context.DeadlineExceeded {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this additional check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two places an error can happen: the ctx can timeout or the client operation an error. We just need to check both. AFAICT DeadlineExceeded and Canceled are the only possible context errors. Could probably just change this to ctx.Err() != nil, but since there is no way for the context to be cancelled here since the call to cancel() is a defer for this function, they are functionally equivalent.

Since all tests are green, I'd like to avoid non-functional changes if we can. This ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the context is cancelled/timed out, ContainerList should return an error. Though, if it isn't, why do you want to abandon the result in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough. updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

func clientErr(ctx context.Context, err error) error {
	if ctx.Err() != nil {
		return ctx.Err()
	}
	return err
}

@sjenning You move an error handling to this function, it checks ctx.Err() first even if err == nil in the function arguments. I do not see any changes in the old logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sjenning ping

@sjenning
Copy link
Contributor Author

@legionus look good to you now?

@eparis
Copy link
Member

eparis commented Nov 28, 2017

/approve

@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 28, 2017
@legionus
Copy link
Contributor

look good to you now?

LGTM but I think that @dmage's comments should be addressed.

@sjenning sjenning force-pushed the issue-17443 branch 2 times, most recently from 8dc6205 to 5b70b9f Compare November 29, 2017 14:59
@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 29, 2017
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 11, 2017
@sjenning
Copy link
Contributor Author

@derekwaynecarr can I get lgtm?

@sjenning
Copy link
Contributor Author

flake #17698
/retest

@sjenning
Copy link
Contributor Author

opened e2e flake #17721
/retest

@sjenning
Copy link
Contributor Author

/test end_to_end

@sjenning
Copy link
Contributor Author

@eparis
Copy link
Member

eparis commented Jan 10, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2018
@derekwaynecarr
Copy link
Member

/lgtm

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: derekwaynecarr, eparis, sjenning

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

Automatic merge from submit-queue (batch tested with PRs 17932, 18037, 17479, 18051, 18052).

@openshift-merge-robot openshift-merge-robot merged commit ec0e90f into openshift:master Jan 10, 2018
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants