Skip to content

Commit

Permalink
[Release-1.30] Backport E2E GHA fixes (k3s-io#11227)
Browse files Browse the repository at this point in the history
* Fix Github Actions for Ubuntu-24.04 (k3s-io#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 <[email protected]>

* Pin vagrant to older version to avoid known issue 13527

Signed-off-by: Derek Nola <[email protected]>

---------

Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola authored Nov 5, 2024
1 parent 1829eaa commit ddea433
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ steps:
UPGRADE_CHANNEL="latest"
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
fi
- docker stop registry && docker rm registry
Expand Down
8 changes: 2 additions & 6 deletions .github/actions/vagrant-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@ runs:
run: |
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
sudo sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list
- name: Install vagrant and libvirt
shell: bash
run: |
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=2.4.1-1 ruby-libvirt
sudo systemctl enable --now libvirtd
- name: Build vagrant dependencies
- name: Install vagrant dependencies
shell: bash
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
# 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
- name: Make the libvirt socket rw accessible to everyone
shell: bash
run: |
sudo chmod a+rw /var/run/libvirt/libvirt-sock

- name: Install vagrant-libvirt plugin
shell: bash
run: vagrant plugin install vagrant-libvirt
4 changes: 3 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- "!tests/e2e**"
- "!tests/docker**"
- ".github/**"
- "!.github/actions/**"
- "!.github/workflows/e2e.yaml"
pull_request:
paths-ignore:
Expand All @@ -19,6 +20,7 @@ on:
- "!tests/e2e**"
- "!tests/docker**"
- ".github/**"
- "!.github/actions/**"
- "!.github/workflows/e2e.yaml"
workflow_dispatch: {}

Expand All @@ -33,7 +35,7 @@ jobs:
e2e:
name: "E2E Tests"
needs: build
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 40
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unitcoverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ permissions:
jobs:
test:
name: Unit Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Checkout
Expand Down
14 changes: 0 additions & 14 deletions pkg/flock/flock_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ limitations under the License.
package flock

import (
"os/exec"
"strings"

"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -49,14 +46,3 @@ func AcquireShared(path string) (int, error) {
func Release(lock int) error {
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"
}
17 changes: 15 additions & 2 deletions pkg/flock/flock_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ limitations under the License.
package flock

import (
"os/exec"
"strings"
"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) {
tests := []struct {
name string
Expand All @@ -45,15 +58,15 @@ func Test_UnitFlock(t *testing.T) {
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)
}

if err := Release(lock); (err != nil) != 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)
}
})
Expand Down

0 comments on commit ddea433

Please sign in to comment.