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

Bug 1806686: Image pruner updates: Controller / Prune Registry #459

Merged
merged 2 commits into from Feb 25, 2020
Merged

Bug 1806686: Image pruner updates: Controller / Prune Registry #459

merged 2 commits into from Feb 25, 2020

Conversation

coreydaley
Copy link
Member

  • Move the image pruner to it's own controller
  • Implement the --prune-registry flag for the pruner

@coreydaley coreydaley changed the title Image pruner updates: Controller / Prune Registry [WIP] Image pruner updates: Controller / Prune Registry Feb 17, 2020
@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 17, 2020
pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
pkg/resource/prunercronjob.go Outdated Show resolved Hide resolved
pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
@coreydaley
Copy link
Member Author

/retest

1 similar comment
@coreydaley
Copy link
Member Author

/retest

@coreydaley coreydaley changed the title [WIP] Image pruner updates: Controller / Prune Registry Image pruner updates: Controller / Prune Registry Feb 18, 2020
@coreydaley
Copy link
Member Author

/assign @dmage @adambkaplan

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 18, 2020
@coreydaley
Copy link
Member Author

/retest

1 similar comment
@coreydaley
Copy link
Member Author

/retest

@coreydaley
Copy link
Member Author

@adambkaplan @dmage ptal

@coreydaley
Copy link
Member Author

/retest

2 similar comments
@coreydaley
Copy link
Member Author

/retest

@coreydaley
Copy link
Member Author

/retest

pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
pkg/operator/controllerimagepruner.go Outdated Show resolved Hide resolved
pkg/client/listers.go Outdated Show resolved Hide resolved
@dmage
Copy link
Member

dmage commented Feb 20, 2020

/approve

@coreydaley
Copy link
Member Author

@dmage updated per your comments

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 20, 2020
@coreydaley
Copy link
Member Author

/retest

4 similar comments
@coreydaley
Copy link
Member Author

/retest

@coreydaley
Copy link
Member Author

/retest

@coreydaley
Copy link
Member Author

/retest

@coreydaley
Copy link
Member Author

/retest

Copy link
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

Let's break out the --prune-registry fixes.

pkg/resource/prunercronjob.go Outdated Show resolved Hide resolved
- Move the image pruner to it's own controller
- Implement the --prune-registry flag for the pruner
Add tests for the --prune-registry flag
@coreydaley
Copy link
Member Author

@adambkaplan ptal, all tests are passing.

@coreydaley coreydaley changed the title Image pruner updates: Controller / Prune Registry Bug 1806686: Image pruner updates: Controller / Prune Registry Feb 24, 2020
@openshift-ci-robot
Copy link
Contributor

@coreydaley: This pull request references Bugzilla bug 1806686, 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.

In response to this:

Bug 1806686: Image pruner updates: Controller / Prune Registry

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Feb 24, 2020
Copy link
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

LGTM

@dmage @ricardomaraschini Given the scope of this change I'd like a second opinion before we merge.

@coreydaley coreydaley changed the title Bug 1806686: Image pruner updates: Controller / Prune Registry Bug 1806686 1806865: Image pruner updates: Controller / Prune Registry Feb 25, 2020
@openshift-ci-robot
Copy link
Contributor

@coreydaley: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

Bug 1806686 1806865: Image pruner updates: Controller / Prune Registry

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.

@openshift-ci-robot openshift-ci-robot removed the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Feb 25, 2020
@coreydaley coreydaley changed the title Bug 1806686 1806865: Image pruner updates: Controller / Prune Registry Bug 1806686,1806865: Image pruner updates: Controller / Prune Registry Feb 25, 2020
@coreydaley
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@coreydaley: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

/bugzilla refresh

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.

@coreydaley coreydaley changed the title Bug 1806686,1806865: Image pruner updates: Controller / Prune Registry Bug 1806686: Image pruner updates: Controller / Prune Registry Feb 25, 2020
@openshift-ci-robot
Copy link
Contributor

@coreydaley: This pull request references Bugzilla bug 1806686, which is valid.

In response to this:

Bug 1806686: Image pruner updates: Controller / Prune Registry

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Feb 25, 2020
Copy link
Contributor

@ricardomaraschini ricardomaraschini left a comment

Choose a reason for hiding this comment

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

Just a few nits, seems good.

}

func (b ByCreationTimestamp) Less(i, j int) bool {
return !b[j].CreationTimestamp.Time.After(b[i].CreationTimestamp.Time)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we convert this to

return b[j].CreationTimestamp.Time.Before(b[i].CreationTimestamp.Time)

var errs []error

// Wait for the cronjob to have an updated --prune-registry flag
err = wait.Poll(1*time.Second, framework.AsyncOperationTimeout, func() (stop bool, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use time.Second instead of 1*time.Second

@@ -8,6 +8,18 @@ import (
corev1 "k8s.io/api/core/v1"
)

func FlagExistsWithValue(args []string, flag string, value string) error {
for _, arg := range args {
if strings.HasPrefix(arg, flag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that HasPrefix() here might lead us to false positives in the future, i.e. we may have two flags that have the same prefix.

@@ -130,6 +140,15 @@ func (gcj *generatorPrunerCronJob) expected() (runtime.Object, error) {
return cj, nil
}

func (gcj *generatorPrunerCronJob) getPruneRegistry(cr *imageregistryapiv1.Config) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this function could be converted into return cr.Spec.ManagementState == operatorapi.Managed. the function name seems misguiding as well as it does not return a "PruneRegistry" :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

The function handles three cases, Managed, Removed, and UnManaged, so the == would not handle all three.
I feel like the getPruneRegistry is inline with the rest of the get(functionNames) here. Feel free to suggest a new name.

Status: imageregistryv1.ImagePrunerStatus{},
}

client, err := regopset.NewForConfig(c.kubeconfig)
Copy link
Member

Choose a reason for hiding this comment

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

You can use c.clients.RegOp

Copy link
Member

@dmage dmage 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 to merge.

@dmage
Copy link
Member

dmage commented Feb 25, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan, coreydaley, dmage

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

2 similar comments
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan, coreydaley, dmage

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan, coreydaley, dmage

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 6d953d3 into openshift:master Feb 25, 2020
@openshift-ci-robot
Copy link
Contributor

@coreydaley: All pull requests linked via external trackers have merged. Bugzilla bug 1806686 has been moved to the MODIFIED state.

In response to this:

Bug 1806686: Image pruner updates: Controller / Prune Registry

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.

@coreydaley
Copy link
Member Author

/cherrypick release-4.4

@openshift-cherrypick-robot

@coreydaley: new pull request created: #468

In response to this:

/cherrypick release-4.4

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.

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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants