Bug 1945602

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.6CC: aos-bugs, wabouham
Target Milestone: ---   
Target Release: 4.6.z   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1945597 Environment:
Last Closed: 2021-04-27 14:20:49 UTC Type: ---
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: 1945597    
Bug Blocks:    

Description Zvonko Kosic 2021-04-01 11:31:13 UTC
+++ This bug was initially created as a clone of Bug #1945597 +++

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-20 18:27:22 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.

# oc debug node/<worker_node>
.
. 
sh-4.4# chroot /host
sh-4.4# 
sh-4.4# lsmod | grep kmod
simple_procfs_kmod     16384  0
simple_kmod            16384  0
sh-4.4# 
sh-4.4# exit
exit
sh-4.4# 
sh-4.4# exit
exit
Removing debug pod ...

# oc get ds -n simple-kmod
NAME                                           DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                                                                                                 AGE
simple-kmod-driver-container-ee060ca2c5056b7   3         3         3       3            3           feature.node.kubernetes.io/kernel-version.full=4.18.0-193.47.1.el8_2.x86_64,node-role.kubernetes.io/worker=   5m4s

# oc get pods -n simple-kmod
NAME                                                 READY   STATUS      RESTARTS   AGE
simple-kmod-driver-build-ee060ca2c5056b7-1-build     0/1     Completed   0          4m37s
simple-kmod-driver-container-ee060ca2c5056b7-6zqfh   1/1     Running     0          5m12s
simple-kmod-driver-container-ee060ca2c5056b7-9vbrw   1/1     Running     0          5m12s
simple-kmod-driver-container-ee060ca2c5056b7-bczlx   1/1     Running     0          5m12s

# oc get pods -n openshift-special-resource-operator
NAME                                                   READY   STATUS    RESTARTS   AGE
special-resource-controller-manager-8587db687f-5d9xg   2/2     Running   0          12m

Comment 5 errata-xmlrpc 2021-04-27 14:20:49 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.6.26 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:1232