Skip to content

Conversation

@dgottlieb
Copy link
Member

No description provided.

DefaultsFilePath = "/etc/viam-defaults.json"
CLIDebug = false
CLIWaitForUpdateCheck = false
DevMode = false
Copy link
Member Author

Choose a reason for hiding this comment

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

driveby

@dgottlieb dgottlieb force-pushed the RSDK-12870 branch 5 times, most recently from dad8a33 to 4724f02 Compare December 5, 2025 20:24
// the case where the file was overwritten in place. Being this update logic is run
// every five seconds, it's common to catch a binary while its being
// compiled/written to.
data.brokenTarget = true
Copy link
Member Author

@dgottlieb dgottlieb Dec 5, 2025

Choose a reason for hiding this comment

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

This brokenTarget logic I changed. The "re-check subsystems to see if things changed" happens every 5 seconds. I was routinely hitting the window where a viam-server recompile removed the old file, but had not yet written out the new one.

// TODO handle compressed formats, for now, the raw download is the same file
verData.UnpackedPath = verData.DlPath
verData.DlSHA = actualSha
actualSha, err := utils.GetFileSum(verData.DlPath)
Copy link
Member Author

@dgottlieb dgottlieb Dec 5, 2025

Choose a reason for hiding this comment

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

Everything else here should be exactly the same except for the level of indentation.

I've misread this code -- trying again

//nolint:gosec
in, err := os.Open(filepath)
func GetFileSum(path string) (outSum []byte, errRet error) {
resolvedPath, err := filepath.EvalSymlinks(path)
Copy link
Member

@cheukt cheukt Dec 5, 2025

Choose a reason for hiding this comment

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

so we were just getting the checksum of the symlink before? and that's why file:// links weren't triggering a checksum mismatch and redownload?

@dgottlieb
Copy link
Member Author

This doesn't work. There are four pieces of state that are important:

  • The current config viam-server value
  • What's in the cache/version_cache.json file
  • Binaries in the /opt/viam/cache/ directory
  • Links in the /opt/viam/bin directory

But this code obfuscates which variables relate to which state. I also think it assumes the version cache file is the source of truth (as opposed to what's in the cache directory). And has no notion of cache invalidation. This all to say, I think the code needs a bigger rewrite. Maybe a later attempt will yield a better result.

@dgottlieb dgottlieb closed this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants