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
Bug 1860163: Optimized Image Pruner #510
Conversation
@dmage: This pull request references Bugzilla bug 1860163, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
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. |
Our image-pruning job started to fail again. Could you please rebase the code so that we can get an oc-binary for the job before this PR lands? |
b1690ac
to
e82f7e7
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed the overall code that carefully, but I'm a bit hesitant to accept a major re-write at this time. How about we push this over to 4.7 and when proved working backport to 4.6?
@soltysh I'm more concerned to have 4.6 with the current pruner. This pruner was already used on CI (one of its WIP versions) because the current one doesn't work on CI, and CI needs a pruner. Ask @stevekuznetsov if he is ok to wait. |
I'll add that for tomorrows review, to carefully examine the changes, I'm fairly familiar with the entire pruner code. |
@@ -101,33 +177,31 @@ type ImageDeleter interface { | |||
type ImageStreamDeleter interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't help but finding this name unfortunate. On other Deleters
we actually have a "Delete" method but not on this one. I guess that it might make sense once I move on with the review, let's see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this object is intended to delete records from image stream statuses
ImageStreamStatusUpdater?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. What I dislike is also the fact that pkg/cli/admin/prune/imageprune/prune.go
is such a huge file, have you considered splitting that into smaller, logical chunks?
pkg/cli/admin/prune/images/images.go
Outdated
return nil | ||
}); err != nil { | ||
return err | ||
} | ||
allImagesUntyped = nil // We don't need it anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above code seems overly convoluted, have a look at https://github.com/kubernetes/kubernetes/blob/51184187b9cc8e54bb51dc921bfb80de3d638635/pkg/controller/cronjob/cronjob_controller.go#L135-L143 and please refactor that so that it's more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaults in pager.SimplePageFunc
are reasonable, I wouldn't tweak them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I didn't know about EachListItem, fixed.
btw, the example that you gave me also needs to be updated. SimplePageFunc is needed for list functions that don't accept ctx. And the list function uses context.TODO(), but it could use ctx
from the pager.
// long as the image is managed by OpenShift. | ||
func (p *pruner) addPodSpecToGraph(referrer *corev1.ObjectReference, spec *corev1.PodSpec, predecessor gonum.Node) []error { | ||
var errs []error | ||
type referenceCounts struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not making a single struct holding the counters instead of embeding one and then another inside?
Why not having one with higher level methods reponsible for adding blobs and manifests rather than directly modify underlying structures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make it easier, stringsCounter is super simple to review
Name: rs.Name, | ||
} | ||
klog.V(4).Infof("Examining %s", ref) | ||
errs = append(errs, p.analyzeReferencesFromPodSpec(ref, &rs.Spec.Template.Spec)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably also verify k8s object's annotations looking for alpha.image.policy.openshift.io/resolve-names
which will be pointing to image streams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it'd be nice to support this annotation, I created a BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1880068
2804e92
to
7e0cb05
Compare
The new implementation of the image pruner does not use graphs. The graph was replaced by two maps. The pruner works in two steps: The first step deletes image stream items (aka revisions) that are not used by the cluster components (pods, builds, etc.) and are not protected by the pruner options (keep-younger-than, keep-tag-revisions, etc.) The second step deletes image objects that are not used by image streams.
@soltysh one day I want to split this pruner into two parts. One is for image streams, another one is for for images. Do you want |
/retest |
@soltysh can you take a look once again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dmage, ricardomaraschini, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@dmage: All pull requests linked via external trackers have merged: Bugzilla bug 1860163 has been moved to the MODIFIED state. In response to this:
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. |
No description provided.