Step: openshift-e2e-test-capabilities-check

The Openshift E2E capabilitie check verifies whether NET_RAW is enabled in the restricted scc based on if the capabilities MC exists or not.

Container image used for this step: ocp/cli-jq:latest

ocp/cli-jq:latest resolves to an image imported from the specified imagestream tag on the build farm (documentation).

Environment

In addition to the default environment, the step exposes the following:

Variable Name Type Variable Content
DELETE_MC Parameter[?] Used to determine whether worker capabilites MC need to be deleted. (default: false)

Source Code

 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
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail
set -x

cp -Lrvf ${KUBECONFIG} /tmp/kubeconfig && export KUBECONFIG=/tmp/kubeconfig
oc new-project e2e-test-capabilities-check

version=$(oc version -o json | jq -r '.openshiftVersion')
if [[ "${version}" == *"4.4"* ]]; then
    echo "version is less than 4.5, exiting"
    exit 0
fi

if [[ "${DELETE_MC}" == "true" ]]; then
    oc delete mc 99-worker-generated-crio-capabilities
    # need to wait for the changes to roll out
    # for debug purposes only
    # The status of the mcp worker doesn't immediately change
    # to updating, it takes a few seconds, hence the sleep here.
    sleep 1m
    echo "waiting for the changes to roll out"
    oc wait --for=condition=Updating=false mcp/worker --timeout=600s
    echo "done waiting"
fi

# create a fedora pod and get the capabilities enabled in the pod
oc run fedora-pod --image registry.fedoraproject.org/fedora:34 --restart Never --command -- sleep 1000
oc wait --for=condition=Ready pod/fedora-pod --timeout=300s
capabilities=$(oc rsh fedora-pod capsh --print)

# get the capabilities MCs available
workerMC=$(oc get mc/99-worker-generated-crio-capabilities -o name; true)
masterMC=$(oc get mc/99-master-generated-crio-capabilities -o name; true)
# Since we are only deleting the worker caps MC for the test, the master caps MC should
# exist. If it does, this means we have the capabilities patch so we should go ahead and
# check the capabilities.
if [[ "${workerMC}" == "" ]] && [[ "${masterMC}" != "" ]]; then
    if [[ "${capabilities}" == *"net_raw"* ]]; then
        echo "No worker capabilities MCs were found, but the restricted scc still has NET_RAW enabled"
        exit 1
    fi
elif [[ "${workerMC}" != "" ]]; then
    if [[ "${capabilities}" != *"net_raw"* ]]; then
        echo "Worker capabilities MC was found, but the restricted scc does not have NET_RAW enabled"
        exit 1
    fi
fi

# delete the pod
oc delete pod fedora-pod

Properties

Property Value Description
Resource requests (cpu) 1 Used in .resources.requests of the pod running this step.
Resource requests (memory) 100Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/openshift/e2e/test/capabilities-check/openshift-e2e-test-capabilities-check-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub