Skip to contentSkip to conversation

travis: skip kernel update+reboot if it's not necessary

PATCH In review Ondrej Mosnacek 2 participants 6 messages Oct 30, 2020 – Oct 31, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 travis: skip kernel update+reboot if it's not necessary

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -1
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
Signature · 1 line
2.26.2
#1 lore raw
Quoted 60 lines · Ondrej Mosnacek

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -2
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
--
Quoted 2 lines

2.26.2

Ack

#2 lore raw
Quoted 56 lines · William Roberts
Quoted 55 lines · Ondrej Mosnacek

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -0
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
Quoted 9 lines
Quoted 7 lines
travis-ci/run-testsuite.sh +0 -2
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
--

2.26.2

Ack

Thanks, but I'm not sure if you realized that this is a patch for the testsuite CI, not the userspace one :) Can I still add you ack?

Note that userspace CI doesn't need the kernel update + reboot (nor this patch), as it doesn't test on development images.

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.
#3 lore raw
Quoted 69 lines · Ondrej Mosnacek
Quoted 56 lines · William Roberts
Quoted 55 lines · Ondrej Mosnacek

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -0
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
Quoted 9 lines
Quoted 7 lines
travis-ci/run-testsuite.sh +0 -2
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
--

2.26.2

Ack

Quoted 6 lines

Thanks, but I'm not sure if you realized that this is a patch for the testsuite CI, not the userspace one :) Can I still add you ack?

Note that userspace CI doesn't need the kernel update + reboot (nor this patch), as it doesn't test on development images.

Well aware, thanks. That ack really means reviewed by and tested by lines. I was just being lazy.

I've been following the testsuite project closely as selinux now depends on it in it's CI. I wouldn't be opposed to being a miantiner for the testsuite either.

Thanks for your work on this BTW, glad to see that KVM paradigm getting used more.

Bill

#4 lore raw
Quoted 73 lines · William Roberts
Quoted 72 lines · Ondrej Mosnacek
Quoted 56 lines · William Roberts
Quoted 55 lines · Ondrej Mosnacek

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -0
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
Quoted 9 lines
Quoted 7 lines
travis-ci/run-testsuite.sh +0 -2
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
--

2.26.2

Ack

Thanks, but I'm not sure if you realized that this is a patch for the testsuite CI, not the userspace one :) Can I still add you ack?

Quoted 6 lines
Quoted 3 lines

Note that userspace CI doesn't need the kernel update + reboot (nor this patch), as it doesn't test on development images.

Well aware, thanks. That ack really means reviewed by and tested by lines. I was just being lazy.

Ok, great!

Quoted 2 lines

I've been following the testsuite project closely as selinux now depends on it in it's CI. I wouldn't be opposed to being a miantiner for the testsuite either.

Even greater :) Paul, Stephen, do we want to make Bill another testsuite maintainer? It seems I don't have permission to add people to the GH team, so one of you would have to do it.

Quoted 2 lines

Thanks for your work on this BTW, glad to see that KVM paradigm getting used more.

Yeah, it's cool and it makes maintaining the testsuite so much easier. But you don't need to thank me, you're the one who started it all :)

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.
#5 lore raw
In reply to William Roberts
Quoted 57 lines · William Roberts
Quoted 55 lines · Ondrej Mosnacek

Only do it when we can't install the kernel-modules package for the running kernel to make the CI run faster. Now that rawhide images are updating regularly again, it is rarely necessary.

Also don't run dnf clean all -y before installing dependencies. There really is no point and it just slows things down when we do need to update the kernel.

---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)
travis-ci/run-kvm-test.sh +12 -9
index d22c92b..6afbf96 100755
@@ -121,15 +121,18 @@ fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
travis-ci/run-testsuite.sh +0 -0
index 9b5f954..051f9d8 100755
@@ -16,7 +16,6 @@ pwd
 # the CI.
 setenforce 0
 
Quoted 9 lines
Quoted 7 lines
travis-ci/run-testsuite.sh +0 -2
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \
--

2.26.2

Ack

And I just applied this one as well:
https://github.com/SELinuxProject/selinux-testsuite/commit/69d9e8bd648ace3516d6da7e51a2fd6e012538b1

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.