Skip to content

Commit bf211d6

Browse files
Merge branch 'main' into sidebar
2 parents 3c371ed + 39fee0b commit bf211d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2935
-1652
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Nightly container build
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: headlamp-k8s/headlamp
14+
15+
jobs:
16+
push_to_registry:
17+
name: Build and push nightly container image
18+
runs-on: ubuntu-latest
19+
permissions:
20+
packages: write
21+
steps:
22+
- name: Check out the repo
23+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
24+
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
30+
31+
- name: Log in to the Container registry
32+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GHCR_IMAGES }}
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # v4.2.1
40+
with:
41+
context: .
42+
push: true
43+
pull: true
44+
platforms: linux/amd64,linux/arm64
45+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
46+
provenance: true
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max

.github/workflows/pr-to-update-chart.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
CURRENT_CHART_VERSION=$(grep '^version:' ./charts/headlamp/Chart.yaml | cut -d' ' -f2)
5050
CURRENT_CHART_VERSION=$(echo $CURRENT_CHART_VERSION | awk -F. -v OFS=. '{$(NF - 1) += 1 ; print}')
5151
# Create branch
52-
BRANCH=update_chart_headlamp_$LATEST_HEADLAMP_TAG
52+
BRANCH=hl-ci-update_chart_headlamp_$LATEST_HEADLAMP_TAG
5353
if git branch -l | grep -q $BRANCH; then
5454
echo "deleting old branch from local to avoid conflict"
5555
git branch -D $BRANCH

.github/workflows/pr-to-update-choco.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ jobs:
100100
echo "Repository: ${{ github.repository }}"
101101
echo "Workspace: ${GITHUB_WORKSPACE}"
102102
pwd
103-
echo echo "https://github.com/kubernetes-sigs/headlamp/pull/new/choco-update-$LATEST_HEADLAMP_TAG"
104-
git checkout -b "choco-update-$LATEST_HEADLAMP_TAG"
103+
echo echo "https://github.com/kubernetes-sigs/headlamp/pull/new/hl-ci-choco-update-$LATEST_HEADLAMP_TAG"
104+
git checkout -b "hl-ci-choco-update-$LATEST_HEADLAMP_TAG"
105105
git add .
106106
git commit -s -m "chocolatey: Bump Headlamp version to $LATEST_HEADLAMP_TAG"
107-
git push origin "choco-update-$LATEST_HEADLAMP_TAG"
107+
git push origin "hl-ci-choco-update-$LATEST_HEADLAMP_TAG"
108108
gh pr create \
109109
--title "chocolatey: Bump Headlamp version to $LATEST_HEADLAMP_TAG" \
110110
--base main \

.github/workflows/pr-to-update-homebrew.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,23 @@ jobs:
5656
run: |
5757
user=${{github.actor}}
5858
HEADLAMP_VERSION=${LATEST_HEADLAMP_TAG:1}
59+
BRANCH_NAME="hl-ci-update_headlamp_$HEADLAMP_VERSION"
5960
if [ -z $user ]; then
6061
user=yolossn
6162
fi
6263
cd homebrew-cask
63-
if git branch -l | grep -q "update_headlamp_$HEADLAMP_VERSION"; then
64+
if git branch -l | grep -q "$BRANCH_NAME"; then
6465
echo "deleting old branch from local to avoid conflict"
65-
git branch -D "update_headlamp_$HEADLAMP_VERSION"
66+
git branch -D "$BRANCH_NAME"
6667
fi
67-
if git branch -a | grep -q "origin/update_headlamp_$HEADLAMP_VERSION"; then
68+
if git branch -a | grep -q "origin/$BRANCH_NAME"; then
6869
echo "deleting old branch from remote to avoid conflict"
69-
git push origin --delete "update_headlamp_$HEADLAMP_VERSION"
70+
git push origin --delete "$BRANCH_NAME"
7071
fi
7172
wget "https://github.com/kubernetes-sigs/headlamp/releases/download/$LATEST_HEADLAMP_TAG/checksums.txt"
7273
ARM_SHA=$(cat checksums.txt | grep .arm64.dmg | awk -F" " '{print $1}')
7374
INTEL_SHA=$(cat checksums.txt | grep .x64.dmg | awk -F" " '{print $1}')
74-
git checkout -b "update_headlamp_$HEADLAMP_VERSION"
75+
git checkout -b "$BRANCH_NAME"
7576
sed -i "s/version\ .*/version \"$HEADLAMP_VERSION\"/g" ./Casks/h/headlamp.rb
7677
if [ $ARM_SHA ]; then
7778
echo "replacing ARM SHA"
@@ -88,11 +89,11 @@ jobs:
8889
git commit --signoff -m "Update Headlamp version to $HEADLAMP_VERSION"
8990
git status
9091
git log -1
91-
git push origin "update_headlamp_$HEADLAMP_VERSION" -f
92+
git push origin "$BRANCH_NAME" -f
9293
gh pr create \
9394
--title "Upgrade Headlamp version to $HEADLAMP_VERSION" \
9495
--repo "Homebrew/homebrew-cask" \
95-
--head "headlamp-k8s:update_headlamp_$HEADLAMP_VERSION" \
96+
--head "headlamp-k8s:$BRANCH_NAME" \
9697
--base "master" \
9798
--assignee "$user" \
9899
--body "Upgrade Headlamp version to $HEADLAMP_VERSION

