-
Notifications
You must be signed in to change notification settings - Fork 110
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
fix RestartModule #4114
fix RestartModule #4114
Conversation
// that state. 'no error' + 'version incremented' is a cheap proxy for that. | ||
err := r.(*localRobot).restartSingleModule(ctx, mod) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, mod.LocalVersion, test.ShouldResemble, "0.0.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure I understand the fuller lifecycle of a real viam-server here. If this test were to continue from here with:
- Create a new config object from json:
cfg, err := config.Read(ctx, cfgPath, logger)
- Use that for a reconfigure:
r.Reconfigure(cfg)
I expect that cfg.Modules[0].LocalVersion
value to be the default value/empty string. And the robot would consider this a diff and restart the module? Presumably unpackaging it back into the "0.0.0" directory (or whatever gets used for the default scenario).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the state is stored in the localRobot, not in the config
so in your example, if r
is reused, the fresh config.Read
won't overwrite the version state; it will be restored by the r.applyLocalModuleVersions(newConfig)
call
in reconfigure
at L1168 here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense -- thanks for pointing me to the important missing link here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw it would be very nice if we could store it in config; would make it way easier to understand the state for reloading + local tarball
I often start these PRs by mutating the Config struct and then am confused for an hour bc it is getting overwritten or I am mutating a copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I'd like to have a better story here as well.
What changed
localRobot.localModuleVersions
map where local module versions can be incremented per conversation with @dgottlieb (see discussion section below)Why
Restart broke at some point (probably when I added local tarball support).
Discussion
This change allows local tarball modules to use the normal module restart flow. Local tarball reloading matters because remote reloading will use local tarballs under the surface.
The normal module restart flow is:
That previously broke with local tarballs, because their version was always
""
(empty string). It would unpack on top of the old unpack, which will break in edge cases where a file is removed from the tarball.(This PR fixes that).
Also note: I added a test here, but it's not a very good test. Ideally we'd want to 1) test a local tarball so we could observe unpacking happening correctly and 2) test that the PID of the module rolls over. This state is hard to get so I cut some corners; if people have ideas on how to get this stuff in localRobot, would be interested to expand the new test.
Checklist
Logs from manual test
With a local tarball module, it incremented the folder version and restarted the process as I restarted from CLI:
Follow ups