weaver: ssh deployer errors with "unknown keys [location_file]"

I’ve tried both setting up my own test weaver application and using the collatz example and both times when running

❯ weaver ssh deploy weaver.toml

I get the following error message

unable to parse ssh config: section "ssh" has unknown keys [locations_file]

I’ve tried looking at the code but nothing seems to stand out to me at a quick glance as to why this is erroring. I don’t fully understand how all the code works just yet but thought I’d raise the issue and continue debugging

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Hi @aranw. Thanks for pointing out the issue. @dnephin this is one of the problem, great find 😃. There is another small issue we introduced while renaming the project. I am creating a fix.

Nice bug report! I’m just learning the code as well, but I may have an idea about this problem.

https://github.com/ServiceWeaver/weaver/blob/35727ae307c392d27cadfbf5302d56a3e76977ab/internal/tool/ssh/deploy.go#L181-L186

I believe the serverweaver_metric struct tag on line 182 is wrong. It doesn’t appear anywhere else in the code, and ParseConfigSection (which receives that struct) seems to use https://pkg.go.dev/github.com/burntsushi/toml#Decode to decode the config. That function expects a toml struct tag.

That leaves the locations_file field from the config as “undecoded”, which causes the error here:

https://github.com/ServiceWeaver/weaver/blob/35727ae307c392d27cadfbf5302d56a3e76977ab/runtime/config.go#L87-L88

I suspect this diff should fix it, but I’m not familiar enough with the testing of this package to add test coverage for the change:

diff --git a/internal/tool/ssh/deploy.go b/internal/tool/ssh/deploy.go
index 6a6e276..9be6534 100644
--- a/internal/tool/ssh/deploy.go
+++ b/internal/tool/ssh/deploy.go
@@ -179,7 +179,7 @@ func getLocations(app *protos.AppConfig) ([]string, error) {
 	const shortSSHKey = "ssh"
 
 	type sshConfigSchema struct {
-		LocationsFile string `serverweaver_metric:"locations_file"`
+		LocationsFile string `toml:"locations_file"`
 	}
 	parsed := &sshConfigSchema{}
 	if err := runtime.ParseConfigSection(sshKey, shortSSHKey, app, parsed); err != nil {