1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Copyright (c) Contributors to the Apptainer project, established as
// Apptainer a Series of LF Projects LLC.
// For website terms of use, trademark policy, privacy policy and other
// project policies see https://lfprojects.org/policies
// Copyright (c) 2020, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the URIs of this project regarding your
// rights to use or distribute this software.
package main
import (
"os"
"syscall"
"time"
pluginapi "github.com/apptainer/apptainer/pkg/plugin"
apptainercallback "github.com/apptainer/apptainer/pkg/plugin/callback/runtime/engine/apptainer"
apptainerConfig "github.com/apptainer/apptainer/pkg/runtime/engine/apptainer/config"
"github.com/apptainer/apptainer/pkg/runtime/engine/config"
)
// Plugin is the only variable which a plugin MUST export.
// This symbol is accessed by the plugin framework to initialize the plugin.
var Plugin = pluginapi.Plugin{
Manifest: pluginapi.Manifest{
Name: "github.com/apptainer/apptainer/e2e-runtime-plugin",
Author: "Sylabs Team",
Version: "0.1.0",
Description: "E2E runtime plugin",
},
Callbacks: []pluginapi.Callback{
(apptainercallback.MonitorContainer)(callbackMonitor),
(apptainercallback.PostStartProcess)(callbackPostStart),
},
}
func callbackMonitor(config *config.Common, pid int, signals chan os.Signal) (syscall.WaitStatus, error) {
var status syscall.WaitStatus
cfg := config.EngineConfig.(*apptainerConfig.EngineConfig)
if !cfg.GetContain() {
os.Exit(42)
} else {
// sleep until post start process exit
time.Sleep(10 * time.Second)
}
return status, nil
}
func callbackPostStart(config *config.Common, pit int) error {
cfg := config.EngineConfig.(*apptainerConfig.EngineConfig)
if cfg.GetContain() {
os.Exit(43)
}
return nil
}
|