Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static timestamps for cmd:vpp logs #16

Merged
merged 3 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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