Merge pull request #3821 from hashicorp/persist-file-handling

Add graceful handling of malformed persisted service/check files.
This commit is contained in:
Kyle Havlovitz 2018-01-22 12:31:33 -08:00 committed by GitHub
commit c4528a6110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -2155,7 +2155,8 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig) error {
if err := json.Unmarshal(buf, &p); err != nil {
// Backwards-compatibility for pre-0.5.1 persisted services
if err := json.Unmarshal(buf, &p.Service); err != nil {
return fmt.Errorf("failed decoding service file %q: %s", file, err)
a.logger.Printf("[ERR] Failed decoding service file %q: %s", file, err)
continue
}
}
serviceID := p.Service.ID
@ -2234,7 +2235,8 @@ func (a *Agent) loadChecks(conf *config.RuntimeConfig) error {
// Decode the check
var p persistedCheck
if err := json.Unmarshal(buf, &p); err != nil {
return fmt.Errorf("Failed decoding check file %q: %s", file, err)
a.logger.Printf("[ERR] Failed decoding check file %q: %s", file, err)
continue
}
checkID := p.Check.CheckID