Fix Github Actions for Ubuntu-24.04 (#11112)

* Fix vagrant/libvirt composite action for ubuntu-24.04

* Don't ignore changes to internal actions

* Fix unit tests for ubuntu 24.04, new lsof version

* Pin os version for unit and E2E workflows

Signed-off-by: Derek Nola <derek.nola@suse.com>
pull/11102/head
Derek Nola 1 month ago committed by GitHub
parent 536fa44eb0
commit 4888376682
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -649,7 +649,7 @@ steps:
UPGRADE_CHANNEL="latest" UPGRADE_CHANNEL="latest"
fi fi
fi fi
E2E_RELEASE_CHANNEL=$UPGRADE_CHANNEL go test -v -timeout=45m ./upgradecluster_test.go -ci -local E2E_RELEASE_CHANNEL=$UPGRADE_CHANNEL go test -v -timeout=45m ./upgradecluster_test.go -ci -local -ginkgo.v
cp ./coverage.out /tmp/artifacts/upgrade-coverage.out cp ./coverage.out /tmp/artifacts/upgrade-coverage.out
fi fi
- docker stop registry && docker rm registry - docker stop registry && docker rm registry

@ -8,17 +8,15 @@ runs:
run: | run: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list
- name: Install vagrant and libvirt - name: Install vagrant and libvirt
shell: bash shell: bash
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libvirt-daemon libvirt-daemon-system vagrant sudo apt-get install -y libvirt-daemon libvirt-daemon-system vagrant ruby-libvirt
sudo systemctl enable --now libvirtd sudo systemctl enable --now libvirtd
- name: Build vagrant dependencies - name: Install vagrant dependencies
shell: bash shell: bash
run: | run: |
sudo apt-get build-dep -y vagrant ruby-libvirt
sudo apt-get install -y --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev sudo apt-get install -y --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev
# This is a workaround for the libvirt group not being available in the current shell # This is a workaround for the libvirt group not being available in the current shell
# https://github.com/actions/runner-images/issues/7670#issuecomment-1900711711 # https://github.com/actions/runner-images/issues/7670#issuecomment-1900711711
@ -26,8 +24,6 @@ runs:
shell: bash shell: bash
run: | run: |
sudo chmod a+rw /var/run/libvirt/libvirt-sock sudo chmod a+rw /var/run/libvirt/libvirt-sock
- name: Install vagrant-libvirt plugin - name: Install vagrant-libvirt plugin
shell: bash shell: bash
run: vagrant plugin install vagrant-libvirt run: vagrant plugin install vagrant-libvirt

@ -9,6 +9,7 @@ on:
- "!tests/e2e**" - "!tests/e2e**"
- "!tests/docker**" - "!tests/docker**"
- ".github/**" - ".github/**"
- "!.github/actions/**"
- "!.github/workflows/e2e.yaml" - "!.github/workflows/e2e.yaml"
pull_request: pull_request:
paths-ignore: paths-ignore:
@ -19,6 +20,7 @@ on:
- "!tests/e2e**" - "!tests/e2e**"
- "!tests/docker**" - "!tests/docker**"
- ".github/**" - ".github/**"
- "!.github/actions/**"
- "!.github/workflows/e2e.yaml" - "!.github/workflows/e2e.yaml"
workflow_dispatch: {} workflow_dispatch: {}
@ -33,7 +35,7 @@ jobs:
e2e: e2e:
name: "E2E Tests" name: "E2E Tests"
needs: build needs: build
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
timeout-minutes: 40 timeout-minutes: 40
strategy: strategy:
fail-fast: false fail-fast: false

@ -28,7 +28,7 @@ permissions:
jobs: jobs:
test: test:
name: Unit Tests name: Unit Tests
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- name: Checkout - name: Checkout

@ -19,9 +19,6 @@ limitations under the License.
package flock package flock
import ( import (
"os/exec"
"strings"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -49,14 +46,3 @@ func AcquireShared(path string) (int, error) {
func Release(lock int) error { func Release(lock int) error {
return unix.Flock(lock, unix.LOCK_UN) return unix.Flock(lock, unix.LOCK_UN)
} }
// CheckLock checks whether any process is using the lock
func CheckLock(path string) bool {
lockByte, _ := exec.Command("lsof", "-w", "-F", "ln", path).Output()
locks := string(lockByte)
if locks == "" {
return false
}
readWriteLock := strings.Split(locks, "\n")[2]
return readWriteLock == "lR" || readWriteLock == "lW"
}

@ -19,9 +19,22 @@ limitations under the License.
package flock package flock
import ( import (
"os/exec"
"strings"
"testing" "testing"
) )
// checkLock checks whether any process is using the lock
func checkLock(path string) bool {
lockByte, _ := exec.Command("lsof", "-w", "-F", "lfn", path).Output()
locks := string(lockByte)
if locks == "" {
return false
}
readWriteLock := strings.Split(locks, "\n")[2]
return readWriteLock == "lR" || readWriteLock == "lW"
}
func Test_UnitFlock(t *testing.T) { func Test_UnitFlock(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
@ -45,7 +58,7 @@ func Test_UnitFlock(t *testing.T) {
return return
} }
if got := CheckLock(tt.path); got != tt.wantCheck { if got := checkLock(tt.path); got != tt.wantCheck {
t.Errorf("CheckLock() = %+v\nWant = %+v", got, tt.wantCheck) t.Errorf("CheckLock() = %+v\nWant = %+v", got, tt.wantCheck)
} }
@ -53,7 +66,7 @@ func Test_UnitFlock(t *testing.T) {
t.Errorf("Release() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("Release() error = %v, wantErr %v", err, tt.wantErr)
} }
if got := CheckLock(tt.path); got == tt.wantCheck { if got := checkLock(tt.path); got == tt.wantCheck {
t.Errorf("CheckLock() = %+v\nWant = %+v", got, !tt.wantCheck) t.Errorf("CheckLock() = %+v\nWant = %+v", got, !tt.wantCheck)
} }
}) })

Loading…
Cancel
Save