Closed levisyin closed 5 days ago
I think the reason may be in the function CheckUpdate
.
If the upgrade-info.json
file was created, but the content hasn't been written into it, would cause the issue.
At the first time, fw.lastModTime
is time.Time{}
, after a file is created, the modTime
of os.Stat(file).ModTime()
would be the creation time, so the expression stat.ModTime().After(fw.lastModTime)
would always be true
.
This would cause the issue: the upgrade-info.json
file was created but hasn't been updated, and the file content length verification inner parseUpgradeInfoFile
would fail.
func (fw *fileWatcher) CheckUpdate(currentUpgrade upgradetypes.Plan) bool {
if fw.needsUpdate {
return true
}
stat, err := os.Stat(fw.filename)
if err != nil {
// file doesn't exists
return false
}
if !stat.ModTime().After(fw.lastModTime) {
return false
}
info, err := parseUpgradeInfoFile(fw.filename, fw.disableRecase)
if err != nil {
panic(fmt.Errorf("failed to parse upgrade info file: %w", err))
}
...
}
Is there an existing issue for this?
What happened?
Cosmos SDK Version
main
How to reproduce?
Run
go test -timeout 30s -run ^TestProcessTestSuite$ -testify.m ^(TestLaunchProcess)$ cosmossdk.io/tools/cosmovisor -v -count=1