mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
Removed redundant logging
This commit is contained in:
parent
c26fd66edd
commit
f8b633c69e
@ -1428,7 +1428,7 @@ func (a *Agent) persistService(service *structs.NodeService) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return writeFileAtomic(svcPath, encoded, a.logger)
|
return writeFileAtomic(svcPath, encoded)
|
||||||
}
|
}
|
||||||
|
|
||||||
// purgeService removes a persisted service definition file from the data dir
|
// purgeService removes a persisted service definition file from the data dir
|
||||||
@ -1456,7 +1456,7 @@ func (a *Agent) persistCheck(check *structs.HealthCheck, chkType *structs.CheckT
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return writeFileAtomic(checkPath, encoded, a.logger)
|
return writeFileAtomic(checkPath, encoded)
|
||||||
}
|
}
|
||||||
|
|
||||||
// purgeCheck removes a persisted check definition file from the data dir
|
// purgeCheck removes a persisted check definition file from the data dir
|
||||||
@ -1470,7 +1470,7 @@ func (a *Agent) purgeCheck(checkID types.CheckID) error {
|
|||||||
|
|
||||||
// writeFileAtomic writes the given contents to a temporary file in the same
|
// writeFileAtomic writes the given contents to a temporary file in the same
|
||||||
// directory, does an fsync and then renames the file to its real path
|
// directory, does an fsync and then renames the file to its real path
|
||||||
func writeFileAtomic(path string, contents []byte, logger *log.Logger) error {
|
func writeFileAtomic(path string, contents []byte) error {
|
||||||
uuid, err := uuid.GenerateUUID()
|
uuid, err := uuid.GenerateUUID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -1485,26 +1485,21 @@ func writeFileAtomic(path string, contents []byte, logger *log.Logger) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := fh.Write(contents); err != nil {
|
if _, err := fh.Write(contents); err != nil {
|
||||||
logger.Printf("[INFO] Writing to temp file at %v failed, deleting...\n", tempPath)
|
|
||||||
fh.Close()
|
fh.Close()
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := fh.Sync(); err != nil {
|
if err := fh.Sync(); err != nil {
|
||||||
logger.Printf("[INFO] Syncing temp file at %v failed, deleting...\n", tempPath)
|
|
||||||
fh.Close()
|
fh.Close()
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := fh.Close(); err != nil {
|
if err := fh.Close(); err != nil {
|
||||||
logger.Printf("[INFO] Closing file handle to temp file at %v failed, deleting...\n", tempPath)
|
|
||||||
fh.Close()
|
fh.Close()
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.Rename(tempPath, path); err != nil {
|
if err := os.Rename(tempPath, path); err != nil {
|
||||||
logger.Printf("[INFO] Renaming temp file at %v failed, deleting...\n", tempPath)
|
|
||||||
fh.Close()
|
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -2092,6 +2087,7 @@ func (a *Agent) loadServices(conf *Config) error {
|
|||||||
a.logger.Printf("[WARN] Ignoring temporary service file %v", fi.Name())
|
a.logger.Printf("[WARN] Ignoring temporary service file %v", fi.Name())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the file for reading
|
// Open the file for reading
|
||||||
file := filepath.Join(svcDir, fi.Name())
|
file := filepath.Join(svcDir, fi.Name())
|
||||||
fh, err := os.Open(file)
|
fh, err := os.Open(file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user