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

Remove receipts migration #603

Merged

Conversation

chriskim06
Copy link
Member

This removes the receiptsmigration code like we discussed in the related issue. I'm leaving the system.go file for now and leaving the integration test with the same name, but I might end up changing it in a follow up PR when I switch the index migration to be automatic.

Related issue: #600

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 30, 2020
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 30, 2020
Copy link
Contributor

@corneliusweig corneliusweig left a comment

Choose a reason for hiding this comment

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

I'm feeling a bit uneasy about removing the migration code without having the new one in place. First, it will make it more difficult to re-use the deleted utils and tests for the upcoming automatic migration logic.

But more importantly, if we merge this, we will have to bump the minor version if we have to craft a new release. Patch-level will no longer be correct, because we are breaking something.

Lastly, I think the migration instructions are broken. Or am I wrong here?

@@ -72,6 +54,5 @@ func init() {
if _, ok := os.LookupEnv(constants.EnableMultiIndexSwitch); ok {
systemCmd.AddCommand(indexUpgradeCmd)
}
systemCmd.AddCommand(receiptsUpgradeCmd)
rootCmd.AddCommand(systemCmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to remove the whole system command. It would make sense to do that in a follow-up PR right after this one, so that we can revert the PR lateron if we find that we need system again.
However, as long as it does nothing, there's no point in leaving it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya I was planning on removing it in the follow up PR where I make the index migration automatic.

@@ -16,25 +16,9 @@
package receiptsmigration
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, if we dump the migration logic, we can also dump all checks if KREW_HOME has been migrated, because we don't offer a good way forward. If somebody with an old krew tries to upgrade, they will end up with a broken installation and have to recover manually.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think having Done is useful to be able to detect when to guide 0.2 users on how to manually reinstall krew/plugins right? That's the reason I left this in.

fmt.Fprintln(os.Stderr, "You need to perform a migration to continue using krew.\nPlease run `kubectl krew system receipts-upgrade`")
if !isMigrated {
fmt.Fprintln(os.Stderr, `This version of Krew is not supported anymore. Please manually migrate:
1. Backup plugin list: kubectl krew list > backup.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

So here's the problem: krew list will not work, because the krew we're running here is a new one, but it is faced with an old index. Instead of listing plugins, krew list will simply produce this error message and bail out. That's the reason why I was advocating for a unified migration.

The instructions here cannot rely on any krew command and must rely on bash (BSD flavor, so that OSX works) and PowerShell or other Windows instructions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good catch, I can change this. I can come up with something for bash, but I don't really have any experience in windows 😅. I'll try to figure out what it would look like there, but do you or @ahmetb know what the windows equivalent of ls -d $KREW_HOME/store/ > plugins.tmp/kubectl krew install < plugins.tmp would be?

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.
I'd say don't bother with this and just talk about:

  1. uninstall...
  2. reinstall...
  3. install the plugins you used

(don't mention backups).

cmd/krew/main.go Outdated
@@ -22,5 +22,5 @@ import (

func main() {
cmd.Execute()
defer klog.Flush()
klog.Flush()
Copy link
Member

Choose a reason for hiding this comment

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

🤔 let's move this 1 above maybe and keep as defer.

there might be some os.Exit/panics causing klog.Flush to not be called

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. For some reason the linter started complaining about the defer being at the end of the function

$ hack/run-lint.sh
cmd/krew/main.go:25:2: unnecessaryDefer: defer klog.Flush() is placed just before return (gocritic)
        defer klog.Flush()

I'll do as you suggested 👍

@ahmetb
Copy link
Member

ahmetb commented Jun 3, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, chriskim06

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 3, 2020
@k8s-ci-robot k8s-ci-robot merged commit c23aea1 into kubernetes-sigs:master Jun 3, 2020
@chriskim06 chriskim06 deleted the remove-receipts-migration branch June 11, 2020 15:05
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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

4 participants