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

The viceroy_version field seems to not be working #1037

Closed
dbraley opened this issue Oct 9, 2023 · 8 comments · Fixed by #1039
Closed

The viceroy_version field seems to not be working #1037

dbraley opened this issue Oct 9, 2023 · 8 comments · Fixed by #1039
Labels
bug Something isn't working

Comments

@dbraley
Copy link

dbraley commented Oct 9, 2023

Version

Fastly CLI version v10.4.0 (4b869ab)
Built with go version go1.21.0 linux/amd64
Viceroy version: viceroy 0.9.1

What happened

This morning, we noticed a new version of Viceroy (0.9.0) seems to have broken our local development environment. I've filed fastly/Viceroy#321 with Viceroy to resolve that.

To keep our engineers moving while they work on it, we tried to force the version with the viceroy_version field in the fastly.toml (https://developer.fastly.com/reference/compute/fastly-toml/#local-server) file used for development:

[local_server]
viceroy_version = "0.8.1"

We also tried with viceroy_version = "v0.8.1". If I'm providing that information incorrectly, please do let me know.

Neither attempt to set the version through the toml file showed any indication that they were using an older version of viceroy, and both still failed with the same exact bug. However, downloading v0.8.1 directly from https://github.com/fastly/Viceroy/releases/tag/v0.8.1 and using the --viceroy-path flag on the fastly compute serve command did resolve the problem.

@dbraley dbraley added the bug Something isn't working label Oct 9, 2023
@Integralist
Copy link
Collaborator

👋🏻 Thanks @dbraley for alerting us to this.

It might be that the TTL on the Viceroy check hadn't expired. If you run fastly config you'll see something like...

[viceroy]
last_checked = "2023-10-06T14:12:37+01:00"
latest_version = "0.8.1"
ttl = "24h"

If the TTL hasn't expired, no checks will be executed. In those cases you can either modify the config to have a shorter TTL (e.g. "1m" for one minute) or you can force past the TTL using --viceroy-check (see https://developer.fastly.com/reference/cli/compute/serve/)

But that's only related to installing updates (which you clearly already had done) so I'll investigate as I'm thinking maybe there's a disconnect between what's specified in the fastly.toml manifest vs the internal fastly config.

Thanks again for raising this issue.

@dbraley
Copy link
Author

dbraley commented Oct 9, 2023

Thanks!

@Integralist
Copy link
Collaborator

Hi @dbraley I'm not sure which CLI version you were using, but I just used a local build of the CLI and found the ability to install a specific Viceroy version worked fine (i.e. fastly compute serve --verbose)...

Screenshot 2023-10-10 at 10 40 03

The fastly.toml config looked like this:

[local_server]
viceroy_version = "0.8.0"

@Integralist
Copy link
Collaborator

I switched back to the latest CLI release (10.4.0) and that seems to be correctly respecting my pinned Viceroy version...

Screenshot 2023-10-10 at 10 43 29

I then changed the pinned version and the latest CLI release correctly identified that I had changed the version required...

Screenshot 2023-10-10 at 10 44 39

I then removed the pinned version entirely from my fastly.toml config and the latest CLI version correctly updated my installed version to the latest release...

Screenshot 2023-10-10 at 10 46 44

The following screenshot demonstrates, since I've only just updated the Viceroy version, that the 24hr TTL hasn't expired and so it's not going to check for a newer Viceroy version and will just use what I have installed...

Screenshot 2023-10-10 at 10 47 51

And just to be triple-sure it was working, after the Viceroy binary was updated to the latest release I added back the override version into my fastly.toml and the CLI correctly identified the change in requirement...

Screenshot 2023-10-10 at 10 49 49

@Integralist
Copy link
Collaborator

I'm going to close this issue now, as it seems the CLI is working as intended.

As you have correctly mentioned (and have used) there are also other options to allow you to change the Viceroy version:

  • --viceroy-path for looking up the binary from a specific location
  • FASTLY_VICEROY_USE_PATH=<TRUE|1> for looking up the Viceroy binary in your $PATH.

@dbraley
Copy link
Author

dbraley commented Oct 10, 2023

AH! Okay, I think I see where we were going astray. Thank you for the quick feedback by the way, and sorry for not providing the cli version in the issue text where I was supposed to (had something else in my copy buffer, meant to come back and do that and forgot).

Anyway, I think the problem is that we were using env files, which is where we have all of our [local_server] setup, so it seemed logical that the viceroy_version needed to be there as well.

❯ head -3 fastly.frontend.toml
# This toml is part of the frontend development configuration.
[local_server]
viceroy_version = "0.8.1"

❯ fastly compute serve --env frontend --addr=0.0.0.0:8090 -v --file=local/wasm32-wasi/release/ka-fastly.wasm --skip-build
Fastly API token provided via config file (profile: personal)
Fastly API endpoint: https://api.fastly.com


INFO: Viceroy is installed but the CLI config (`fastly config`) shows the TTL, checking for a newer version,
hasn't expired. To force a refresh, re-run the command with the `--viceroy-check` flag.

✓ Running local server

Manifest: /Users/davidbraley/khan/webapp/services/fastly-khanacademy-dev/fastly.frontend.toml
Wasm binary: local/wasm32-wasi/release/ka-fastly.wasm
Viceroy binary: /Users/davidbraley/Library/Application Support/fastly/viceroy
Viceroy version: viceroy 0.9.1

But it doesn't work there. It does if you add it to the actual fastly.toml file though!

❯ tail -2 fastly.toml
[local_server]
viceroy_version = "0.8.1"

❯ fastly compute serve --env frontend --addr=0.0.0.0:8090 -v --file=local/wasm32-wasi/release/ka-fastly.wasm --skip-build --viceroy-check
Fastly API token provided via config file (profile: personal)
Fastly API endpoint: https://api.fastly.com


INFO: Viceroy is already installed, and the installed version matches the required version (0.8.1) in the
fastly.toml file.

✓ Running local server

Manifest: /Users/davidbraley/khan/webapp/services/fastly-khanacademy-dev/fastly.frontend.toml
Wasm binary: local/wasm32-wasi/release/ka-fastly.wasm
Viceroy binary: /Users/davidbraley/Library/Application Support/fastly/viceroy
Viceroy version: viceroy 0.8.1

I'm honestly not sure if that's a bug or not, but if not it should probably be documented somewhere that the viceroy_version must be in the actual fastly.toml file, not an env file. Unless it is and I just missed it somewhere?

Anyway, I'm definitely unblocked a few ways, so I'll leave it to y'all to figure out if there's any actual action to be done here. Thanks again!

@Integralist
Copy link
Collaborator

This is great feedback @dbraley thank you!

I actually forgot about the --env feat 🤦🏻 so leave this with me as I think the problem is that the CLI (for the most part) deals directly with the fastly.toml so it's very likely there are a few places where we should actually be checking for --env being set and consulting that file instead.

@Integralist
Copy link
Collaborator

@dbraley I think I've addressed the underlying issue you reported. Thanks again for bubbling this issue up to us as we had neglected to include the environment files as part of the compute serve command installing the Viceroy dependency.

#1039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants