If we want to support rkt in validation tool, I find out that some of the container end test programms should be different from the runc.
For example, for vallidate specs.Process, we use command below,
cmdlineBytes, err := ioutil.ReadFile("/proc/1/cmdline")
if err != nil {
return err
}
args := strings.Split(string(bytes.Trim(cmdlineBytes, "\x00")), " ")
if len(args) != len(spec.Process.Args) {
return fmt.Errorf("Process arguments expected: %v, actual: %v")
}
for i, a := range args {
if a != spec.Process.Args[i] {
return fmt.Errorf("Process arguments expected: %v, actual: %v", a, spec.Process.Args[i])
}
}
However, the /proc/1/cmdline in rkt contains systemd args, so the code logic in validating specs.Process.Args should be different with runc.
List my suggestion as below,
First, split the validation programme into seperate samples, such as,
func main() {
app := cli.NewApp()
app.Name = "oci-runtimeValidate"
app.Version = "0.0.1"
app.Usage = "Utilities for OCI runtime validation"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "validateOverall",
Aliases: []string{"va"},
Usage: "Validate overall specs",
Action: func(c *cli.Context) {
validations := []validation{
validateHooks,
validateSelinux,
validateSeccomp,
...
}
for _, v := range validations {
if err := v(spec, rspec); err != nil {
logrus.Fatalf("Validation failed: %q", err)
}
}
},
},
{
Name: "validateSeccomp",
Aliases: []string{"vse"},
Usage: "Validate Seccomp with specs",
Action: func(c *cli.Context) {
if err := validateSeccomp(spec, rspec); err != nil {
logrus.Fatalf("Validation failed: %q", err)
}
},
},
{
Name: "validateHooks",
Aliases: []string{"vho"},
Usage: "Validate Hooks with specs",
Action: func(c *cli.Context) {
if err := validateHooks(spec, rspec); err != nil {
logrus.Fatalf("Validation failed: %q", err)
}
},
},
{
Name: "validateSelinux",
Aliases: []string{"vsel"},
Usage: "Validate selinuxlabel with specs",
Action: func(c *cli.Context) {
if err := validateSelinux(spec, rspec); err != nil {
logrus.Fatalf("Validation failed: %q", err)
}
},
},
...
With this way, we will have benifits as below,
- To do less job in container end with each case, lead to the same effort.
- Cases which have different realization in container end have less impect to others.
- Because we use the standard default template of specs in validate, so we have no need to validate all of the items every time.
What is your opinion? Expect to your response.
If we want to support rkt in validation tool, I find out that some of the container end test programms should be different from the runc.
For example, for vallidate specs.Process, we use command below,
However, the /proc/1/cmdline in rkt contains systemd args, so the code logic in validating specs.Process.Args should be different with runc.
List my suggestion as below,
First, split the validation programme into seperate samples, such as,
With this way, we will have benifits as below,
What is your opinion? Expect to your response.