Skip to content

Add --prune & --prune-all options to delete the unreferenced revisions#1217

Merged
knative-prow-robot merged 1 commit intoknative:mainfrom
Kaustubh-pande:multiple-name-support
Mar 15, 2021
Merged

Add --prune & --prune-all options to delete the unreferenced revisions#1217
knative-prow-robot merged 1 commit intoknative:mainfrom
Kaustubh-pande:multiple-name-support

Conversation

@Kaustubh-pande
Copy link
Copy Markdown
Contributor

@Kaustubh-pande Kaustubh-pande commented Feb 10, 2021

Description

As per the review comment #317

Changes

  • Add --prune option to remove all unreferenced revisions for a given service
  • Add --prune-all option to remove all the unreferenced revisions

Reference

Fixes #317

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 10, 2021
Copy link
Copy Markdown
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@Kaustubh-pande: 2 warnings.

Details

In response to this:

Description

As per the review comment #317

Changes

  • Add --all option to delete all the revisions

Reference

Fixes #317

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.

Comment thread pkg/kn/commands/revision/delete_mock_test.go Outdated
Comment thread pkg/kn/commands/revision/delete_mock_test.go Outdated
@knative-prow-robot
Copy link
Copy Markdown
Contributor

Hi @Kaustubh-pande. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 10, 2021
Copy link
Copy Markdown
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for contribution.
/ok-to-test
/lgtm
/hold to allow others a chance to review

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 10, 2021
@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 10, 2021
@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

@rhuss : Rethinking on this command, if user deletes all the revisions, the one (or may be multiple) receiving the traffic will be recreated. Should we have this option then ? (as it tries to change the desire state)
Instead, we may consider kn revision delete --unused or kn revision delete --prune to inspect the revisions not receiving the traffic and delete them. wdyt?

Comment thread pkg/kn/commands/revision/delete.go Outdated
Comment thread pkg/kn/commands/revision/delete.go Outdated
Comment thread lib/test/revision.go Outdated
Comment thread test/e2e/revision_test.go Outdated
@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

@rhuss : Rethinking on this command, if user deletes all the revisions, the one (or may be multiple) receiving the traffic will be recreated. Should we have this option then ? (as it tries to change the desire state)
Instead, we may consider kn revision delete --unused or kn revision delete --prune to inspect the revisions not receiving the traffic and delete them. wdyt?

@navidshaikh, @rhuss I think kn revision delete --prune is more suitable here, can I rename --all to --prune?

@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Feb 15, 2021

I agree that we should not unconditionally delete all revisions, as this can (a) lead to an inconsistent state (e.g. when a revision is part of a traffic split) and (b) one of the revision would be recreated anyway.

So my suggestion is to add either a kn revision prune command or an option kn revision delete --prune so that all unreferenced revisions are removed. IMO this is the only reasonable use case.

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2021
@Kaustubh-pande Kaustubh-pande changed the title Add --all option to delete all the revisions Add --prune option to remove all the unreferenced revisions Feb 17, 2021
@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

/retest

Comment thread CHANGELOG.adoc
Comment thread docs/cmd/kn_revision_delete.md Outdated
Comment thread pkg/kn/commands/revision/delete.go Outdated
@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Feb 23, 2021

I don't know by heart but is this PR about delete all revisions in a namespace or only revisions for a specific service ? I think it really should be about deleting revisions for a given service as I think this is the main use case.

So, from UX pov I see the following options that I would love to see

  • kn revision delete --prune myservice (so taking a service name as an argument)
  • kn revision delete --prune-all (extra option to avoid accidentally pruning everything when a service name is forgotten. also I think the option space is not very polluted for kn revision delete so I think having two options is ok)

sorry for reiterating on this, but I think this is important.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2021
@knative knative deleted a comment from knative-prow-robot Feb 23, 2021
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 26, 2021
Comment thread lib/test/revision.go
@Kaustubh-pande Kaustubh-pande force-pushed the multiple-name-support branch from 4abc429 to 7d50aba Compare March 2, 2021 11:51
Comment thread pkg/kn/commands/revision/delete.go Outdated
@knative-prow-robot knative-prow-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 Mar 5, 2021
@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Mar 8, 2021

@Kaustubh-pande @navidshaikh @dsimansk what is left for this PR to get merged ? (sorry, have not followed up the latest changes of the PR)

@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

@Kaustubh-pande @navidshaikh @dsimansk what is left for this PR to get merged ? (sorry, have not followed up the latest changes of the PR)

sorry, I was off for a couple of days, I will push a commit today.

@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Mar 8, 2021

/retest

@Kaustubh-pande Kaustubh-pande force-pushed the multiple-name-support branch from 1afc4fe to a33bddf Compare March 8, 2021 15:28
Base automatically changed from master to main March 8, 2021 17:40
@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

/retest

Comment thread pkg/kn/commands/revision/delete.go Outdated
Comment thread pkg/kn/commands/revision/delete.go Outdated
Comment thread pkg/kn/commands/revision/delete.go Outdated
Comment thread pkg/kn/commands/revision/delete.go Outdated
@Kaustubh-pande Kaustubh-pande force-pushed the multiple-name-support branch from a33bddf to 022715c Compare March 9, 2021 14:35
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/revision/delete.go 84.0% 90.6% 6.6

@Kaustubh-pande
Copy link
Copy Markdown
Contributor Author

/retest

@dsimansk
Copy link
Copy Markdown
Contributor

dsimansk commented Mar 9, 2021

/lgtm
/hold
Adding hold for @navidshaikh and others to take a look.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 9, 2021
Copy link
Copy Markdown
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

/lgtm
/unhold
suggested a few nits which can be fixed in a follow up, thanks!

Comment thread lib/test/revision.go
}
}

// RevisionDeleteWithPruneOption verifies removeing all unreferenced revisions for a given service in sync mode
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// RevisionDeleteWithPruneOption verifies removeing all unreferenced revisions for a given service in sync mode
// RevisionDeleteWithPruneOption verifies removing all unreferenced revisions for a given service in sync mode

Comment thread lib/test/revision.go
r.AssertNoError(out)
}

// RevisionDeleteWithPruneAllOption verifies removeing all unreferenced revision in sync mode
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// RevisionDeleteWithPruneAllOption verifies removeing all unreferenced revision in sync mode
// RevisionDeleteWithPruneAllOption verifies removing all unreferenced revision in sync mode

fmt.Fprintf(cmd.OutOrStdout(), "No unreferenced revisions found.\n")
return nil
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can create the client first and then replace the multiple if/else with switch

Comment thread test/e2e/revision_test.go
nonexistRevision := "hello-nonexist"
test.RevisionMultipleDelete(r, existRevision1, existRevision2, nonexistRevision)

t.Log("update hello service and increase revision count to 4")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Log("update hello service and increase revision count to 4")
t.Log("update hello service and increase revision count")

Copy link
Copy Markdown
Contributor

@navidshaikh navidshaikh Mar 12, 2021

Choose a reason for hiding this comment

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

since the revisions are being deleted in above tests

Comment thread test/e2e/revision_test.go
unRefRevision := test.FindRevisionByGeneration(r, "hello", 3)
test.RevisionDeleteWithPruneOption(r, "hello", unRefRevision)

t.Log("update hello service and increase revision count to 5")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Log("update hello service and increase revision count to 5")
t.Log("update hello service and increase revision count")

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 12, 2021
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maximilien, navidshaikh

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [maximilien,navidshaikh]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@navidshaikh
Copy link
Copy Markdown
Contributor

/test pull-knative-client-integration-tests-latest-release

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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Consider supporting multiple NAMEs on some commands

7 participants