| 27 | ) |
| 28 | |
| 29 | func 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 | |
| 60 | func startContainer(ctx context.Context, masterSocket int, containerPid int, e *engine.Engine, fatalChan chan error) { |
| 61 | comm := os.NewFile(uintptr(masterSocket), "master-socket") |