MCPcopy
hub / github.com/apptainer/apptainer / createContainer

Function createContainer

internal/app/starter/master_linux.go:29–58  ·  view source on GitHub ↗
(ctx context.Context, rpcSocket int, containerPid int, e *engine.Engine, fatalChan chan error)

Source from the content-addressed store, hash-verified

27)
28
29func createContainer(ctx context.Context, rpcSocket int, containerPid int, e *engine.Engine, fatalChan chan error) {
30 comm := os.NewFile(uintptr(rpcSocket), "rpc-socket")
31 if comm == nil {
32 fatalChan <- fmt.Errorf("bad RPC socket file descriptor")
33 return
34 }
35 rpcConn, err := net.FileConn(comm)
36 comm.Close()
37 if err != nil {
38 fatalChan <- fmt.Errorf("failed to copy unix socket descriptor: %s", err)
39 return
40 }
41
42 configFile := apptainerconf.GetCurrentConfig()
43 if configFile != nil && configFile.AllowMonitoring {
44 apptheusMetric, err := metric.New()
45 if err != nil {
46 sylog.Debugf("Failed to establish connection to apptheus, err: %s", err)
47 }
48 e.ApptheusSocket = apptheusMetric
49 }
50
51 err = e.CreateContainer(ctx, containerPid, rpcConn)
52 if err != nil {
53 fatalChan <- fmt.Errorf("container creation failed: %s", err)
54 return
55 }
56
57 rpcConn.Close()
58}
59
60func startContainer(ctx context.Context, masterSocket int, containerPid int, e *engine.Engine, fatalChan chan error) {
61 comm := os.NewFile(uintptr(masterSocket), "master-socket")

Callers 2

MasterFunction · 0.85
TestCreateContainerFunction · 0.85

Calls 5

GetCurrentConfigFunction · 0.92
NewFunction · 0.92
DebugfFunction · 0.92
CreateContainerMethod · 0.65
CloseMethod · 0.45

Tested by 1

TestCreateContainerFunction · 0.68