Skip to content

cmd/syncthing: Do auto-upgrade before startup (fixes #6384) - #6385

Merged
imsodin merged 4 commits into
syncthing:masterfrom
imsodin:cmdsyncthing/earlyUpgrade
Mar 16, 2020
Merged

imsodin merged 4 commits into
syncthing:masterfrom
imsodin:cmdsyncthing/earlyUpgrade

Conversation

@imsodin

@imsodin imsodin commented Feb 28, 2020

Copy link
Copy Markdown
Member

From #6384:

This is usually fine, but sometimes we fuck up in release candidates and they crash. If that crash is early & persistent then the auto upgrade won't kick in and the user is stuck.

Maybe, potentially, we should consider doing the upgrade check early and before doing other stuff.

Of course it will never happen again that I produce a panic-inducing PR (ahem...), but nevertheless I believe that we definitely should do that.

I tested -upgrade-check -upgrade and with and without STNOUPGRADE=1: It all did the expected.

I made checkUpgradeExitOnErr a function variable instead of a global function, as I believe no functions except the main... ones should ever call os.Exit. If it is considered ugly, I'd rather go for the little bit of duplication of explicitly handling the errors in the two upgrade ifs below that.

Comment thread cmd/syncthing/main.go Resolved
Comment thread cmd/syncthing/main.go Resolved
Comment thread cmd/syncthing/main.go Resolved
Comment thread cmd/syncthing/main.go Resolved
Comment thread cmd/syncthing/main.go Resolved
Comment thread cmd/syncthing/main.go Resolved

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks OK to me. I want one more review on this by someone, as auto upgrade failures have a tendency to be really annoying to sort out after the fact...

@AudriusButkevicius

Copy link
Copy Markdown
Member

I'll have a look in front of a larger screen

Comment thread cmd/syncthing/main.go
}
// Log the error if relevant.
if err != nil {
if _, ok := err.(errNoUpgrade); !ok {

@AudriusButkevicius AudriusButkevicius Mar 15, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this not be err.(*errNoUpgrade) ? As err is effectively an interface ( Error() string } hence it can't be a value, and is always a pointer?
Did you verify this works?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I checked that it works. errNoUpgrade is returned, not a pointer. An interface variable need not be a pointer, it just has to implement the interface as a value or pointer. And usually methods are implemented with pointer receivers, but it is customary to use value receivers for custom errors (I guess because you never change them after creating).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as I said, lgtm otherwise

@AudriusButkevicius AudriusButkevicius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm other than that one question

@imsodin
imsodin merged commit c101a04 into syncthing:master Mar 16, 2020
@imsodin
imsodin deleted the cmdsyncthing/earlyUpgrade branch March 16, 2020 07:12
calmh added a commit to imsodin/syncthing that referenced this pull request Mar 16, 2020
* master:
  lib/db: Use need func in withNeed and simplify (syncthing#6412)
  cmd/syncthing: Do auto-upgrade before startup (fixes syncthing#6384) (syncthing#6385)
calmh added a commit to calmh/syncthing that referenced this pull request Mar 17, 2020
* master:
  lib/protocol: Zero pad index ID strings
  lib/db: Don't ignore failures unmarshaling version lists (syncthing#6411)
  lib/db: Use need func in withNeed and simplify (syncthing#6412)
  cmd/syncthing: Do auto-upgrade before startup (fixes syncthing#6384) (syncthing#6385)
  lib/db: Extend set test with second remote (syncthing#6402)
  gui, man, authors: Update docs, translations, and contributors
  lib/protocol: Use BlocksHash to compare block lists when available (syncthing#6401)
  lib/api: Ignore that one file that always shows up in git status
@calmh calmh added this to the v1.4.1 milestone Mar 18, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Apr 7, 2020
calmh added a commit that referenced this pull request Apr 8, 2020
* release:
  lib/db: Don't get blocklists on drop and missing continue (ref #6457) (#6502)
  Revert "cmd/syncthing: Do auto-upgrade before startup (fixes #6384) (#6385)"
  lib/ur: Correct freaky error handling (fixes #6499) (#6500)
@calmh calmh modified the milestones: v1.4.1, v1.5.0 Apr 8, 2020
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Mar 17, 2021
@syncthing syncthing locked and limited conversation to collaborators Mar 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants