• Kubernetes Submit Queue's avatar
    Merge pull request #32427 from Random-Liu/system-verification · 9534c4f5
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Node Conformance Test: Add system verification
    
    For #30122 and #29081.
    
    This PR introduces system verification test in node e2e and conformance test. It will run before the real test. Once the system verification fails, the test will just fail. The output of the system verification is like this:
    
    ```
    I0909 23:33:20.622122    2717 validators.go:45] Validating os...
    OS: Linux
    I0909 23:33:20.623274    2717 validators.go:45] Validating kernel...
    I0909 23:33:20.624037    2717 kernel_validator.go:79] Validating kernel version
    KERNEL_VERSION: 3.16.0-4-amd64
    I0909 23:33:20.624146    2717 kernel_validator.go:93] Validating kernel config
    CONFIG_NAMESPACES: enabled
    CONFIG_NET_NS: enabled
    CONFIG_PID_NS: enabled
    CONFIG_IPC_NS: enabled
    CONFIG_UTS_NS: enabled
    CONFIG_CGROUPS: enabled
    CONFIG_CGROUP_CPUACCT: enabled
    CONFIG_CGROUP_DEVICE: enabled
    CONFIG_CGROUP_FREEZER: enabled
    CONFIG_CGROUP_SCHED: enabled
    CONFIG_CPUSETS: enabled
    CONFIG_MEMCG: enabled
    I0909 23:33:20.679328    2717 validators.go:45] Validating cgroups...
    CGROUPS_CPU: enabled
    CGROUPS_CPUACCT: enabled
    CGROUPS_CPUSET: enabled
    CGROUPS_DEVICES: enabled
    CGROUPS_FREEZER: enabled
    CGROUPS_MEMORY: enabled
    I0909 23:33:20.679454    2717 validators.go:45] Validating docker...
    DOCKER_GRAPH_DRIVER: aufs
    ```
    
    It verifies the system following a predefined `SysSpec`:
    
    ``` go
    // DefaultSysSpec is the default SysSpec.
     var DefaultSysSpec = SysSpec{
        OS:            "Linux",
        KernelVersion: []string{`3\.[1-9][0-9].*`, `4\..*`}, // Requires 3.10+ or 4+
        // TODO(random-liu): Add more config
        KernelConfig: KernelConfig{
            Required: []string{
                "NAMESPACES", "NET_NS", "PID_NS", "IPC_NS", "UTS_NS",
                "CGROUPS", "CGROUP_CPUACCT", "CGROUP_DEVICE", "CGROUP_FREEZER",
                "CGROUP_SCHED", "CPUSETS", "MEMCG",
            },
            Forbidden: []string{},
        },
        Cgroups: []string{"cpu", "cpuacct", "cpuset", "devices", "freezer", "memory"},
        RuntimeSpec: RuntimeSpec{
            DockerSpec: &DockerSpec{
                Version: []string{`1\.(9|\d{2,})\..*`}, // Requires 1.9+
                GraphDriver: []string{"aufs", "overlay", "devicemapper"},
            },
        },
     }
    ```
    
    Currently, it only supports:
    - Kernel validation: version validation and kernel configuration validation
    - Cgroup validation: validating whether required cgroups subsystems are enabled.
    - Runtime Validation: currently, only validates docker graph driver.
    
    The validating framework is ready. The specific validation items could be added over time.
    
    @dchen1107 
    /cc @kubernetes/sig-node
    9534c4f5
test.sh 12 KB