Skip to content

Commit

Permalink
Merge pull request #16 from d-uzlov/fix-static-timestamp
Browse files Browse the repository at this point in the history
Fix static timestamps for cmd:vpp logs
  • Loading branch information
edwarnicke authored May 4, 2023
2 parents 3e6797d + 5d2d93d commit 3266d87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.31
version: v1.52.2

checkgomod:
name: check go.mod and go.sum
Expand Down
13 changes: 8 additions & 5 deletions start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os"
"path"
"path/filepath"
"time"

"git.fd.io/govpp.git/api"
"github.com/edwarnicke/exechelper"
Expand Down Expand Up @@ -55,7 +56,9 @@ func StartAndDialContext(ctx context.Context, opts ...Option) (conn Connection,
close(errCh)
return nil, errCh
}
logWriter := log.Entry(ctx).WithField("cmd", "vpp").Writer()
// We need to reset time in logger to make sure that
// we don't use a static timestamp for a long-running process
logWriter := log.Entry(ctx).WithField("cmd", "vpp").WithTime(time.Time{}).Writer()
vppErrCh := exechelper.Start("vpp -c "+filepath.Join(o.rootDir, vppConfFilename),
exechelper.WithContext(ctx),
exechelper.WithStdout(logWriter),
Expand All @@ -81,18 +84,18 @@ func writeDefaultConfigFiles(ctx context.Context, o *option) error {
filename = filepath.Join(o.rootDir, filename)
if _, err := os.Stat(filename); os.IsNotExist(err) {
log.Entry(ctx).Infof("Configuration file: %q not found, using defaults", filename)
if err := os.MkdirAll(path.Dir(filename), 0700); err != nil {
if err := os.MkdirAll(path.Dir(filename), 0o700); err != nil {
return err
}
if err := ioutil.WriteFile(filename, []byte(contents), 0600); err != nil {
if err := ioutil.WriteFile(filename, []byte(contents), 0o600); err != nil {
return err
}
}
}
if err := os.MkdirAll(filepath.Join(o.rootDir, "/var/run/vpp"), 0700); os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Join(o.rootDir, "/var/run/vpp"), 0o700); os.IsNotExist(err) {
return err
}
if err := os.MkdirAll(filepath.Join(o.rootDir, "/var/log/vpp"), 0700); os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Join(o.rootDir, "/var/log/vpp"), 0o700); os.IsNotExist(err) {
return err
}
return nil
Expand Down

0 comments on commit 3266d87

Please sign in to comment.