Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1945597

Summary: Optionally set KERNEL_VERSION and RT_KERNEL_VERSION
Product: OpenShift Container Platform Reporter: Zvonko Kosic <zkosic>
Component: Special Resource OperatorAssignee: Zvonko Kosic <zkosic>
Status: CLOSED ERRATA QA Contact: Walid A. <wabouham>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 4.7CC: aos-bugs
Target Milestone: ---   
Target Release: 4.7.z   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1945599 1945602 (view as bug list) Environment:
Last Closed: 2021-04-20 18:52:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1945599    
Bug Blocks: 1945602    

Description Zvonko Kosic 2021-04-01 11:20:49 UTC
Setting an empty default value for `ARG` entries eliminates the need of the following downstream modifications:
```
    - action: replace
      match: 'ARG KERNEL_VERSION'
      replacement: ''

    - action: replace
      match: 'ARG RT_KERNEL_VERSION'
      replacement: ''

    - action: replace
      match: 'ARG RHEL_VERSION'
      replacement: ''
```
https://github.com/openshift/ocp-build-data/blob/6861686494e12d5cbecde7d67f5ba01f4afe6323/images/driver-toolkit.yml#L10-L20

Using this bash's parameter expansion `${VAR:+-}` appends a `-` only if `$VAR` is not empty, eliminating the following downstream modifications:
```
    - action: replace
      match: '-${KERNEL_VERSION}'
      replacement: ''

    - action: replace
      match: '-${RT_KERNEL_VERSION}'
      replacement: ''
```
https://github.com/openshift/ocp-build-data/blob/6861686494e12d5cbecde7d67f5ba01f4afe6323/images/driver-toolkit.yml#L22-L28

---

This way, ART builds will use basically the same `Dockerfile` as upstream, and we'd use those replacement modifications only when we want to explicitly pin a version:
```
content:
  source:
    modifications:
    - action: replace
      match: "ARG KERNEL_VERSION=''"
      replacement: "ARG KERNEL_VERSION='1.2.3'"

    - action: replace
      match: "ARG RT_KERNEL_VERSION=''"
      replacement: "ARG RT_KERNEL_VERSION='1.2.3'"
```

Comment 3 Walid A. 2021-04-14 18:08:35 UTC
Verified on master branch of https://github.com/openshift-psap/special-resource-operator.git that we were able to use the driver-toolkit container as a base to build the simple-kmod driver-container.
Thanks @David Gray for providing the verification steps.

# oc get all -n simple-kmod
NAME                                                      READY   STATUS      RESTARTS   AGE
pod/simple-kmod-driver-build-bf9b01f15741109d-1-build     0/1     Completed   0          2m51s
pod/simple-kmod-driver-container-bf9b01f15741109d-4qbkv   1/1     Running     0          3m38s
pod/simple-kmod-driver-container-bf9b01f15741109d-4qqc6   1/1     Running     0          3m38s
pod/simple-kmod-driver-container-bf9b01f15741109d-l72s6   1/1     Running     0          3m38s
NAME                                                           DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                                                                                                 AGE
daemonset.apps/simple-kmod-driver-container-bf9b01f15741109d   3         3         3       3            3           feature.node.kubernetes.io/kernel-version.full=4.18.0-240.22.1.el8_3.x86_64,node-role.kubernetes.io/worker=   3m38s
NAME                                                                       TYPE     FROM         LATEST
buildconfig.build.openshift.io/simple-kmod-driver-build-bf9b01f15741109d   Docker   Git@master   1
NAME                                                                   TYPE     FROM          STATUS     STARTED         DURATION
build.build.openshift.io/simple-kmod-driver-build-bf9b01f15741109d-1   Docker   Git@59317a1   Complete   2 minutes ago   1m57s
NAME                                                          IMAGE REPOSITORY                                                                            TAGS                            UPDATED
imagestream.image.openshift.io/driver-toolkit                 image-registry.openshift-image-registry.svc:5000/simple-kmod/driver-toolkit                 v4.7.0-202104131107.p0          5 minutes ago
imagestream.image.openshift.io/simple-kmod-driver-container   image-registry.openshift-image-registry.svc:5000/simple-kmod/simple-kmod-driver-container   v4.18.0-240.22.1.el8_3.x86_64   55 seconds ago

# oc get ds -n simple-kmod
NAME                                            DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                                                                                                 AGE
simple-kmod-driver-container-bf9b01f15741109d   3         3         3       3            3           feature.node.kubernetes.io/kernel-version.full=4.18.0-240.22.1.el8_3.x86_64,node-role.kubernetes.io/worker=   4m3s

# oc get pods -n simple-kmod
NAME                                                  READY   STATUS      RESTARTS   AGE
simple-kmod-driver-build-bf9b01f15741109d-1-build     0/1     Completed   0          3m44s
simple-kmod-driver-container-bf9b01f15741109d-4qbkv   1/1     Running     0          4m31s
simple-kmod-driver-container-bf9b01f15741109d-4qqc6   1/1     Running     0          4m31s
simple-kmod-driver-container-bf9b01f15741109d-l72s6   1/1     Running     0          4m31s


# oc get pods -n simple-kmod -o wide
NAME                                                  READY   STATUS      RESTARTS   AGE     IP             NODE                                         NOMINATED NODE   READINESS GATES
simple-kmod-driver-build-bf9b01f15741109d-1-build     0/1     Completed   0          4m8s    10.128.3.167   ip-10-0-130-0.us-east-2.compute.internal     <none>           <none>
simple-kmod-driver-container-bf9b01f15741109d-4qbkv   1/1     Running     0          4m55s   10.129.2.15    ip-10-0-196-121.us-east-2.compute.internal   <none>           <none>
simple-kmod-driver-container-bf9b01f15741109d-4qqc6   1/1     Running     0          4m55s   10.128.3.166   ip-10-0-130-0.us-east-2.compute.internal     <none>           <none>
simple-kmod-driver-container-bf9b01f15741109d-l72s6   1/1     Running     0          4m55s   10.131.0.139   ip-10-0-179-91.us-east-2.compute.internal    <none>           <none>

# oc debug node/ip-10-0-196-121.us-east-2.compute.internal -- /host/usr/sbin/lsmod | grep simple
Starting pod/ip-10-0-196-121us-east-2computeinternal-debug ...
To use host binaries, run `chroot /host`
simple_procfs_kmod     16384  0
simple_kmod            16384  0
Removing debug pod ...

Comment 5 errata-xmlrpc 2021-04-20 18:52:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.7.7 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1149