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

caddy upgrade can downgrade Caddy #4057

Open
basilhendroff opened this issue Mar 9, 2021 · 7 comments
Open

caddy upgrade can downgrade Caddy #4057

basilhendroff opened this issue Mar 9, 2021 · 7 comments
Labels
bug 🐞 Something isn't working discussion 💬 The right solution needs to be found
Milestone

Comments

@basilhendroff
Copy link

Two issues:

  1. Caddy upgrade downgrades to 2.3.0
    2.. Backup file caddy.tmp is not created.

For details, please refer to https://caddy.community/t/caddy-2-4-0-beta-1-is-now-available/11519/17?u=basil

@francislavoie francislavoie added the bug 🐞 Something isn't working label Mar 9, 2021
@francislavoie francislavoie added this to the v2.4.0 milestone Mar 9, 2021
@xdevs23
Copy link
Contributor

xdevs23 commented Mar 9, 2021

I'm guessing that the currently installed version is not checked in

func cmdUpgrade(_ Flags) (int, error) {
and thus it just downloads the stable and installs it?

@mholt
Copy link
Member

mholt commented Mar 10, 2021

@xdevs23 Correct. The problem I'm currently wrestling with is, I'm not sure how to know what the new version will be before Go builds it. Without an explicit version passed into the go command, it uses latest which is kind of mysterious. We could just go ahead with the upgrade anyway and then check its resulting version string by running caddy version on the new binary, but this is not ideal if the resulting binary isn't even wanted in the first place; it adds pressure to the Caddy build server and takes time, etc.

As for:

Backup file caddy.tmp is not created

This is not actually the case, as discussed in the thread; it just gets cleaned up afterward after a successful upgrade. We can consider leaving it though.

@mholt mholt modified the milestones: v2.4.0, 2.x Mar 10, 2021
@mholt mholt added the discussion 💬 The right solution needs to be found label Mar 10, 2021
@xdevs23
Copy link
Contributor

xdevs23 commented Mar 10, 2021

Would it be possible to have an API endpoint (or maybe just a file in each GitHub release) containing its own version?
For example:

https://github.com/caddyserver/caddy/releases/download/latest/version.txt

And then just parse the semver and check if it's newer (and not a version that has an extra string at the end like -beta.1)

This could be incorporated into the cmdUpgrade function so that checking for a new version is just a simple GET call with a text response.

@mholt
Copy link
Member

mholt commented Apr 5, 2021

Someone showed me how to get the version that the go tool will resolve to, like which version will be used when latest is specified:

$ go list -m -json github.com/caddyserver/caddy/v2@latest

@francislavoie
Copy link
Member

@mholt apparently this could work too (note the >):

$ go list -m -json github.com/caddyserver/caddy/v2@>{current_version}

e.g.

$ go list -m -json github.com/caddyserver/caddy/v2@>v2.4.0-beta.1

But unfortunately I don't think we can actually test this right now because the latest version happens to be a stable version, since we just released v2.4.0 🤦‍♂️

@Caligatio
Copy link

I stumbled into this issue and accidentally opened duplicate issue #4159

Another thing to think about is whether a plugin update should ideally trigger an upgrade. I don't know how any of this is managed on the back-end but, if Caddy isn't updated and one of the requested plugins has an update, should this trigger an upgrade?

Would this be more easily solved with an upgrade web service? I'm imagining something like:

  • Some server-side code periodically checks the Caddy and plugin repositories to see if there are new commits/releases.
  • When upgrade is called, Caddy sends its version as well as all plugin versions to the upgrade web service.
  • Said web service evaluates whether new versions of any of the requested parts are available:
    • If there are new parts, the web service acts as a pass-through to the current download system.
    • If there are no new parts, it returns something like a HTTP 304 to indicate no action is required.

francislavoie added a commit that referenced this issue Oct 16, 2021
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.
francislavoie added a commit that referenced this issue Oct 18, 2021
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.
francislavoie added a commit that referenced this issue Oct 19, 2021
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.
francislavoie added a commit that referenced this issue Nov 6, 2021
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.
mholt pushed a commit that referenced this issue Nov 8, 2021
* caddycmd: Add `--skip-cleanup` to upgrade commands

This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.

* caddycmd: Fix duplicate error message

The error message "download succeeded, but unable to execute" was repeated, because it was both in the `listModules`/`showVersion` functions and in the calling `upgradeBuild` function. Oversight when this was refactored.

* caddycmd: Implement fix for performing cleanup on Windows

Without this, the cleanup operation would fail with an error message like this:

upgrade: download succeeded, but unable to clean up backup binary: remove C:\caddy\caddy.exe.tmp: Access is denied.

* caddycmd: Rename to `--keep-backup`, simplify build constraints
@jant90
Copy link

jant90 commented Feb 2, 2022

I always run caddy upgrade before actually starting Caddy to keep my install up-to-date and I would like to see a version check before upgrading as well, so Caddy won't upgrade itself (and download the binary) on every run even when it already is on the latest version.

@mholt mholt changed the title Caddy upgrade bugs caddy upgrade can downgrade Caddy May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working discussion 💬 The right solution needs to be found
Projects
None yet
Development

No branches or pull requests

6 participants