Skip to content

Commit

Permalink
remove old init function
Browse files Browse the repository at this point in the history
  • Loading branch information
adamancini committed Sep 18, 2023
1 parent 94d9639 commit 357504e
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions pkg/collect/host_filesystem_performance_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import (
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
)

// func init() {
// rand.Seed(time.Now().UnixNano())
// }

type Durations []time.Duration

// Today we only care about checking for write latency so the options struct
Expand Down Expand Up @@ -64,26 +60,26 @@ func collectHostFilesystemPerformance(hostCollector *troubleshootv1beta2.Filesys
return nil, errors.Wrapf(err, "failed to mkdir %q", hostCollector.Directory)
}

// filename := filepath.Join(hostCollector.Directory, fioJobOptions.Name)
// // Create file handle
// f, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
// if err != nil {
// if os.IsPermission(err) {
// return nil, errors.Wrapf(err, "open %s permission denied; please run this collector as root", filename)
// } else if os.IsNotExist(err) {
// return nil, errors.Wrapf(err, "open %s no such file or directory", filename)
// } else {
// return nil, errors.Wrapf(err, "open %s for writing failed", filename)
// }
// }
// defer func() {
// if err := f.Close(); err != nil {
// log.Println(err.Error())
// }
// if err := os.Remove(filename); err != nil {
// log.Println(err.Error())
// }
// }()
filename := filepath.Join(hostCollector.Directory, fioJobOptions.Name)
// Create file handle
f, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
if err != nil {
if os.IsPermission(err) {
return nil, errors.Wrapf(err, "open %s permission denied; please run this collector as root", filename)
} else if os.IsNotExist(err) {
return nil, errors.Wrapf(err, "open %s no such file or directory", filename)
} else {
return nil, errors.Wrapf(err, "open %s for writing failed", filename)
}
}
defer func() {
if err := f.Close(); err != nil {
log.Println(err.Error())
}
if err := os.Remove(filename); err != nil {
log.Println(err.Error())
}
}()

// Start the background IOPS task and wait for warmup
if hostCollector.EnableBackgroundIOPS {
Expand Down

0 comments on commit 357504e

Please sign in to comment.