Merge pull request #2808 from liubin/fix/2805-fix-test-leak-of-monitor-socket

runtime: don't start shim management server in tests
This commit is contained in:
Bin Liu 2021-10-08 19:42:09 +08:00 committed by GitHub
commit 0300e91cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -39,6 +39,13 @@ import (
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/oci"
)
type startManagementServerFunc func(s *service, ctx context.Context, ociSpec *specs.Spec)
var defaultStartManagementServerFunc startManagementServerFunc = func(s *service, ctx context.Context, ociSpec *specs.Spec) {
go s.startManagementServer(ctx, ociSpec)
shimLog.Info("management server started")
}
func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*container, error) {
rootFs := vc.RootFs{}
if len(r.Rootfs) == 1 {
@ -131,7 +138,9 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
}
s.hpid = uint32(pid)
go s.startManagementServer(ctx, ociSpec)
if defaultStartManagementServerFunc != nil {
defaultStartManagementServerFunc(s, ctx, ociSpec)
}
case vc.PodContainer:
span, ctx := katatrace.Trace(s.ctx, shimLog, "create", shimTracingTags)

View File

@ -125,6 +125,10 @@ func init() {
}
tc = ktu.NewTestConstraint(false)
// disable shim management server.
// all tests are not using this, so just set it to nil
defaultStartManagementServerFunc = nil
}
// createOCIConfig creates an OCI configuration (spec) file in