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 possible leak (W.i.P.) #3194

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion cmd/sharded-test-server/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ func startCacheServer(ctx context.Context, logDirPath, workingDir string, synthe
return nil, "", err
}

logger := klog.FromContext(ctx)
defer func() {
err = logFile.Close()
if err != nil {
logger.Error(err, "failed to close the log file")
}
}()

writer := helpers.NewHeadWriter(logFile, out)
cmd.Stdout = writer
cmd.Stdin = os.Stdin
Expand All @@ -88,7 +96,6 @@ func startCacheServer(ctx context.Context, logDirPath, workingDir string, synthe
}()

// wait for readiness
logger := klog.FromContext(ctx)
logger.Info("waiting for the cache server to be up")
cacheKubeconfigPath := filepath.Join(cacheWorkingDir, "cache.kubeconfig")
for {
Expand Down
7 changes: 7 additions & 0 deletions cmd/sharded-test-server/frontproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ func startFrontProxy(
return err
}

defer func() {
err = logFile.Close()
if err != nil {
logger.Error(err, "failed to close the log file")
}
}()

writer := helpers.NewHeadWriter(logFile, out)
cmd.Stdout = writer
cmd.Stdin = os.Stdin
Expand Down
8 changes: 8 additions & 0 deletions cmd/sharded-test-server/virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ func (v *VirtualWorkspace) start(ctx context.Context) error {
return err
}

// logger := klog.FromContext(ctx)
// defer func() {
// err = logFile.Close()
// if err != nil {
// logger.Error(err, "failed to close the log file")
// }
// }()

v.writer = helpers.NewHeadWriter(logFile, out)
cmd.Stdout = v.writer
cmd.Stdin = os.Stdin
Expand Down
7 changes: 7 additions & 0 deletions cmd/test-server/kcp/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ func (s *Shard) Start(ctx context.Context, quiet bool) error {
return err
}

// defer func() {
// err = logFile.Close()
// if err != nil {
// logger.Error(err, "failed to close the log file")
// }
// }()

s.writer = helpers.NewHeadWriter(logFile, out)
cmd.Stdout = s.writer
cmd.Stdin = os.Stdin
Expand Down
Loading