.github/workflows/pr-to-update-minikube.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ jobs:
5656
user=yolossn
5757
fi
5858
HEADLAMP_VERSION=${LATEST_HEADLAMP_TAG:1}
59+
BRANCH_NAME="hl-ci-update_headlamp_$HEADLAMP_VERSION"
5960
LATEST_HEADLAMP_SHA=$(gh api \
6061
"/orgs/headlamp-k8s/packages/container/headlamp/versions" --jq "map(select(.metadata.container.tags[] | contains(\"$LATEST_HEADLAMP_TAG\"))) | .[].name")
6162
echo $LATEST_HEADLAMP_SHA
6263
cd minikube
63-
if git branch -l | grep -q "update_headlamp_$HEADLAMP_VERSION"; then
64+
if git branch -l | grep -q "$BRANCH_NAME"; then
6465
echo "deleting old branch from local to avoid conflict"
65-
git branch -D "update_headlamp_$HEADLAMP_VERSION"
66+
git branch -D "$BRANCH_NAME"
6667
fi
67-
if git branch -a | grep -q "origin/update_headlamp_$HEADLAMP_VERSION"; then
68+
if git branch -a | grep -q "origin/$BRANCH_NAME"; then
6869
echo "deleting old branch from remote to avoid conflict"
69-
git push origin --delete "update_headlamp_$HEADLAMP_VERSION"
70+
git push origin --delete "$BRANCH_NAME"
7071
fi
71-
git checkout -b "update_headlamp_$HEADLAMP_VERSION"
72+
git checkout -b "$BRANCH_NAME"
7273
OLD_HEADLAMP_VERSION=$(DEP=headlamp make get-dependency-version)
7374
sed -i "s/headlamp-k8s\/headlamp:v.*/headlamp-k8s\/headlamp:$LATEST_HEADLAMP_TAG@$LATEST_HEADLAMP_SHA\",/g" ./pkg/minikube/assets/addons.go
7475
NEW_HEADLAMP_VERSION=$(DEP=headlamp make get-dependency-version)
@@ -78,11 +79,11 @@ jobs:
7879
git commit --signoff -m "Addon headlamp: Update headlamp-k8s/headlamp image from $OLD_HEADLAMP_VERSION to $NEW_HEADLAMP_VERSION"
7980
git status
8081
git log -1
81-
git push origin "update_headlamp_$HEADLAMP_VERSION" -f
82+
git push origin "$BRANCH_NAME" -f
8283
gh pr create \
8384
--title "Addon headlamp: Update headlamp-k8s/headlamp image from $OLD_HEADLAMP_VERSION to $NEW_HEADLAMP_VERSION" \
8485
--repo "kubernetes/minikube" \
85-
--head "headlamp-k8s:update_headlamp_$HEADLAMP_VERSION" \
86+
--head "headlamp-k8s:$BRANCH_NAME" \
8687
--base "master" \
8788
--assignee "$user" \
8889
--body "Upgrade Headlamp version to $HEADLAMP_VERSION

.github/workflows/pr-to-update-winget.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ jobs:
9898
cd $GITHUB_WORKSPACE/winget-pkgs/manifests/h/Headlamp/Headlamp
9999
pwd
100100
ls
101-
git checkout -b "winget-update-$LATEST_HEADLAMP_TAG"
101+
git checkout -b "hl-ci-winget-update-$LATEST_HEADLAMP_TAG"
102102
git add .
103103
git commit -s -m "Update winget package $LATEST_HEADLAMP_TAG"
104-
git push origin "winget-update-$LATEST_HEADLAMP_TAG"
104+
git push origin "hl-ci-winget-update-$LATEST_HEADLAMP_TAG"
105105
env:
106106
GITHUB_TOKEN: ${{ secrets.KINVOLK_REPOS_TOKEN }}
107107

108108
- name: Create Pull Request
109109
run: |
110110
echo "Create pull request"
111111
echo "continue with the following link"
112-
echo "https://github.com/headlamp-k8s/winget-pkgs/pull/new/winget-update-$LATEST_HEADLAMP_TAG"
112+
echo "https://github.com/headlamp-k8s/winget-pkgs/pull/new/hl-ci-winget-update-$LATEST_HEADLAMP_TAG"

app/electron/main.ts

Lines changed: 82 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,9 @@ function startElecron() {
11311131
},
11321132
});
11331133

1134+
// Load the frontend
1135+
mainWindow.loadURL(startUrl);
1136+
11341137
setMenu(mainWindow, currentMenu);
11351138

11361139
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
@@ -1285,77 +1288,88 @@ function startElecron() {
12851288
new PluginManagerEventListeners().setupEventHandlers();
12861289

12871290
if (!useExternalServer) {
1288-
const runningHeadlamp = await getRunningHeadlampPIDs();
1289-
let shouldWaitForKill = true;
1290-
1291-
if (!!runningHeadlamp) {
1292-
const resp = dialog.showMessageBoxSync(mainWindow, {
1293-
// Avoiding mentioning Headlamp here because it may run under a different name depending on branding (plugins).
1294-
title: i18n.t('Another process is running'),
1295-
message: i18n.t(
1296-
'Looks like another process is already running. Continue by terminating that process automatically, or quit?'
1297-
),
1298-
type: 'question',
1299-
buttons: [i18n.t('Continue'), i18n.t('Quit')],
1300-
});
1291+
serverProcess = await startServer();
1292+
attachServerEventHandlers(serverProcess);
13011293

1302-
if (resp === 0) {
1303-
runningHeadlamp.forEach(pid => {
1304-
try {
1305-
killProcess(pid);
1306-
} catch (e) {
1307-
console.log(`Failed to quit headlamp-servere:`, e.message);
1308-
shouldWaitForKill = false;
1294+
serverProcess.addListener('exit', async e => {
1295+
const ERROR_ADDRESS_IN_USE = 98;
1296+
if (e === ERROR_ADDRESS_IN_USE) {
1297+
const runningHeadlamp = await getRunningHeadlampPIDs();
1298+
let shouldWaitForKill = true;
1299+
1300+
if (!mainWindow) {
1301+
return;
1302+
}
1303+
1304+
if (!!runningHeadlamp) {
1305+
const resp = dialog.showMessageBoxSync(mainWindow, {
1306+
// Avoiding mentioning Headlamp here because it may run under a different name depending on branding (plugins).
1307+
title: i18n.t('Another process is running'),
1308+
message: i18n.t(
1309+
'Looks like another process is already running. Continue by terminating that process automatically, or quit?'
1310+
),
1311+
type: 'question',
1312+
buttons: [i18n.t('Continue'), i18n.t('Quit')],
1313+
});
1314+
1315+
if (resp === 0) {
1316+
runningHeadlamp.forEach(pid => {
1317+
try {
1318+
killProcess(pid);
1319+
} catch (e) {
1320+
console.log(`Failed to quit headlamp-servere:`, e.message);
1321+
shouldWaitForKill = false;
1322+
}
1323+
});
1324+
} else {
1325+
mainWindow.close();
1326+
return;
13091327
}
1310-
});
1311-
} else {
1312-
mainWindow.close();
1313-
return;
1314-
}
1315-
}
1316-
1317-
// If we reach here, then we attempted to kill headlamp-server. Let's make sure it's killed
1318-
// before starting our own, or else we may end up in a race condition (failing to start the
1319-
// new one before the existing one is fully killed).
1320-
if (!!runningHeadlamp && shouldWaitForKill) {
1321-
let stillRunning = true;
1322-
let timeWaited = 0;
1323-
const maxWaitTime = 3000; // ms
1324-
// @todo: Use an iterative back-off strategy for the wait (so we can start by waiting for shorter times).
1325-
for (let tries = 1; timeWaited < maxWaitTime && stillRunning; tries++) {
1326-
console.debug(
1327-
`Checking if Headlamp is still running after we asked it to be killed; ${tries} ${timeWaited}/${maxWaitTime}ms wait.`
1328-
);
1329-
1330-
// Wait (10 * powers of 2) ms with a max of 250 ms
1331-
const waitTime = Math.min(10 * tries ** 2, 250); // ms
1332-
await new Promise(f => setTimeout(f, waitTime));
1333-
1334-
timeWaited += waitTime;
1335-
1336-
stillRunning = !!(await getRunningHeadlampPIDs());
1337-
console.debug(stillRunning ? 'Still running...' : 'No longer running!');
1328+
}
1329+
1330+
// If we reach here, then we attempted to kill headlamp-server. Let's make sure it's killed
1331+
// before starting our own, or else we may end up in a race condition (failing to start the
1332+
// new one before the existing one is fully killed).
1333+
if (!!runningHeadlamp && shouldWaitForKill) {
1334+
let stillRunning = true;
1335+
let timeWaited = 0;
1336+
const maxWaitTime = 3000; // ms
1337+
// @todo: Use an iterative back-off strategy for the wait (so we can start by waiting for shorter times).
1338+
for (let tries = 1; timeWaited < maxWaitTime && stillRunning; tries++) {
1339+
console.debug(
1340+
`Checking if Headlamp is still running after we asked it to be killed; ${tries} ${timeWaited}/${maxWaitTime}ms wait.`
1341+
);
1342+
1343+
// Wait (10 * powers of 2) ms with a max of 250 ms
1344+
const waitTime = Math.min(10 * tries ** 2, 250); // ms
1345+
await new Promise(f => setTimeout(f, waitTime));
1346+
1347+
timeWaited += waitTime;
1348+
1349+
stillRunning = !!(await getRunningHeadlampPIDs());
1350+
console.debug(stillRunning ? 'Still running...' : 'No longer running!');
1351+
}
1352+
}
1353+
1354+
// If we couldn't kill the process, warn the user and quit.
1355+
const processes = await getRunningHeadlampPIDs();
1356+
if (!!processes) {
1357+
dialog.showMessageBoxSync({
1358+
type: 'warning',
1359+
title: i18n.t('Failed to quit the other running process'),
1360+
message: i18n.t(
1361+
`Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.`,
1362+
{ process_list: processes }
1363+
),
1364+
});
1365+
1366+
mainWindow.close();
1367+
return;
1368+
}
1369+
serverProcess = await startServer();
1370+
attachServerEventHandlers(serverProcess);
13381371
}
1339-
}
1340-
1341-
// If we couldn't kill the process, warn the user and quit.
1342-
const processes = await getRunningHeadlampPIDs();
1343-
if (!!processes) {
1344-
dialog.showMessageBoxSync({
1345-
type: 'warning',
1346-
title: i18n.t('Failed to quit the other running process'),
1347-
message: i18n.t(
1348-
`Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.`,
1349-
{ process_list: processes }
1350-
),
1351-
});
1352-
1353-
mainWindow.close();
1354-
return;
1355-
}
1356-
1357-
serverProcess = await startServer();
1358-
attachServerEventHandlers(serverProcess);
1372+
});
13591373
}
13601374

13611375
// Also add bundled plugin bin directories to PATH
@@ -1370,9 +1384,6 @@ function startElecron() {
13701384
if (userPluginBinDirs.length > 0) {
13711385
addToPath(userPluginBinDirs, 'userPluginBinDirs plugin');
13721386
}
1373-
1374-
// Finally load the frontend
1375-
mainWindow.loadURL(startUrl);
13761387
}
13771388

13781389
if (disableGPU) {

0 commit comments

Comments
 (0)