Skip to content

Commit e2ee402

Browse files
authored
Merge pull request #237 from setlog/feature-work-with-broken-timestamp
Treat broken timestamps file as if no timestamps had been created yet instead of failing hard.
2 parents 6b77d54 + 7a0a337 commit e2ee402

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/launcher/timestamps/timestamps.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ type Timestamps struct {
1818
Bundles map[string]string `json:"Bundles"`
1919
}
2020

21+
func createEmptyTimestamps() *Timestamps {
22+
return &Timestamps{DeploymentConfig: "", Bundles: map[string]string{}}
23+
}
24+
2125
func VerifyDeploymentConfigTimestamp(newTimestamp, filePath string) {
2226
timestamps := readTimestamps(filePath)
2327
timestamps.CheckAndSetDeploymentConfigTimestamp(newTimestamp)
@@ -36,7 +40,7 @@ func readTimestamps(filePath string) *Timestamps {
3640
if os.IsNotExist(err) {
3741
log.WithFields(log.Fields{"err": err, "filePath": filePath}).Infof("Could not read timestamps " +
3842
"because the file does not yet exist: looks like this is the first run of the launcher.")
39-
return &Timestamps{DeploymentConfig: "", Bundles: map[string]string{}}
43+
return createEmptyTimestamps()
4044
}
4145
panic(err)
4246
}
@@ -64,7 +68,8 @@ func ReadTimestampsFromReader(reader io.Reader) *Timestamps {
6468
var timestamps Timestamps
6569
err = json.Unmarshal(bytes, &timestamps)
6670
if err != nil {
67-
panic(fmt.Sprintf("Could not unmarshal timestamps `%s`: %v", string(bytes), err))
71+
log.Warnf("Ignoring timestamps: Could not unmarshal timestamps `%s`: %v", string(bytes), err)
72+
return createEmptyTimestamps()
6873
}
6974
return &timestamps
7075
}

0 commit comments

Comments
 (0)