!43 KubeOS:update to 1.0.2-8

From: @li-yuanrong 
Reviewed-by: @duguhaotian 
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2023-02-07 08:58:58 +00:00 committed by Gitee
commit bf808b73f5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
13 changed files with 1780 additions and 691 deletions

View File

@ -1,264 +0,0 @@
From 0ccbd9d7eba9d600746420d2dd363065f487be17 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Sat, 30 Oct 2021 02:50:37 +0000
Subject: [PATCH] KubeOS:modify checks in generate.sh and change module path
The previous disk space check did not consider the case where
the disk capacity was TB. In addition,if a path containing
/mnt exists,the mount check consider that /mnt has been mounted.
Add the processing when the disk capacity is TB during disk check,
modify mount check and changes module path to openeuler.org/KubeOS.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
VERSION | 2 +-
cmd/agent/main.go | 6 ++--
cmd/agent/server/server.go | 2 +-
cmd/operator/controllers/os_controller.go | 6 ++--
cmd/operator/main.go | 8 +++---
cmd/proxy/controllers/os_controller.go | 14 ++++-----
cmd/proxy/main.go | 12 ++++----
go.mod | 2 +-
hack/releasenote.sh | 35 +++++++++++++++++++++++
pkg/agentclient/connection.go | 2 +-
scripts/generate.sh | 16 ++++++-----
11 files changed, 71 insertions(+), 34 deletions(-)
create mode 100755 hack/releasenote.sh
diff --git a/VERSION b/VERSION
index 3eefcb9..7dea76e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+1.0.1
diff --git a/cmd/agent/main.go b/cmd/agent/main.go
index 8f9485a..aef9e47 100644
--- a/cmd/agent/main.go
+++ b/cmd/agent/main.go
@@ -17,9 +17,9 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
- pb "openeuler.org/saiyan/cmd/agent/api"
- "openeuler.org/saiyan/cmd/agent/server"
- "openeuler.org/saiyan/pkg/version"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
+ "openeuler.org/KubeOS/cmd/agent/server"
+ "openeuler.org/KubeOS/pkg/version"
)
func main() {
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
index ef8630b..711e0c8 100644
--- a/cmd/agent/server/server.go
+++ b/cmd/agent/server/server.go
@@ -29,7 +29,7 @@ import (
"time"
"github.com/sirupsen/logrus"
- pb "openeuler.org/saiyan/cmd/agent/api"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
)
const (
diff --git a/cmd/operator/controllers/os_controller.go b/cmd/operator/controllers/os_controller.go
index 5c572fd..a040ef4 100644
--- a/cmd/operator/controllers/os_controller.go
+++ b/cmd/operator/controllers/os_controller.go
@@ -25,9 +25,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/values"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/values"
)
// OSReconciler reconciles an OS object
diff --git a/cmd/operator/main.go b/cmd/operator/main.go
index c8c0530..17b74e1 100644
--- a/cmd/operator/main.go
+++ b/cmd/operator/main.go
@@ -21,10 +21,10 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/cmd/operator/controllers"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/version"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/cmd/operator/controllers"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/version"
//+kubebuilder:scaffold:imports
)
diff --git a/cmd/proxy/controllers/os_controller.go b/cmd/proxy/controllers/os_controller.go
index 04aed8f..ab9a411 100644
--- a/cmd/proxy/controllers/os_controller.go
+++ b/cmd/proxy/controllers/os_controller.go
@@ -26,10 +26,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/pkg/agentclient"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/values"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/pkg/agentclient"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/values"
)
// OSReconciler reconciles a OS object
@@ -137,9 +137,9 @@ func evictNode(drainer *drain.Helper, node *corev1.Node) error {
}
if err := drain.RunNodeDrain(drainer, node.Name); err != nil {
log.Error(err, "unable to drain node")
- if err := drain.RunCordonOrUncordon(drainer, node, false); err != nil {
- log.Error(err, "unable to uncordon node when an error occurs in draining node")
- return err
+ if terr := drain.RunCordonOrUncordon(drainer, node, false); terr != nil {
+ log.Error(terr, "unable to uncordon node when an error occurs in draining node")
+ return terr
}
return err
}
diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go
index 921bd95..ce1f58d 100644
--- a/cmd/proxy/main.go
+++ b/cmd/proxy/main.go
@@ -22,12 +22,12 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/cmd/agent/server"
- "openeuler.org/saiyan/cmd/proxy/controllers"
- "openeuler.org/saiyan/pkg/agentclient"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/version"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/cmd/agent/server"
+ "openeuler.org/KubeOS/cmd/proxy/controllers"
+ "openeuler.org/KubeOS/pkg/agentclient"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/version"
//+kubebuilder:scaffold:imports
)
diff --git a/go.mod b/go.mod
index cdf8ff6..736e6bd 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module openeuler.org/saiyan
+module openeuler.org/KubeOS
go 1.15
diff --git a/hack/releasenote.sh b/hack/releasenote.sh
new file mode 100755
index 0000000..71049a2
--- /dev/null
+++ b/hack/releasenote.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#######################################################################
+##- @Copyright (C) Huawei Technologies., Ltd. 2021. All rights reserved.
+# - KubeOS licensed under the Mulan PSL v2.
+# - You can use this software according to the terms and conditions of the Mulan PSL v2.
+# - You may obtain a copy of Mulan PSL v2 at:
+# - http://license.coscl.org.cn/MulanPSL2
+# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+# - PURPOSE.
+# - See the Mulan PSL v2 for more details.
+#######################################################################
+
+#!/bin/bash
+
+function get_release_notes()
+{
+ LAST_RELEASE=$(git describe --tags --abbrev=0)
+ # Prepare proposed delease notes
+ echo "$(date "+%Y-%m-%d") $USER release $1"
+ git log --first-parent --oneline $LAST_RELEASE.. | cut -d' ' -f 2- | sed 's/^/ - /'
+ echo ""
+ echo " dev stats:"
+ echo " -$(git diff --shortstat $LAST_RELEASE)"
+ echo -n " - contributors: "
+ git shortlog -ns --no-merges $LAST_RELEASE..HEAD | cut -d$'\t' -f 2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/, /g'
+ echo ""
+}
+
+if [ $# -ne 1 ];then
+ echo "Usage:"
+ echo "./hack/releasenote.sh v1.0.0"
+ exit 0
+fi
+get_release_notes $1
diff --git a/pkg/agentclient/connection.go b/pkg/agentclient/connection.go
index 1f28ee4..7d16019 100644
--- a/pkg/agentclient/connection.go
+++ b/pkg/agentclient/connection.go
@@ -21,7 +21,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
- pb "openeuler.org/saiyan/cmd/agent/api"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
)
// Client defines the client stub for OS service
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 7a57b05..1374894 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -145,7 +145,7 @@ function check_path() {
exit 5
fi
- if mount 2>/dev/null | grep -q "${ISO_PATH}"; then
+ if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
echo "$ISO_PATH has already been mounted."
exit 4
fi
@@ -153,11 +153,13 @@ function check_path() {
function check_disk_space() {
local disk_ava="$(df ${PWD} -h | awk 'NR==2{print}' | awk '{print $4}')"
- if echo "${disk_ava}" | grep -q G$; then
- disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
- if [ "${disk_ava}" -lt 25 ]; then
- echo "The available disk space is not enough, at least 25GB."
- exit 6
+ if echo "${disk_ava}" | grep -q [GT]$; then
+ if echo "${disk_ava}" | grep -q G$; then
+ disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
+ if [ "${disk_ava}" -lt 25 ]; then
+ echo "The available disk space is not enough, at least 25GB."
+ exit 6
+ fi
fi
else
echo "The available disk space is not enough, at least 25G."
@@ -293,7 +295,7 @@ fi
set +eE
for i in $1 $2 $3
do
- echo "$i" | grep -v -E ${CHECK_REGEX}
+ echo "$i" | grep -v -E -q ${CHECK_REGEX}
filterParam=$(echo "$i" | grep -v -E ${CHECK_REGEX})
if [[ "${filterParam}" != "$i" ]]; then
echo "error: params $i is invalid, please check it."
--
2.30.0

View File

@ -0,0 +1,479 @@
From 236b8ddeb3bc7f35eb817769f117ecd68a59335c Mon Sep 17 00:00:00 2001
From: stedylan <836671668@qq.com>
Date: Sun, 7 Aug 2022 01:47:14 +0800
Subject: [PATCH] Write a tool to support KubeOS deployment on physical
machines.
This tool uses dracut module to make partitions and formatting, set network infomation, get rootfs and set boot options in initramfs before switch to the real root.
Signed-off-by: stedylan <836671668@qq.com>
---
scripts/00bootup/Global.cfg | 12 ++
scripts/00bootup/module-setup.sh | 28 +++
scripts/00bootup/mount.sh | 332 +++++++++++++++++++++++++++++++
scripts/create/imageCreate.sh | 4 +-
scripts/create/rootfsCreate.sh | 1 +
scripts/rpmlist | 10 +-
scripts/set_in_chroot.sh | 3 +
7 files changed, 387 insertions(+), 3 deletions(-)
create mode 100644 scripts/00bootup/Global.cfg
create mode 100644 scripts/00bootup/module-setup.sh
create mode 100644 scripts/00bootup/mount.sh
diff --git a/scripts/00bootup/Global.cfg b/scripts/00bootup/Global.cfg
new file mode 100644
index 0000000..cad4e33
--- /dev/null
+++ b/scripts/00bootup/Global.cfg
@@ -0,0 +1,12 @@
+# rootfs file name
+rootfs_name=kubeos.tar
+
+# select the target disk to install kubeOS
+disk=/dev/sda
+
+# address where stores the rootfs on the http server
+server_ip=192.168.1.50
+
+local_ip=192.168.1.100
+
+route_ip=192.168.1.1
\ No newline at end of file
diff --git a/scripts/00bootup/module-setup.sh b/scripts/00bootup/module-setup.sh
new file mode 100644
index 0000000..5460b2b
--- /dev/null
+++ b/scripts/00bootup/module-setup.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+check() {
+ return 0
+}
+
+depends() {
+ echo systemd
+}
+
+install() {
+ inst_multiple -o grub2-mkimage mkfs.ext4 mkfs.vfat lsblk tar cpio gunzip lspci parted dhclient ifconfig curl hwinfo head tee arch df awk route
+ inst_hook mount 00 "$moddir/mount.sh"
+ inst_simple "$moddir/mount.sh" "/mount.sh"
+ inst_simple "$moddir/Global.cfg" "/Global.cfg"
+}
+
+installkernel() {
+ hostonly='' \
+ instmods \
+ =drivers/ata \
+ =drivers/nvme \
+ =drivers/scsi \
+ =drivers/net \
+ =fs/fat \
+ =fs/nls
+}
+
diff --git a/scripts/00bootup/mount.sh b/scripts/00bootup/mount.sh
new file mode 100644
index 0000000..a04a364
--- /dev/null
+++ b/scripts/00bootup/mount.sh
@@ -0,0 +1,332 @@
+#!/bin/bash
+arch=$(arch)
+min_size=8
+log=/install.log
+
+source /Global.cfg
+
+function CheckSpace() {
+ local disk_ava="$(parted -l | grep ${disk} | awk '{print $3}')"
+ if echo "${disk_ava}" | grep [GT]B$; then
+ if echo "${disk_ava}" | grep GB$; then
+ disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
+ if [ "${disk_ava}" -lt ${min_size} ]; then
+ echo "The available disk space is not enough, at least ${min_size}GB." | tee -a ${log}
+ return 1
+ fi
+ fi
+ else
+ echo "The available disk space is not enough, at least ${min_size}G." | tee -a ${log}
+ return 1
+ fi
+
+ return 0
+}
+
+function GetDisk() {
+ disks=$(hwinfo --disk --short | grep -vi "^disk" | awk '{print $1}')
+ if [ ! -z ${disks} ]; then
+ if [ ! -z ${disk} ] && echo "${disks[@]}" | grep -wq "${disk}" ; then
+ echo "${disk} exists, start partition" | tee -a ${log}
+ else
+ echo "disk not exist, choose default disk" | tee -a ${log}
+ disk=$(echo ${disks[0]})
+ fi
+ else
+ echo "no disk found" | tee -a ${log}
+ return 1
+ fi
+
+
+ CheckSpace
+ if [ $? -ne 0 ]; then
+ echo "no enough space on ${disk}" | tee -a ${log}
+ return 1
+ fi
+
+ return 0
+}
+
+function PartitionAndFormatting() {
+ echo "Partitioning and formatting disk $disk..."
+ # partition and format
+ parted ${disk} -s mklabel gpt >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ parted ${disk} -s mkpart primary fat16 1M 100M >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ parted ${disk} -s mkpart primary ext4 100M 2600M >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ parted ${disk} -s mkpart primary ext4 2600M 5100M >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ parted ${disk} -s mkpart primary ext4 5100M 100% >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ parted ${disk} -s set 1 boot on >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "partition failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkfs.vfat -n "BOOT" ${disk}1 >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "format failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkfs.ext4 -L "ROOT-A" ${disk}2 >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "format failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkfs.ext4 -L "ROOT-B" ${disk}3 >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "format failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkfs.ext4 -L "PERSIST" ${disk}4 >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "format failed" | tee -a ${log}
+ return 1
+ fi
+
+ return 0
+}
+
+function InitNetwork() {
+ echo "Initializing network..."
+ # 获取网卡信息,默认只有一个网卡
+ net_name=`ifconfig -a | awk '{print $1}' | grep : | grep '^e' | awk -F: '{print $1}'`
+ # dhclient --timeout 60 >> ${log} 2>&1
+
+ ifconfig ${net_name} up
+ if [ $? -ne 0 ]; then
+ echo "load net card failed" | tee -a ${log}
+ return 1
+ fi
+ sleep 3
+
+ ifconfig ${net_name} ${local_ip} netmask 255.255.255.0 >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "ip set failed" | tee -a ${log}
+ return 1
+ fi
+ sleep 3
+
+ route add default gw ${route_ip} >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "add route failed" | tee -a ${log}
+ return 1
+ fi
+ sleep 3
+
+
+
+ return 0
+}
+
+function MountRoot() {
+ echo "Mounting rootfs..."
+ # mount rootfs
+ mount ${disk}2 /sysroot >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "mount rootfs failed" | tee -a ${log}
+ return 1
+ fi
+
+ return 0
+}
+
+function MountPersist() {
+ echo "Mounting persist"
+ mkdir /persist
+ mount ${disk}4 /persist >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "mount persist failed" | tee -a ${log}
+ return 1
+ fi
+ mkdir /persist/{var,etc,etcwork}
+ mkdir -p /persist/etc/KubeOS/certs
+ return 0
+}
+
+function MountBoot() {
+ echo "Mounting boot"
+ mkdir -p /sysroot/boot/efi
+ mount ${disk}1 /sysroot/boot/efi >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "mount boot failed" | tee -a ${log}
+ return 1
+ fi
+ return 0
+}
+
+function GetRootfs() {
+ echo "Downloading rootfs..."
+
+ curl -o /persist/${rootfs_name} http://${server_ip}/${rootfs_name}
+ if [ ! -e "/persist/${rootfs_name}" ]; then
+ echo "download rootfs failed" | tee -a ${log}
+ return 1
+ fi
+
+ tar -xvf /persist/${rootfs_name} -C /sysroot
+ if [ $? -ne 0 ]; then
+ echo "decompose rootfs failed" | tee -a ${log}
+ return 1
+ fi
+
+ rm -rf /persist/${rootfs_name}
+
+ return 0
+}
+
+function Inst_Grub2_x86() {
+ # copy the files that boot need
+ cp -r /sysroot/usr/lib/grub/x86_64-efi /sysroot/boot/efi/EFI/openEuler
+ eval "grub2-mkimage -d /sysroot/usr/lib/grub/x86_64-efi -O x86_64-efi --output=/sysroot/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux" >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "grub2-mkimage on x86 failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkdir -p /sysroot/boot/efi/EFI/BOOT/
+ cp -f /sysroot/boot/efi/EFI/openEuler/grubx64.efi /sysroot/boot/efi/EFI/BOOT/BOOTX64.EFI
+
+ return 0
+}
+
+function Inst_Grub2_aarch64() {
+ cp -r /sysroot/usr/lib/grub/arm64-efi /sysroot/boot/efi/EFI/openEuler/
+ eval "grub2-mkimage -d /sysroot/usr/lib/grub/arm64-efi -O arm64-efi --output=/sysroot/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux" >> ${log} 2>&1
+ if [ $? -ne 0 ]; then
+ echo "grub2-mkimage on aarch64 failed" | tee -a ${log}
+ return 1
+ fi
+
+ mkdir -p /sysroot/boot/efi/EFI/BOOT/
+ cp -f /sysroot/boot/efi/EFI/openEuler/grubaa64.efi /sysroot/boot/efi/EFI/BOOT/BOOTAA64.EFI
+
+ return 0
+}
+
+function SetBoot() {
+ # mount boot
+ echo "Setting boot"
+
+ if [ $arch == "x86_64" ]; then
+ Inst_Grub2_x86
+ if [ $? -ne 0 ]; then
+ echo "install grub on x86 failed" | tee -a ${log}
+ return 1
+ fi
+ fi
+
+ if [ $arch == "aarch64" ]; then
+ Inst_Grub2_aarch64
+ if [ $? -ne 0 ]; then
+ echo "install grub on aarch64 failed" | tee -a ${log}
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+function Bootup_Main() {
+ # get disk
+ echo "Checking disk info..." | tee -a ${log}
+ GetDisk
+ if [ $? -ne 0 ]; then
+ echo "Checking disk info failed" | tee -a ${log}
+ return 1
+ fi
+
+ # partition and format disk
+ echo "Partion and formatting..." | tee -a ${log}
+ PartitionAndFormatting
+ if [ $? -ne 0 ]; then
+ echo "Partition and formatting disk failed" | tee -a ${log}
+ return 1
+ fi
+
+ # init network
+ echo "Initializing network..." | tee -a ${log}
+ InitNetwork
+ if [ $? -ne 0 ]; then
+ echo "Initializing network failed" | tee -a ${log}
+ return 1
+ fi
+
+ # mount partitions
+ echo "Mounting root..." | tee -a ${log}
+ MountRoot
+ if [ $? -ne 0 ]; then
+ echo "Mounting root failed" | tee -a ${log}
+ return 1
+ fi
+
+ # mount persist
+ echo "Mounting persisst..." | tee -a ${log}
+ MountPersist
+ if [ $? -ne 0 ]; then
+ echo "Mounting persist failed" | tee -a ${log}
+ return 1
+ fi
+
+ # mount boot
+ echo "Mounting boot..." | tee -a ${log}
+ MountBoot
+ if [ $? -ne 0 ]; then
+ echo "Mounting boot failed" | tee -a ${log}
+ return 1
+ fi
+
+ # download rootfs
+ echo "Downloading rootfs..." | tee -a ${log}
+ GetRootfs
+ if [ $? -ne 0 ]; then
+ echo "Downloading rootfs failed" | tee -a ${log}
+ return 1
+ fi
+
+ # set boot
+ echo "Setting boot..." | tee -a ${log}
+ SetBoot
+ if [ $? -ne 0 ]; then
+ echo "Setting boot failed" | tee -a ${log}
+ return 1
+ fi
+
+ return 0
+}
+
+Bootup_Main
+ret=$?
+if [ ${ret} -eq 0 ]; then
+ echo "kubeOS install success! switch to root" | tee -a ${log}
+ cp ${log} /persist
+else
+ echo "kubeOS install failed, see install.log" | tee -a ${log}
+fi
+
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
index f8dafbe..95ebcde 100644
--- a/scripts/create/imageCreate.sh
+++ b/scripts/create/imageCreate.sh
@@ -62,12 +62,12 @@ function create_pxe_img() {
case $opt in
"repo")
create_os_tar_from_repo "$@"
- tar -xvf os.tar ./boot/initramfs.img
+ tar -xvf os.tar ./initramfs.img
tar -xvf os.tar ./boot/vmlinuz
;;
"docker")
create_os_tar_from_docker "$@"
- tar -xvf os.tar boot/initramfs.img
+ tar -xvf os.tar initramfs.img
tar -xvf os.tar boot/vmlinuz
;;
esac
diff --git a/scripts/create/rootfsCreate.sh b/scripts/create/rootfsCreate.sh
index 8049f09..e5c53d5 100644
--- a/scripts/create/rootfsCreate.sh
+++ b/scripts/create/rootfsCreate.sh
@@ -61,6 +61,7 @@ EOF
mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
cp grub.cfg "${RPM_ROOT}"/boot/grub2
cp grub.cfg "${RPM_ROOT}"/boot/efi/EFI/openEuler
+ cp -r ./00bootup ${RPM_ROOT}/usr/lib/dracut/modules.d/
cp set_in_chroot.sh "${RPM_ROOT}"
ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
rm "${RPM_ROOT}/set_in_chroot.sh"
diff --git a/scripts/rpmlist b/scripts/rpmlist
index 7a9adfa..077a164 100644
--- a/scripts/rpmlist
+++ b/scripts/rpmlist
@@ -13,4 +13,12 @@ socat
conntrack-tools
ebtables
ethtool
-rsyslog
\ No newline at end of file
+rsyslog
+vi
+net-tools
+hwinfo
+dracut
+coreutils
+gawk
+parted
+dosfstools
\ No newline at end of file
diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh
index bacef78..4b061df 100644
--- a/scripts/set_in_chroot.sh
+++ b/scripts/set_in_chroot.sh
@@ -11,3 +11,6 @@ sed -i '/^root:/d' /etc/shadow_bak
echo "root:"${ROOT_PWD}${str:1} > /etc/shadow
cat /etc/shadow_bak >> /etc/shadow
rm -rf /etc/shadow_bak
+
+dracut -f -v --add bootup /initramfs.img --kver `ls /lib/modules`
+rm -rf /usr/lib/dracut/modules.d/00bootup
\ No newline at end of file
--
2.33.0.windows.2

View File

@ -0,0 +1,341 @@
From f64c9587a20cc44036b0f622105501ff142729d7 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Tue, 23 Aug 2022 15:32:36 +0800
Subject: [PATCH] KubeOS:fix the kbimg.sh exception and pxe installation
problem.
Fixed the issue of abnormal usage printing of the kbimg.sh parameter,
no verification of the -b parameter, and environment clearance in
the concurrent scenario.
Fix the problem that disks and network adapters cannot be found
due to disk and network adapter verification during PXE installation.
Fix the problem that os-proxy does not transfer imagetype and dockerimage
to the os-agent.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
cmd/proxy/controllers/os_controller.go | 16 ++++++------
scripts/00bootup/Global.cfg | 12 ++++++---
scripts/00bootup/mount.sh | 35 ++++++++++++++------------
scripts/common/utils.sh | 7 ++++++
scripts/create/imageCreate.sh | 4 +--
scripts/kbimg.sh | 30 +++++++++++++---------
6 files changed, 62 insertions(+), 42 deletions(-)
diff --git a/cmd/proxy/controllers/os_controller.go b/cmd/proxy/controllers/os_controller.go
index f73c750..09e58f9 100644
--- a/cmd/proxy/controllers/os_controller.go
+++ b/cmd/proxy/controllers/os_controller.go
@@ -106,13 +106,15 @@ func (r *OSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
case "upgrade":
version := osVersionSpec
downloadInfo := &agentclient.DownloadInfo{
- ImageURL: osInstance.Spec.ImageURL,
- FlagSafe: osInstance.Spec.FlagSafe,
- CheckSum: osInstance.Spec.CheckSum,
- CaCert: osInstance.Spec.CaCert,
- ClientCert: osInstance.Spec.ClientCert,
- ClientKey: osInstance.Spec.ClientKey,
- MTLS: osInstance.Spec.MTLS,
+ ImageURL: osInstance.Spec.ImageURL,
+ FlagSafe: osInstance.Spec.FlagSafe,
+ CheckSum: osInstance.Spec.CheckSum,
+ CaCert: osInstance.Spec.CaCert,
+ ClientCert: osInstance.Spec.ClientCert,
+ ClientKey: osInstance.Spec.ClientKey,
+ MTLS: osInstance.Spec.MTLS,
+ ImageType: osInstance.Spec.ImageType,
+ DockerImage: osInstance.Spec.DockerImage,
}
if err := r.Connection.UpdateSpec(version, downloadInfo); err != nil {
return values.RequeueNow, err
diff --git a/scripts/00bootup/Global.cfg b/scripts/00bootup/Global.cfg
index cad4e33..dd78617 100644
--- a/scripts/00bootup/Global.cfg
+++ b/scripts/00bootup/Global.cfg
@@ -4,9 +4,13 @@ rootfs_name=kubeos.tar
# select the target disk to install kubeOS
disk=/dev/sda
-# address where stores the rootfs on the http server
+# pxe server ip address where stores the rootfs on the http server
server_ip=192.168.1.50
-
+# target machine ip
local_ip=192.168.1.100
-
-route_ip=192.168.1.1
\ No newline at end of file
+# target machine route
+route_ip=192.168.1.1
+# target machine netmask
+netmask=255.255.255.0
+# target machine netDevice name
+net_name=eth0
diff --git a/scripts/00bootup/mount.sh b/scripts/00bootup/mount.sh
index a04a364..1bc83ff 100644
--- a/scripts/00bootup/mount.sh
+++ b/scripts/00bootup/mount.sh
@@ -24,20 +24,17 @@ function CheckSpace() {
}
function GetDisk() {
- disks=$(hwinfo --disk --short | grep -vi "^disk" | awk '{print $1}')
- if [ ! -z ${disks} ]; then
- if [ ! -z ${disk} ] && echo "${disks[@]}" | grep -wq "${disk}" ; then
+ disks=(`hwinfo --disk --short 2>&1 | grep -vi "^disk" | awk '{print $1}'`)
+ if [ ${#disks[*]} -gt 0 ]; then
+ if [ -n "${disk}" ] && echo "${disks[@]}" | grep -wq "${disk}" ; then
echo "${disk} exists, start partition" | tee -a ${log}
else
- echo "disk not exist, choose default disk" | tee -a ${log}
- disk=$(echo ${disks[0]})
+ echo "disk not exist, please choose correct disk" | tee -a ${log}
fi
else
echo "no disk found" | tee -a ${log}
return 1
fi
-
-
CheckSpace
if [ $? -ne 0 ]; then
echo "no enough space on ${disk}" | tee -a ${log}
@@ -115,9 +112,18 @@ function PartitionAndFormatting() {
function InitNetwork() {
echo "Initializing network..."
- # 获取网卡信息,默认只有一个网卡
- net_name=`ifconfig -a | awk '{print $1}' | grep : | grep '^e' | awk -F: '{print $1}'`
- # dhclient --timeout 60 >> ${log} 2>&1
+ netNames=(`ifconfig -a | awk '{print $1}' | grep : | grep '^e' | awk -F: '{print $1}'`)
+ if [ ${#netNames[*]} -gt 0 ]; then
+ if [ -n "${net_name}" ] && echo "${netNames[@]}" | grep -wq "${net_name}" ; then
+ echo "${net_name} exists, start set ip" | tee -a ${log}
+ else
+ echo "net_name not exist, choose default net" | tee -a ${log}
+ net_name=${netNames[0]}
+ fi
+ else
+ echo "no net Device found" | tee -a ${log}
+ return 1
+ fi
ifconfig ${net_name} up
if [ $? -ne 0 ]; then
@@ -126,7 +132,7 @@ function InitNetwork() {
fi
sleep 3
- ifconfig ${net_name} ${local_ip} netmask 255.255.255.0 >> ${log} 2>&1
+ ifconfig ${net_name} ${local_ip} netmask ${netmask} >> ${log} 2>&1
if [ $? -ne 0 ]; then
echo "ip set failed" | tee -a ${log}
return 1
@@ -139,9 +145,6 @@ function InitNetwork() {
return 1
fi
sleep 3
-
-
-
return 0
}
@@ -249,6 +252,7 @@ function SetBoot() {
return 1
fi
fi
+ sed -i 's#/dev/sda#'${disk}'#g' /sysroot/boot/efi/EFI/openEuler/grub.cfg
return 0
}
@@ -328,5 +332,4 @@ if [ ${ret} -eq 0 ]; then
cp ${log} /persist
else
echo "kubeOS install failed, see install.log" | tee -a ${log}
-fi
-
+fi
\ No newline at end of file
diff --git a/scripts/common/utils.sh b/scripts/common/utils.sh
index 902a6ae..3546c8c 100644
--- a/scripts/common/utils.sh
+++ b/scripts/common/utils.sh
@@ -87,6 +87,13 @@ function delete_file() {
return 0
}
+function check_binary_exist() {
+ if [ ! -f "$1" ];then
+ log_error_print "binary path is invalid."
+ exit 3
+ fi
+}
+
function check_repo_path() {
if [ ! -f "$1" ];then
log_error_print "REPO path is invalid."
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
index 95ebcde..564c740 100644
--- a/scripts/create/imageCreate.sh
+++ b/scripts/create/imageCreate.sh
@@ -56,19 +56,17 @@ function create_img() {
}
function create_pxe_img() {
- rm -rf boot/ kubeos.tar
+ rm -rf initramfs.img kubeos.tar
local opt=$1
shift
case $opt in
"repo")
create_os_tar_from_repo "$@"
tar -xvf os.tar ./initramfs.img
- tar -xvf os.tar ./boot/vmlinuz
;;
"docker")
create_os_tar_from_docker "$@"
tar -xvf os.tar initramfs.img
- tar -xvf os.tar boot/vmlinuz
;;
esac
mv os.tar kubeos.tar
diff --git a/scripts/kbimg.sh b/scripts/kbimg.sh
index 1268700..a77d62e 100644
--- a/scripts/kbimg.sh
+++ b/scripts/kbimg.sh
@@ -72,12 +72,12 @@ options:
EOF
}
-function show_vm_image_usage() {
+function show_vm_pxe_image_usage() {
cat << EOF
-Usage : kbimg create vm-image -p iso-path -v os-version -b os-agent-dir -e os-password
+Usage : kbimg create [vm-image|pxe-image] -p iso-path -v os-version -b os-agent-dir -e os-password
or
- kbimg create vm-image -d repository/name:tag
+ kbimg create [vm-image|pxe-image] -d repository/name:tag
options:
-p repo path
@@ -130,7 +130,7 @@ function clean_space() {
function clean_img() {
delete_file system.img
delete_file update.img
- delete_dir boot
+ delete_file initramfs.img
delete_file kubeos.tar
}
@@ -170,6 +170,7 @@ function verify_upgrade_image_input() {
;;
*)
log_error_print "option $opt not found"
+ show_upgrade_image_usage
exit 3
;;
esac
@@ -183,6 +184,7 @@ function verify_repo_input() {
echo "$@" | grep -q "\-$i "
if [ "$?" -ne 0 ];then
log_error_print "option -$i is mandatory, please check input"
+ show_vm_pxe_image_usage
exit 3
fi
done
@@ -208,6 +210,7 @@ function verify_repo_input() {
;;
*)
log_error_print "option $opt not found"
+ show_vm_pxe_image_usage
exit 3
;;
esac
@@ -215,7 +218,8 @@ function verify_repo_input() {
}
function verify_docker_input() {
if [ $1 != "-d" ]; then
- log_error_print "option $opt not found"
+ log_error_print "option $1 not found"
+ show_vm_pxe_image_usage
exit 3
fi
check_param $2
@@ -242,13 +246,14 @@ function verify_create_input() {
check_disk_space "docker"
verify_upgrade_image_input "$@"
check_repo_path "${REPO}"
+ check_binary_exist "${AGENT_PATH}"
create_docker_image "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}" "${DOCKER_IMG}"
;;
"vm-image")
shift
if [ $# -eq 1 ]; then
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_vm_image_usage
+ show_vm_pxe_image_usage
exit 0
fi
fi
@@ -256,6 +261,7 @@ function verify_create_input() {
if [ $# -eq 8 ]; then
verify_repo_input "$@"
check_repo_path "${REPO}"
+ check_binary_exist "${AGENT_PATH}"
create_vm_img "repo" "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}"
elif [ $# -eq 2 ]; then
verify_docker_input "$@"
@@ -263,7 +269,7 @@ function verify_create_input() {
create_vm_img "docker" "${DOCKER_IMG}"
else
log_error_print "the number of parameters is incorrect, please check it."
- show_vm_image_usage
+ show_vm_pxe_image_usage
exit 3
fi
;;
@@ -271,7 +277,7 @@ function verify_create_input() {
shift
if [ $# -eq 1 ]; then
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_pxe_image_usage
+ show_vm_pxe_image_usage
exit 0
fi
fi
@@ -279,6 +285,7 @@ function verify_create_input() {
if [ $# -eq 8 ]; then
verify_repo_input "$@"
check_repo_path "${REPO}"
+ check_binary_exist "${AGENT_PATH}"
create_pxe_img "repo" "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}"
elif [ $# -eq 2 ]; then
verify_docker_input "$@"
@@ -286,7 +293,7 @@ function verify_create_input() {
create_pxe_img "docker" "${DOCKER_IMG}"
else
log_error_print "the number of parameters is incorrect, please check it."
- show_pxe_image_usage
+ show_vm_pxe_image_usage
exit 3
fi
;;
@@ -327,9 +334,8 @@ function kubeos_image_main() {
esac
}
+test_lock
trap clean_space EXIT
trap clean_img ERR
-test_lock
-kubeos_image_main "$@"
-
+kubeos_image_main "$@"
\ No newline at end of file
--
2.33.0.windows.2

View File

@ -1,119 +0,0 @@
From c652bb6f46ce2e434bd098552abebbba8909a9c0 Mon Sep 17 00:00:00 2001
From: linxiaoxu <linxiaoxu@huawei.com>
Date: Wed, 8 Dec 2021 02:01:18 +0000
Subject: [PATCH] change generate argument from isopath to repopath
---
docs/quick-start.md | 4 ++--
scripts/generate.sh | 30 ++++++------------------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/docs/quick-start.md b/docs/quick-start.md
index 098c839..ceb81e5 100644
--- a/docs/quick-start.md
+++ b/docs/quick-start.md
@@ -56,10 +56,10 @@
进入scripts目录执行脚本
```
cd scripts
- bash generate.sh ISO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
+ bash generate.sh REPO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
```
- 参数说明:
- - ISO_PATH 全量iso的路径
+ - REPO_PATH 全量repo的路径
- VERSION 制作的容器OS镜像的版本
- AGENT_PATH构建出来的os-agent的路径
- ENCRYPTED_PASSWD镜像的root用户密码加密后的带盐值的密码。可以用openssl、kiwi等命令生成
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 1374894..d5111f1 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -12,8 +12,7 @@
set -e
NAME=KubeOS
-ISO_PATH="/mnt"
-ISO=""
+REPO=""
VERSION=""
AGENT_PATH=""
PASSWD=""
@@ -27,7 +26,7 @@ CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
function show_options() {
cat << EOF
-usage example: sh generate.sh isopath osversion agentpath passwd(encrypted)
+usage example: sh generate.sh repopath osversion agentpath passwd(encrypted)
options:
-h,--help show help information
@@ -114,7 +113,6 @@ function delete_file() {
function clean_space() {
delete_dir "${RPM_ROOT}"
delete_dir "${TMP_MOUNT_PATH}"
- unmount_dir "${ISO_PATH}"
delete_file os.tar
rm -rf "${LOCK}"
}
@@ -135,8 +133,8 @@ function test_lock() {
}
function check_path() {
- if [ ! -f "${ISO}" ];then
- echo "ISO path is invalid."
+ if [ ! -f "${REPO}" ];then
+ echo "REPO path is invalid."
exit 3
fi
@@ -144,11 +142,6 @@ function check_path() {
echo "there is a rootfs folder. please confirm if rootfs is being used, if not, please remove ${RPM_ROOT} first."
exit 5
fi
-
- if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
- echo "$ISO_PATH has already been mounted."
- exit 4
- fi
}
function check_disk_space() {
@@ -168,24 +161,13 @@ function check_disk_space() {
}
function prepare_yum() {
- mount "${ISO}" "${ISO_PATH}"
- if [ ! -d "/mnt/Packages" ]; then
- echo "please use ISO file path as ${ISO}."
- exit 2
- fi
-
# init rpmdb
rpm --root "${RPM_ROOT}" --initdb
mkdir -p "${RPM_ROOT}"{/etc/yum.repos.d,/persist,/proc,/dev/pts,/sys}
mount_proc_dev_sys "${RPM_ROOT}"
# init yum repo
local iso_repo="${RPM_ROOT}/etc/yum.repos.d/iso.repo"
- echo "[base]" >"${iso_repo}"
- {
- echo "name=ISO base"
- echo "baseurl=file://${ISO_PATH}"
- echo "enabled=1"
- } >>"${iso_repo}"
+ cat ${REPO} > ${RPM_ROOT}/etc/yum.repos.d/iso.repo
}
function install_packages() {
@@ -304,7 +286,7 @@ do
done
set -eE
-ISO=$1
+REPO=$1
VERSION=$2
AGENT_PATH=$3
PASSWD=$4
--
2.30.0

View File

@ -1,298 +0,0 @@
From a19218ad25eac323ead61ec5ff1fbb04a6dc2539 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Fri, 3 Dec 2021 11:16:22 +0800
Subject: [PATCH] KubeOS:add arm architecture support to the OS image
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
cmd/agent/server/server.go | 5 +-
files/{boot-grub2.mount => boot.mount} | 6 +-
scripts/bootloader.sh | 40 +++++++++++++
scripts/generate.sh | 83 +++++++++++++++-----------
scripts/grub.cfg | 16 ++---
scripts/rpmlist | 3 +-
scripts/set_in_chroot.sh | 2 +-
7 files changed, 107 insertions(+), 48 deletions(-)
rename files/{boot-grub2.mount => boot.mount} (92%)
create mode 100644 scripts/bootloader.sh
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
index 711e0c8..e4db02e 100644
--- a/cmd/agent/server/server.go
+++ b/cmd/agent/server/server.go
@@ -174,7 +174,10 @@ func install(imagePath string, mainPart string, partB string) error {
if side != partB {
next = "A"
}
- return runCommand("grub2-set-default", next)
+ if err := runCommand("grub2-set-default", next); err != nil {
+ return err
+ }
+ return runCommand("cp", "/boot/grub2/grubenv", "/boot/efi/EFI/openEuler")
}
func (s *Server) reboot() error {
diff --git a/files/boot-grub2.mount b/files/boot.mount
similarity index 92%
rename from files/boot-grub2.mount
rename to files/boot.mount
index a53fff7..a228aae 100644
--- a/files/boot-grub2.mount
+++ b/files/boot.mount
@@ -15,9 +15,9 @@ Conflicts=umount.target
Before=local-fs.target umount.target
[Mount]
-What=/dev/disk/by-label/GRUB2
-Where=/boot/grub2
-Type=ext4
+What=/dev/disk/by-label/BOOT
+Where=/boot
+Type=vfat
Options=defaults
[Install]
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
new file mode 100644
index 0000000..b93c314
--- /dev/null
+++ b/scripts/bootloader.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+set -eu
+set -o pipefail
+set -x
+ARCH=`arch`
+
+function install_grub2_x86 ()
+{
+ # make boot.img/core.img and setup, to support legacy boot mode
+ GRUBNAME=$(which grub2-install)
+ echo "Installing GRUB2..."
+ GRUB_OPTS=${GRUB_OPTS:-"--force"}
+ GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
+
+ $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $DEVICE
+
+ # make efi file, and save in FAT16 partition, to support UEFI boot mode
+ cp -r /usr/lib/grub/x86_64-efi boot/efi/EFI/openEuler
+ eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
+
+ mkdir -p /boot/EFI/BOOT/
+ cp -f /boot/efi/EFI/openEuler/grubx64.efi /boot/EFI/BOOT/BOOTX64.EFI
+}
+
+function install_grub2_efi ()
+{
+ cp -r /usr/lib/grub/arm64-efi /boot/efi/EFI/openEuler/
+ eval "grub2-mkimage -d /usr/lib/grub/arm64-efi -O arm64-efi --output=/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
+
+ mkdir -p /boot/EFI/BOOT/
+ cp -f /boot/efi/EFI/openEuler/grubaa64.efi /boot/EFI/BOOT/BOOTAA64.EFI
+}
+
+if [ $ARCH == "x86_64" ]; then
+ install_grub2_x86
+fi
+
+if [ $ARCH == "aarch64" ]; then
+ install_grub2_efi
+fi
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 73830ea..c481e30 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -22,6 +22,7 @@ TMP_MOUNT_PATH="${PWD}/mnt"
RPM_ROOT="${PWD}/rootfs"
LOCK=./test.lock
CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
+ARCH=$(arch)
function show_options() {
cat << EOF
@@ -76,9 +77,14 @@ function init_part() {
offset=$(echo "${offset}*512" | bc)
local loop=$(losetup -f)
losetup -o "${offset}" --sizelimit "${sizelimit}" "${loop}" system.img
- mkfs.ext4 -L "$2" "${loop}"
- mount -t ext4 "${loop}" "$3"
- rm -rf "$3/lost+found"
+ if [ $2 == "BOOT" ];then
+ mkfs.vfat -n "$2" "${loop}"
+ mount -t vfat "${loop}" "$3"
+ else
+ mkfs.ext4 -L "$2" "${loop}"
+ mount -t ext4 "${loop}" "$3"
+ rm -rf "$3/lost+found"
+ fi
}
function delete_dir() {
@@ -183,12 +189,15 @@ function install_packages() {
fi
local rpms=$(cat ./rpmlist | tr "\n" " ")
- yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms}
- yum -y --installroot="${RPM_ROOT}" clean all
+ if [ "${ARCH}" == "x86_64" ]; then
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2 grub2-efi-x64-modules grub2-pc-modules
+ elif [ "${ARCH}" == "aarch64" ]; then
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2-efi-aa64-modules
+ fi
+ yum -y --installroot="${RPM_ROOT}" clean all
}
function install_misc() {
- cp grub.cfg "${RPM_ROOT}/boot/grub2/"
cp ../files/*mount ../files/os-agent.service "${RPM_ROOT}/usr/lib/systemd/system/"
cp ../files/os-release "${RPM_ROOT}/usr/lib/"
cp "${AGENT_PATH}" "${RPM_ROOT}/usr/bin"
@@ -204,38 +213,46 @@ EOF
mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
cp set_in_chroot.sh "${RPM_ROOT}"
- ROOT_PWD="${PASSWD}" chroot "$RPM_ROOT" bash /set_in_chroot.sh
+ ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
rm "${RPM_ROOT}/set_in_chroot.sh"
}
function create_img() {
rm -f system.img update.img
qemu-img create system.img ${IMG_SIZE}G
- parted system.img -- mklabel msdos
- parted system.img -- mkpart primary ext4 1MiB 20MiB
- parted system.img -- mkpart primary ext4 20MiB 2120MiB
- parted system.img -- mkpart primary ext4 2120MiB 4220MiB
- parted system.img -- mkpart primary ext4 4220MiB 100%
-
- local device=$(losetup -f)
- losetup "${device}" system.img
-
- mkdir -p "${TMP_MOUNT_PATH}"
-
- init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
- local grub2_path="${TMP_MOUNT_PATH}/boot/grub2"
- mkdir -p "${grub2_path}"
- init_part system.img1 GRUB2 "${grub2_path}"
-
- tar -x -C "${TMP_MOUNT_PATH}" -f os.tar
- sync
-
- dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
- mount_proc_dev_sys "${TMP_MOUNT_PATH}"
- chroot "${TMP_MOUNT_PATH}" grub2-install --modules="biosdisk part_msdos" "${device}"
- sync
- unmount_dir "${TMP_MOUNT_PATH}"
-
+ parted system.img -- mklabel msdos
+ parted system.img -- mkpart primary fat16 1MiB 60MiB
+ parted system.img -- mkpart primary ext4 60MiB 2160MiB
+ parted system.img -- mkpart primary ext4 2160MiB 4260MiB
+ parted system.img -- mkpart primary ext4 4260MiB 100%
+
+ local device=$(losetup -f)
+ losetup "${device}" system.img
+
+ mkdir -p "${TMP_MOUNT_PATH}"
+
+ init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
+ local BOOT_PATH=${TMP_MOUNT_PATH}/boot
+ mkdir -p ${BOOT_PATH}
+ chmod 755 ${BOOT_PATH}
+ init_part system.img1 BOOT "${BOOT_PATH}"
+
+ mv -f ${RPM_ROOT}/boot/* ${BOOT_PATH} || true
+ [ -d ${RPM_ROOT}/boot/ ] && rm -rf ${RPM_ROOT}/boot/
+ sudo mv -t ${TMP_MOUNT_PATH} ${RPM_ROOT}/* || true
+ cp bootloader.sh "${TMP_MOUNT_PATH}"
+ mount_proc_dev_sys "${TMP_MOUNT_PATH}"
+ DEVICE="${device}" chroot "${TMP_MOUNT_PATH}" bash bootloader.sh
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/grub2
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/efi/EFI/openEuler
+ rm -rf "${TMP_MOUNT_PATH}/bootloader.sh"
+ sync
+
+ dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
+ sync
+ unmount_dir "${TMP_MOUNT_PATH}"
+
+
init_part system.img3 ROOT-B "${TMP_MOUNT_PATH}"
umount "${TMP_MOUNT_PATH}"
@@ -251,8 +268,6 @@ function create_os_tar() {
install_packages
install_misc
unmount_dir "${RPM_ROOT}"
-
- tar -C "${RPM_ROOT}" -cf ./os.tar .
}
test_lock
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
index d10e4cf..90507c4 100644
--- a/scripts/grub.cfg
+++ b/scripts/grub.cfg
@@ -92,12 +92,12 @@ menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod ext2
set root='hd0,msdos2'
if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /boot/vmlinuz
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /vmlinuz
else
- search --no-floppy --file --set=root /boot/vmlinuz
+ search --no-floppy --file --set=root /vmlinuz
fi
- linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
+ linux /vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
+ initrd /initramfs.img
}
menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'KubeOS-B' {
@@ -108,12 +108,12 @@ menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod ext2
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /boot/vmlinuz
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /vmlinuz
else
- search --no-floppy --file --set=root /boot/vmlinuz
+ search --no-floppy --file --set=root /vmlinuz
fi
- linux /boot/vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
+ linux /vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
+ initrd /initramfs.img
}
### END /etc/grub.d/10_linux ###
diff --git a/scripts/rpmlist b/scripts/rpmlist
index 93c277c..7a9adfa 100644
--- a/scripts/rpmlist
+++ b/scripts/rpmlist
@@ -1,6 +1,7 @@
kernel
passwd
-grub2
+grub2-efi
+grub2-tools
dhcp
NetworkManager
openssh-server
diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh
index 3b8313f..49e3894 100644
--- a/scripts/set_in_chroot.sh
+++ b/scripts/set_in_chroot.sh
@@ -1,7 +1,7 @@
#!/bin/bash
ln -s /usr/lib/systemd/system/os-agent.service /usr/lib/systemd/system/multi-user.target.wants/os-agent.service
ln -s /usr/lib/systemd/system/kubelet.service /usr/lib/systemd/system/multi-user.target.wants/kubelet.service
-ln -s /usr/lib/systemd/system/boot-grub2.mount /lib/systemd/system/local-fs.target.wants/boot-grub2.mount
+ln -s /usr/lib/systemd/system/boot.mount /lib/systemd/system/local-fs.target.wants/boot.mount
ln -s /usr/lib/systemd/system/etc.mount /lib/systemd/system/local-fs.target.wants/etc.mount
str=`sed -n '/^root:/p' /etc/shadow | awk -F "root:" '{print $2}'`
--
2.30.0

View File

@ -0,0 +1,300 @@
From fd5b3f24446c8c5dfc2fb271431ed296618eccc1 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Sat, 27 Aug 2022 16:22:56 +0800
Subject: [PATCH] KubeOS: fixed the issue of VMs images and add check of
Global.cfg.
Modify the docker image creation method to fix the problem that /etc/hosts is
empty in the VM created using the docker image and that the /sys directory is
mounted abnormally.
Add checks whether configuration in the Global.cfg file are empty and whether
the IP address is valid.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
api/v1alpha1/os_types.go | 15 +++---
cmd/agent/server/docker_image.go | 27 +++++++----
.../config/crd/upgrade.openeuler.org_os.yaml | 1 -
scripts/Dockerfile | 2 +-
scripts/common/utils.sh | 48 ++++++++++++++++---
scripts/create/imageCreate.sh | 3 +-
scripts/create/rootfsCreate.sh | 12 ++---
scripts/kbimg.sh | 19 +-------
8 files changed, 74 insertions(+), 53 deletions(-)
diff --git a/api/v1alpha1/os_types.go b/api/v1alpha1/os_types.go
index 5acb97a..862d408 100644
--- a/api/v1alpha1/os_types.go
+++ b/api/v1alpha1/os_types.go
@@ -23,14 +23,13 @@ type OSSpec struct {
MaxUnavailable int `json:"maxunavailable"`
CheckSum string `json:"checksum"`
FlagSafe bool `json:"flagSafe"`
- // +kubebuilder:default=true
- MTLS bool `json:"mtls"`
- ImageType string `json:"imagetype"`
- DockerImage string `json:"dockerimage"`
- OpsType string `json:"opstype"`
- CaCert string `json:"cacert"`
- ClientCert string `json:"clientcert"`
- ClientKey string `json:"clientkey"`
+ MTLS bool `json:"mtls"`
+ ImageType string `json:"imagetype"`
+ DockerImage string `json:"dockerimage"`
+ OpsType string `json:"opstype"`
+ CaCert string `json:"cacert"`
+ ClientCert string `json:"clientcert"`
+ ClientKey string `json:"clientkey"`
}
// +kubebuilder:subresource:status
diff --git a/cmd/agent/server/docker_image.go b/cmd/agent/server/docker_image.go
index c5ed640..11b21aa 100644
--- a/cmd/agent/server/docker_image.go
+++ b/cmd/agent/server/docker_image.go
@@ -54,7 +54,7 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
return "", err
}
defer cli.ContainerRemove(ctx, info.ID, types.ContainerRemoveOptions{})
- tarStream, stat, err := cli.CopyFromContainer(ctx, info.ID, "/")
+ tarStream, stat, err := cli.CopyFromContainer(ctx, info.ID, "/os.tar")
if err != nil {
return "", err
}
@@ -71,6 +71,15 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
return "", fmt.Errorf("space is not enough for downloaing")
}
+ srcInfo := archive.CopyInfo{
+ Path: "/",
+ Exists: true,
+ IsDir: stat.Mode.IsDir(),
+ }
+ if err = archive.CopyTo(tarStream, srcInfo, PersistDir); err != nil {
+ return "", err
+ }
+
tmpMountPath := filepath.Join(PersistDir, "/kubeos-update")
if err = os.Mkdir(tmpMountPath, imgPermission); err != nil {
return "", err
@@ -80,25 +89,23 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
if err = runCommand("dd", "if=/dev/zero", "of="+imagePath, "bs=2M", "count=1024"); err != nil {
return "", err
}
- if err = runCommand("mkfs.ext4", imagePath); err != nil {
+ _, next, err := getNextPart(partA, partB)
+ if err = runCommand("mkfs.ext4", "-L", "ROOT-"+next, imagePath); err != nil {
return "", err
}
if err = runCommand("mount", "-o", "loop", imagePath, tmpMountPath); err != nil {
return "", err
}
defer func() {
- runCommand("losetup", "-D")
syscall.Unmount(tmpMountPath, 0)
-
+ runCommand("losetup", "-D")
}()
- srcInfo := archive.CopyInfo{
- Path: "/",
- Exists: true,
- IsDir: stat.Mode.IsDir(),
- }
+
logrus.Infoln("downloading to file " + imagePath)
- if err = archive.CopyTo(tarStream, srcInfo, tmpMountPath); err != nil {
+ tmpTarPath := filepath.Join(PersistDir, "/os.tar")
+ if err = runCommand("tar", "-xvf", tmpTarPath, "-C", tmpMountPath); err != nil {
return "", err
}
+ defer os.Remove(tmpTarPath)
return imagePath, nil
}
diff --git a/docs/example/config/crd/upgrade.openeuler.org_os.yaml b/docs/example/config/crd/upgrade.openeuler.org_os.yaml
index 465e803..f240b8d 100644
--- a/docs/example/config/crd/upgrade.openeuler.org_os.yaml
+++ b/docs/example/config/crd/upgrade.openeuler.org_os.yaml
@@ -51,7 +51,6 @@ spec:
maxunavailable:
type: integer
mtls:
- default: true
type: boolean
opstype:
type: string
diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 6a616f5..3da4708 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -1,3 +1,3 @@
FROM scratch
-ADD os.tar /
+COPY os.tar /
CMD ["/bin/sh"]
diff --git a/scripts/common/utils.sh b/scripts/common/utils.sh
index 3546c8c..cf9441b 100644
--- a/scripts/common/utils.sh
+++ b/scripts/common/utils.sh
@@ -87,19 +87,53 @@ function delete_file() {
return 0
}
-function check_binary_exist() {
- if [ ! -f "$1" ];then
- log_error_print "binary path is invalid."
+function check_file_valid() {
+ local file="$1"
+ local mesg="$2"
+ if [ ! -e "${file}" ]; then
+ log_error_print "${mesg} is not exist."
+ exit 3
+ fi
+ if [ ! -f "${file}" ];then
+ log_error_print "${mesg} is not a file."
exit 3
fi
}
-function check_repo_path() {
- if [ ! -f "$1" ];then
- log_error_print "REPO path is invalid."
+function check_conf_valid() {
+ local conf_path="${PWD}/00bootup/Global.cfg"
+ check_file_valid ${conf_path} "Globab.cfg"
+ if [ $# != 7 ];then
+ log_error_print "configure configured in Global.cfg is empty."
exit 3
fi
+ for addr in ${server_ip} ${local_ip} ${route_ip} ${netmask}; do
+ check_ip_valid $addr
+ done
+}
+function check_ip_valid() {
+ local ipaddr="$1";
+ if [[ ! $ipaddr =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] ; then
+ log_error_print "ip address configured in Global.cfg is not valid."
+ exit 3;
+ fi
+ for quad in $(echo "${ipaddr//./ }"); do
+ if [ $quad -ge 0 ] && [ $quad -le 255 ];then
+ continue
+ fi
+ log_error_print "ip address configured in Global.cfg is not valid."
+ exit 3;
+ done
+
+}
+
+function check_binary_exist() {
+ check_file_valid "$1" "os-agent binary"
+}
+
+function check_repo_path() {
+ check_file_valid $1 "REPO file"
if [ -d "${RPM_ROOT}" ]; then
log_error_print "there is a rootfs folder. please confirm if rootfs is being used, if not, please remove ${RPM_ROOT} first."
exit 5
@@ -117,7 +151,7 @@ function check_disk_space() {
fi
;;
vm)
- local maxsize=$((5*1024*1024))
+ local maxsize=$((25*1024*1024))
if [ "${disk_ava}" -lt "${maxsize}" ]; then
log_error_print "The available disk space is not enough, at least 25GiB."
exit 6
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
index 564c740..9689f62 100644
--- a/scripts/create/imageCreate.sh
+++ b/scripts/create/imageCreate.sh
@@ -62,13 +62,12 @@ function create_pxe_img() {
case $opt in
"repo")
create_os_tar_from_repo "$@"
- tar -xvf os.tar ./initramfs.img
;;
"docker")
create_os_tar_from_docker "$@"
- tar -xvf os.tar initramfs.img
;;
esac
+ tar -xvf os.tar ./initramfs.img
mv os.tar kubeos.tar
}
function create_docker_image() {
diff --git a/scripts/create/rootfsCreate.sh b/scripts/create/rootfsCreate.sh
index e5c53d5..4c02c35 100644
--- a/scripts/create/rootfsCreate.sh
+++ b/scripts/create/rootfsCreate.sh
@@ -65,8 +65,6 @@ EOF
cp set_in_chroot.sh "${RPM_ROOT}"
ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
rm "${RPM_ROOT}/set_in_chroot.sh"
-
- #todo:chroot create initramfs.img to include install-scripts for PXE install
}
function create_os_tar_from_repo() {
@@ -80,9 +78,9 @@ function create_os_tar_from_repo() {
tar -C "$RPM_ROOT" -cf ./os.tar .
}
function create_os_tar_from_docker() {
- local DOCKER_IMG=$1
- container_id=$(docker create ${DOCKER_IMG})
- echo "$container_id"
- docker export $container_id > os.tar
- docker rm $container_id
+ local DOCKER_IMG=$1
+ container_id=$(docker create ${DOCKER_IMG})
+ echo "$container_id"
+ docker cp $container_id:/os.tar ./
+ docker rm $container_id
}
diff --git a/scripts/kbimg.sh b/scripts/kbimg.sh
index a77d62e..a623e3d 100644
--- a/scripts/kbimg.sh
+++ b/scripts/kbimg.sh
@@ -24,6 +24,7 @@ source common/log.sh &>/dev/null
source common/utils.sh &>/dev/null
source create/rootfsCreate.sh &>/dev/null
source create/imageCreate.sh &>/dev/null
+source 00bootup/Global.cfg &>/dev/null
function show_options() {
cat << EOF
@@ -89,23 +90,6 @@ options:
EOF
}
-function show_pxe_image_usage() {
- cat << EOF
-
-Usage : kbimg create pxe-image -p iso-path -v os-version -b os-agent-dir -e os-password
- or
- kbimg create pxe-image -d repository/name:tag
-
-options:
- -p repo path
- -v KubeOS version
- -b directory of os-agent binary
- -e os encrypted password
- -d docker image like repository/name:tag
- -h,--help show help information
-EOF
-}
-
function file_lock() {
local lock_file=$1
exec {lock_fd}>"${lock_file}"
@@ -282,6 +266,7 @@ function verify_create_input() {
fi
fi
check_disk_space "pxe"
+ check_conf_valid ${rootfs_name} ${disk} ${server_ip} ${local_ip} ${route_ip} ${netmask} ${net_name}
if [ $# -eq 8 ]; then
verify_repo_input "$@"
check_repo_path "${REPO}"
--
2.33.0.windows.2

View File

@ -0,0 +1,183 @@
From 54d0a0304a0f76a0e619a8adac370eb3866f52b1 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Wed, 31 Aug 2022 18:06:28 +0800
Subject: [PATCH] KubeOS:add the clearing of space before the upgrade and
rectifying the rollback failure.
The pre-upgrade space clearance function is added to resolve the problem that the upgrade
fails due to residual resources when the upgrade is performed again after a power failure.
Fix the rollback failure when the upgrade fails due to the upgrade using different architectures.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
cmd/agent/server/docker_image.go | 91 ++++++++++++++++++++++++++++----
scripts/grub.cfg | 10 ----
2 files changed, 81 insertions(+), 20 deletions(-)
diff --git a/cmd/agent/server/docker_image.go b/cmd/agent/server/docker_image.go
index 11b21aa..4f9edc1 100644
--- a/cmd/agent/server/docker_image.go
+++ b/cmd/agent/server/docker_image.go
@@ -15,6 +15,7 @@ package server
import (
"context"
+ "errors"
"fmt"
"io/ioutil"
"os"
@@ -47,9 +48,18 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
return "", err
}
+ containerName := "kubeos-temp"
+ containers, err := cli.ContainerList(ctx, types.ContainerListOptions{All: true})
+ for _, container := range containers {
+ if container.Names[0] == "/"+containerName {
+ if err = cli.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{}); err != nil {
+ return "", err
+ }
+ }
+ }
info, err := cli.ContainerCreate(ctx, &container.Config{
Image: imageName,
- }, nil, nil, "kubeos-temp")
+ }, nil, nil, containerName)
if err != nil {
return "", err
}
@@ -71,22 +81,31 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
return "", fmt.Errorf("space is not enough for downloaing")
}
+ tmpUpdatePath := filepath.Join(PersistDir, "/KubeOS-Update")
+ tmpMountPath := filepath.Join(tmpUpdatePath, "/kubeos-update")
+ tmpTarPath := filepath.Join(tmpUpdatePath, "/os.tar")
+ imagePath := filepath.Join(PersistDir, "/update.img")
+
+ if err = cleanSpace(tmpUpdatePath, tmpMountPath, imagePath); err != nil {
+ return "", err
+ }
+ if err = os.MkdirAll(tmpMountPath, imgPermission); err != nil {
+ return "", err
+ }
+ defer os.RemoveAll(tmpUpdatePath)
+
srcInfo := archive.CopyInfo{
Path: "/",
Exists: true,
IsDir: stat.Mode.IsDir(),
}
- if err = archive.CopyTo(tarStream, srcInfo, PersistDir); err != nil {
+ if err = archive.CopyTo(tarStream, srcInfo, tmpUpdatePath); err != nil {
return "", err
}
-
- tmpMountPath := filepath.Join(PersistDir, "/kubeos-update")
- if err = os.Mkdir(tmpMountPath, imgPermission); err != nil {
+ if err = runCommand("dd", "if=/dev/zero", "of="+imagePath, "bs=2M", "count=1024"); err != nil {
return "", err
}
- defer os.Remove(tmpMountPath)
- imagePath := filepath.Join(PersistDir, "/update.img")
- if err = runCommand("dd", "if=/dev/zero", "of="+imagePath, "bs=2M", "count=1024"); err != nil {
+ if err = os.Chmod(imagePath, imgPermission); err != nil {
return "", err
}
_, next, err := getNextPart(partA, partB)
@@ -102,10 +121,62 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
}()
logrus.Infoln("downloading to file " + imagePath)
- tmpTarPath := filepath.Join(PersistDir, "/os.tar")
if err = runCommand("tar", "-xvf", tmpTarPath, "-C", tmpMountPath); err != nil {
return "", err
}
- defer os.Remove(tmpTarPath)
return imagePath, nil
}
+
+func cleanSpace(updatePath, mountPath, imagePath string) error {
+ isFileExist, err := checkFileExist(mountPath)
+ if err != nil {
+ return err
+ }
+ if isFileExist {
+ var st syscall.Stat_t
+ if err := syscall.Lstat(mountPath, &st); err != nil {
+ return err
+ }
+ dev := st.Dev
+ parent := filepath.Dir(mountPath)
+ if err := syscall.Lstat(parent, &st); err != nil {
+ return err
+ }
+ if dev != st.Dev {
+ if err := syscall.Unmount(mountPath, 0); err != nil {
+ return err
+ }
+ }
+ }
+
+ if err = deleteFile(updatePath); err != nil {
+ return err
+ }
+
+ if err = deleteFile(imagePath); err != nil {
+ return err
+ }
+ return nil
+}
+
+func deleteFile(path string) error {
+ isFileExist, err := checkFileExist(path)
+ if err != nil {
+ return err
+ }
+ if isFileExist {
+ if err = os.RemoveAll(path); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+func checkFileExist(path string) (bool, error) {
+ if _, err := os.Stat(path); err == nil {
+ return true, nil
+ } else if errors.Is(err, os.ErrNotExist) {
+ return false, nil
+ } else {
+ return false, err
+ }
+}
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
index d10e4cf..c1a2641 100644
--- a/scripts/grub.cfg
+++ b/scripts/grub.cfg
@@ -91,11 +91,6 @@ menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod part_msdos
insmod ext2
set root='hd0,msdos2'
- if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /boot/vmlinuz
- else
- search --no-floppy --file --set=root /boot/vmlinuz
- fi
linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
initrd /boot/initramfs.img
}
@@ -107,11 +102,6 @@ menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod part_msdos
insmod ext2
set root='hd0,msdos3'
- if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /boot/vmlinuz
- else
- search --no-floppy --file --set=root /boot/vmlinuz
- fi
linux /boot/vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
initrd /boot/initramfs.img
}
--
2.33.0.windows.2

View File

@ -0,0 +1,254 @@
From a1bf179490d33c25dd49fe6c363eec5e0e8fe532 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Sat, 3 Sep 2022 14:21:54 +0800
Subject: [PATCH] KubeOS:add the configuration of /etc/resolv.conf and change
the VM disk to gpt.
Add the user-defined /etc/resolv.conf file and change the VM disk to gpt
to be the same as that on the physical machine.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
cmd/agent/server/docker_image.go | 3 +-
scripts/00bootup/mount.sh | 50 ++++++++++++++++++--------------
scripts/bootloader.sh | 4 +--
scripts/create/imageCreate.sh | 12 ++++----
scripts/create/rootfsCreate.sh | 4 +++
scripts/grub.cfg | 8 ++---
6 files changed, 45 insertions(+), 36 deletions(-)
diff --git a/cmd/agent/server/docker_image.go b/cmd/agent/server/docker_image.go
index 4f9edc1..735ace0 100644
--- a/cmd/agent/server/docker_image.go
+++ b/cmd/agent/server/docker_image.go
@@ -108,8 +108,7 @@ func pullOSImage(req *pb.UpdateRequest) (string, error) {
if err = os.Chmod(imagePath, imgPermission); err != nil {
return "", err
}
- _, next, err := getNextPart(partA, partB)
- if err = runCommand("mkfs.ext4", "-L", "ROOT-"+next, imagePath); err != nil {
+ if err = runCommand("mkfs.ext4", "-L", "ROOT-A", imagePath); err != nil {
return "", err
}
if err = runCommand("mount", "-o", "loop", imagePath, tmpMountPath); err != nil {
diff --git a/scripts/00bootup/mount.sh b/scripts/00bootup/mount.sh
index 1bc83ff..7f00fd6 100644
--- a/scripts/00bootup/mount.sh
+++ b/scripts/00bootup/mount.sh
@@ -23,6 +23,14 @@ function CheckSpace() {
return 0
}
+function mount_proc_dev_sys() {
+ local tmp_root=$1
+ mount -t proc none "${tmp_root}/proc"
+ mount --bind /dev "${tmp_root}/dev"
+ mount --bind /dev/pts "${tmp_root}/dev/pts"
+ mount -t sysfs none "${tmp_root}/sys"
+}
+
function GetDisk() {
disks=(`hwinfo --disk --short 2>&1 | grep -vi "^disk" | awk '{print $1}'`)
if [ ${#disks[*]} -gt 0 ]; then
@@ -162,14 +170,13 @@ function MountRoot() {
function MountPersist() {
echo "Mounting persist"
- mkdir /persist
- mount ${disk}4 /persist >> ${log} 2>&1
+ mount ${disk}4 /sysroot/persist >> ${log} 2>&1
if [ $? -ne 0 ]; then
echo "mount persist failed" | tee -a ${log}
return 1
fi
- mkdir /persist/{var,etc,etcwork}
- mkdir -p /persist/etc/KubeOS/certs
+ mkdir /sysroot/persist/{var,etc,etcwork}
+ mkdir -p /sysroot/persist/etc/KubeOS/certs
return 0
}
@@ -187,20 +194,20 @@ function MountBoot() {
function GetRootfs() {
echo "Downloading rootfs..."
- curl -o /persist/${rootfs_name} http://${server_ip}/${rootfs_name}
- if [ ! -e "/persist/${rootfs_name}" ]; then
+ curl -o /${rootfs_name} http://${server_ip}/${rootfs_name}
+ if [ ! -e "/${rootfs_name}" ]; then
echo "download rootfs failed" | tee -a ${log}
return 1
fi
- tar -xvf /persist/${rootfs_name} -C /sysroot
+ tar -xf /${rootfs_name} -C /sysroot
if [ $? -ne 0 ]; then
echo "decompose rootfs failed" | tee -a ${log}
return 1
fi
- rm -rf /persist/${rootfs_name}
-
+ rm -rf /${rootfs_name}
+ mount -o remount,ro ${disk}2 /sysroot >> ${log} 2>&1
return 0
}
@@ -283,6 +290,8 @@ function Bootup_Main() {
fi
# mount partitions
+
+ # mount boot
echo "Mounting root..." | tee -a ${log}
MountRoot
if [ $? -ne 0 ]; then
@@ -290,15 +299,6 @@ function Bootup_Main() {
return 1
fi
- # mount persist
- echo "Mounting persisst..." | tee -a ${log}
- MountPersist
- if [ $? -ne 0 ]; then
- echo "Mounting persist failed" | tee -a ${log}
- return 1
- fi
-
- # mount boot
echo "Mounting boot..." | tee -a ${log}
MountBoot
if [ $? -ne 0 ]; then
@@ -313,7 +313,7 @@ function Bootup_Main() {
echo "Downloading rootfs failed" | tee -a ${log}
return 1
fi
-
+ mount_proc_dev_sys /sysroot
# set boot
echo "Setting boot..." | tee -a ${log}
SetBoot
@@ -321,7 +321,13 @@ function Bootup_Main() {
echo "Setting boot failed" | tee -a ${log}
return 1
fi
-
+ # mount persist
+ echo "Mounting persist..." | tee -a ${log}
+ MountPersist
+ if [ $? -ne 0 ]; then
+ echo "Mounting persist failed" | tee -a ${log}
+ return 1
+ fi
return 0
}
@@ -329,7 +335,7 @@ Bootup_Main
ret=$?
if [ ${ret} -eq 0 ]; then
echo "kubeOS install success! switch to root" | tee -a ${log}
- cp ${log} /persist
+ cp ${log} /sysroot/persist
else
echo "kubeOS install failed, see install.log" | tee -a ${log}
-fi
\ No newline at end of file
+fi
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
index 0f906d4..5760f3d 100644
--- a/scripts/bootloader.sh
+++ b/scripts/bootloader.sh
@@ -16,7 +16,7 @@ function install_grub2_x86 ()
# make efi file, and save in FAT16 partition, to support UEFI boot mode
cp -r /usr/lib/grub/x86_64-efi boot/efi/EFI/openEuler
- eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,msdos1)/EFI/openEuler' fat part_gpt part_msdos linux"
+ eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux"
mkdir -p /boot/EFI/BOOT/
cp -f /boot/efi/EFI/openEuler/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
@@ -25,7 +25,7 @@ function install_grub2_x86 ()
function install_grub2_efi ()
{
cp -r /usr/lib/grub/arm64-efi /boot/efi/EFI/openEuler/
- eval "grub2-mkimage -d /usr/lib/grub/arm64-efi -O arm64-efi --output=/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,msdos1)/EFI/openEuler' fat part_gpt part_msdos linux"
+ eval "grub2-mkimage -d /usr/lib/grub/arm64-efi -O arm64-efi --output=/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux"
mkdir -p /boot/EFI/BOOT/
cp -f /boot/efi/EFI/openEuler/grubaa64.efi /boot/efi/EFI/BOOT/BOOTAA64.EFI
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
index 9689f62..e615d5f 100644
--- a/scripts/create/imageCreate.sh
+++ b/scripts/create/imageCreate.sh
@@ -16,12 +16,12 @@ PWD="$(pwd)"
function create_img() {
rm -f system.img update.img
qemu-img create system.img ${IMG_SIZE}G
- parted system.img -- mklabel msdos
- parted system.img -- mkpart primary fat16 1MiB 60MiB
- parted system.img -- mkpart primary ext4 60MiB 2160MiB
- parted system.img -- mkpart primary ext4 2160MiB 4260MiB
- parted system.img -- mkpart primary ext4 4260MiB 100%
-
+ parted system.img -s mklabel gpt
+ parted system.img -s mkpart primary fat32 1MiB 60MiB
+ parted system.img -s mkpart primary ext4 60MiB 2160MiB
+ parted system.img -s mkpart primary ext4 2160MiB 4260MiB
+ parted system.img -s mkpart primary ext4 4260MiB 100%
+ parted system.img -s set 1 boot on
local device=$(losetup -f)
losetup "${device}" system.img
diff --git a/scripts/create/rootfsCreate.sh b/scripts/create/rootfsCreate.sh
index 4c02c35..29f2762 100644
--- a/scripts/create/rootfsCreate.sh
+++ b/scripts/create/rootfsCreate.sh
@@ -46,6 +46,7 @@ function install_misc() {
local VERSION=$1
local AGENT_PATH=$2
local PASSWD=$3
+ local DNS_CONF="${PWD}/resolv.conf"
cp ../files/*mount ../files/os-agent.service "${RPM_ROOT}/usr/lib/systemd/system/"
cp ../files/os-release "${RPM_ROOT}/usr/lib/"
cp "${AGENT_PATH}" "${RPM_ROOT}/usr/bin"
@@ -65,6 +66,9 @@ EOF
cp set_in_chroot.sh "${RPM_ROOT}"
ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
rm "${RPM_ROOT}/set_in_chroot.sh"
+ if [ -e "${DNS_CONF}" ]; then
+ cp "${DNS_CONF}" "${RPM_ROOT}/etc/resolv.conf"
+ fi
}
function create_os_tar_from_repo() {
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
index c1a2641..984b161 100644
--- a/scripts/grub.cfg
+++ b/scripts/grub.cfg
@@ -88,9 +88,9 @@ menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
load_video
set gfxpayload=keep
insmod gzio
- insmod part_msdos
+ insmod part_gpt
insmod ext2
- set root='hd0,msdos2'
+ set root='hd0,gpt2'
linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
initrd /boot/initramfs.img
}
@@ -99,9 +99,9 @@ menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
load_video
set gfxpayload=keep
insmod gzio
- insmod part_msdos
+ insmod part_gpt
insmod ext2
- set root='hd0,msdos3'
+ set root='hd0,gpt3'
linux /boot/vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
initrd /boot/initramfs.img
}
--
2.33.0.windows.2

View File

@ -0,0 +1,104 @@
From d638f26cdf8f22b258e97baec83a261a2de315ee Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Tue, 29 Nov 2022 16:39:20 +0800
Subject: [PATCH] KubeOS: remove grub2 legacy install, add error handling for
opstype and add entry for unit test in Makefile
Remove grub2 install for legacy setup to fix failure of x86
vm images building. Add the error handling of the abnormal value
of the opstype. Add an entry for unit testing in Makefile.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
Makefile | 3 +++
cmd/agent/server/docker_image_test.go | 21 ---------------------
cmd/proxy/controllers/os_controller.go | 3 +++
scripts/bootloader.sh | 8 --------
4 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/Makefile b/Makefile
index 38cc2ce..9d9fbea 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,9 @@ agent:
${ENV} ${GO_BUILD} -tags "osusergo netgo static_build" -ldflags '$(LDFLAGS)' $(BUILDFLAGS) -o bin/os-agent cmd/agent/main.go
strip bin/os-agent
+test:
+ $(GO) test $(shell go list ./... ) -race -cover -count=1 -timeout=300s
+
# Install CRDs into a cluster
install: manifests
kubectl apply -f confg/crd
diff --git a/cmd/agent/server/docker_image_test.go b/cmd/agent/server/docker_image_test.go
index cc77a2b..9987939 100644
--- a/cmd/agent/server/docker_image_test.go
+++ b/cmd/agent/server/docker_image_test.go
@@ -52,24 +52,3 @@ func TestpullOSImage(t *testing.T) {
}
defer os.RemoveAll("/persist")
}
-
-func TestrandStringBytesRmndr(t *testing.T) {
- type args struct {
- n int
- }
- tests := []struct {
- name string
- args args
- want string
- }{
- {name: "normal", args: args{n: 6}, want: ""},
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := randStringBytesRmndr(tt.args.n); got == "" {
- t.Errorf("randStringBytesRmndr() not generatre random string")
- }
-
- })
- }
-}
diff --git a/cmd/proxy/controllers/os_controller.go b/cmd/proxy/controllers/os_controller.go
index 09e58f9..fdd31ea 100644
--- a/cmd/proxy/controllers/os_controller.go
+++ b/cmd/proxy/controllers/os_controller.go
@@ -15,6 +15,7 @@ package controllers
import (
"context"
+ "fmt"
"os"
corev1 "k8s.io/api/core/v1"
@@ -123,6 +124,8 @@ func (r *OSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
if err := r.Connection.RollbackSpec(); err != nil {
return values.RequeueNow, err
}
+ default:
+ return values.RequeueNow, fmt.Errorf("operation %s cannot be recognized", opsType)
}
}
return values.Requeue, nil
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
index 5760f3d..16c5713 100644
--- a/scripts/bootloader.sh
+++ b/scripts/bootloader.sh
@@ -6,14 +6,6 @@ ARCH=`arch`
function install_grub2_x86 ()
{
- # make boot.img/core.img and setup, to support legacy boot mode
- GRUBNAME=$(which grub2-install)
- echo "Installing GRUB2..."
- GRUB_OPTS=${GRUB_OPTS:-"--force"}
- GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
-
- $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $DEVICE
-
# make efi file, and save in FAT16 partition, to support UEFI boot mode
cp -r /usr/lib/grub/x86_64-efi boot/efi/EFI/openEuler
eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux"
--
2.37.1.windows.1

View File

@ -0,0 +1,29 @@
From 20f66b28ea95e262f54cad1a9b65d564f91b8d12 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Thu, 8 Dec 2022 15:08:52 +0800
Subject: [PATCH] KubeOS:fix usage does not print when an error occurs in the
upgrade image creation
Fix the bug that the usage does not print
when the upgrade image has parameter errors
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
scripts/kbimg.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/kbimg.sh b/scripts/kbimg.sh
index a623e3d..a860c06 100644
--- a/scripts/kbimg.sh
+++ b/scripts/kbimg.sh
@@ -125,6 +125,7 @@ function verify_upgrade_image_input() {
echo "$@" | grep -q "\-$i "
if [ "$?" -ne 0 ];then
log_error_print "option -$i is mandatory, please check input"
+ show_upgrade_image_usage
exit 3
fi
done
--
2.33.0.windows.2

View File

@ -1,14 +1,18 @@
# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. # Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
Name: KubeOS Name: KubeOS
Version: 1.0.1 Version: 1.0.2
Release: 6 Release: 8
Summary: O&M platform used to update the whole OS as an entirety Summary: O&M platform used to update the whole OS as an entirety
License: Mulan PSL v2 License: Mulan PSL v2
Source0: https://gitee.com/openeuler/KubeOS/repository/archive/v%{version}.tar.gz Source0: https://gitee.com/openeuler/KubeOS/repository/archive/v%{version}.tar.gz
Patch1: 0001-KubeOS-modify-checks-in-generate.sh-and-change-modul.patch Patch1: 0001-Write-a-tool-to-support-KubeOS-deployment-on-physica.patch
Patch2: 0002-change-generate-argument-from-isopath-to-repopath.patch Patch2: 0002-KubeOS-fix-the-kbimg.sh-exception-and-pxe-installati.patch
Patch3: 0003-KubeOS-add-arm-architecture-support-to-the-OS-image.patch Patch3: 0003-KubeOS-fixed-the-issue-of-VMs-images-and-add-check-o.patch
Patch4: 0004-KubeOS-add-the-clearing-of-space-before-the-upgrade-.patch
Patch5: 0005-KubeOS-add-the-configuration-of-etc-resolv.conf-and-.patch
Patch6: 0006-KubeOS-remove-grub2-legacy-install-add-error-handlin.patch
Patch7: 0007-KubeOS-fix-usage-does-not-print-when-an-error-occurs.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: make BuildRequires: make
BuildRequires: golang >= 1.13 BuildRequires: golang >= 1.13
@ -17,7 +21,7 @@ This is an O&M platform used to update the whole OS as an entirety,
it should be running in kubernetes environment. it should be running in kubernetes environment.
%prep %prep
%autosetup -n %{name} -p1 %autosetup -n %{name}-v%{version} -p1
%package scripts %package scripts
Summary: Scripts to build the os image and binaries of os-proxy and os-operator Summary: Scripts to build the os image and binaries of os-proxy and os-operator
@ -44,13 +48,28 @@ install -p -m 0500 ./bin/operator %{buildroot}/opt/kubeOS/bin
#install artifacts #install artifacts
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts install -d -m 0740 %{buildroot}/opt/kubeOS/scripts
install -p -m 0600 ./scripts/rpmlist %{buildroot}/opt/kubeOS/scripts install -p -m 0600 ./scripts/rpmlist %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/generate.sh %{buildroot}/opt/kubeOS/scripts install -p -m 0500 ./scripts/kbimg.sh %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/set_in_chroot.sh %{buildroot}/opt/kubeOS/scripts install -p -m 0500 ./scripts/set_in_chroot.sh %{buildroot}/opt/kubeOS/scripts
install -p -m 0600 ./scripts/grub.cfg %{buildroot}/opt/kubeOS/scripts install -p -m 0600 ./scripts/grub.cfg %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/bootloader.sh %{buildroot}/opt/kubeOS/scripts install -p -m 0500 ./scripts/bootloader.sh %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/Dockerfile %{buildroot}/opt/kubeOS/scripts
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/common
install -p -m 0500 ./scripts/common/globalVariables.sh %{buildroot}/opt/kubeOS/scripts/common
install -p -m 0500 ./scripts/common/log.sh %{buildroot}/opt/kubeOS/scripts/common
install -p -m 0500 ./scripts/common/utils.sh %{buildroot}/opt/kubeOS/scripts/common
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/create
install -p -m 0500 ./scripts/create/imageCreate.sh %{buildroot}/opt/kubeOS/scripts/create
install -p -m 0500 ./scripts/create/rootfsCreate.sh %{buildroot}/opt/kubeOS/scripts/create
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/00bootup
install -p -m 0600 ./scripts/00bootup/Global.cfg %{buildroot}/opt/kubeOS/scripts/00bootup
install -p -m 0500 ./scripts/00bootup/module-setup.sh %{buildroot}/opt/kubeOS/scripts/00bootup
install -p -m 0500 ./scripts/00bootup/mount.sh %{buildroot}/opt/kubeOS/scripts/00bootup
install -d -m 0740 %{buildroot}/opt/kubeOS/files install -d -m 0740 %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/boot.mount %{buildroot}/opt/kubeOS/files install -p -m 0600 ./files/boot-efi.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/etc.mount %{buildroot}/opt/kubeOS/files install -p -m 0600 ./files/etc.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/persist.mount %{buildroot}/opt/kubeOS/files install -p -m 0600 ./files/persist.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/var.mount %{buildroot}/opt/kubeOS/files install -p -m 0600 ./files/var.mount %{buildroot}/opt/kubeOS/files
@ -60,7 +79,7 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
%files %files
%attr(0500,root,root) /opt/kubeOS/bin/os-agent %attr(0500,root,root) /opt/kubeOS/bin/os-agent
%defattr(-,root,root,0500) %defattr(-,root,root,0500)
%attr(0600,root,root) /opt/kubeOS/files/boot.mount %attr(0600,root,root) /opt/kubeOS/files/boot-efi.mount
%attr(0600,root,root) /opt/kubeOS/files/etc.mount %attr(0600,root,root) /opt/kubeOS/files/etc.mount
%attr(0600,root,root) /opt/kubeOS/files/persist.mount %attr(0600,root,root) /opt/kubeOS/files/persist.mount
%attr(0600,root,root) /opt/kubeOS/files/var.mount %attr(0600,root,root) /opt/kubeOS/files/var.mount
@ -72,15 +91,76 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
%attr(0500,root,root) /opt/kubeOS/bin/operator %attr(0500,root,root) /opt/kubeOS/bin/operator
%defattr(-,root,root,0500) %defattr(-,root,root,0500)
%attr(0600,root,root) /opt/kubeOS/scripts/rpmlist %attr(0600,root,root) /opt/kubeOS/scripts/rpmlist
%attr(0500,root,root) /opt/kubeOS/scripts/generate.sh %attr(0500,root,root) /opt/kubeOS/scripts/kbimg.sh
%attr(0500,root,root) /opt/kubeOS/scripts/set_in_chroot.sh %attr(0500,root,root) /opt/kubeOS/scripts/set_in_chroot.sh
%attr(0600,root,root) /opt/kubeOS/scripts/grub.cfg %attr(0600,root,root) /opt/kubeOS/scripts/grub.cfg
%attr(0500,root,root) /opt/kubeOS/scripts/bootloader.sh %attr(0500,root,root) /opt/kubeOS/scripts/bootloader.sh
%attr(0500,root,root) /opt/kubeOS/scripts/Dockerfile
%attr(0500,root,root) /opt/kubeOS/scripts/common/globalVariables.sh
%attr(0500,root,root) /opt/kubeOS/scripts/common/log.sh
%attr(0500,root,root) /opt/kubeOS/scripts/common/utils.sh
%attr(0500,root,root) /opt/kubeOS/scripts/create/imageCreate.sh
%attr(0500,root,root) /opt/kubeOS/scripts/create/rootfsCreate.sh
%attr(0600,root,root) /opt/kubeOS/scripts/00bootup/Global.cfg
%attr(0500,root,root) /opt/kubeOS/scripts/00bootup/module-setup.sh
%attr(0500,root,root) /opt/kubeOS/scripts/00bootup/mount.sh
%clean %clean
rm -rfv %{buildroot} rm -rfv %{buildroot}
%changelog %changelog
* Thu Dec 08 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-8
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fix usage does not print when an error occurs in the upgrade image creation
* Tue Nov 29 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-7
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:remove grub2 legacy install, add error handling for opstype and add entry for unit test in Makefile
* Sat Sep 03 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-6
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:add the configuration of /etc/resolv.conf and change the VM disk to gpt.
* Wed Aug 31 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-5
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:add the clearing of space before the upgrade and rectifying the rollback failure.
* Mon Aug 29 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-4
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fixed the issue of VMs images and add check of Global.cfg.
* Tue Aug 23 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-3
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fix the kbimg.sh exception and pxe installation
* Fri Aug 05 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-2
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:update to 1.0.2-2
* Tue Aug 02 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-8
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:update to 1.0.1-8
* Fri Dec 09 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-6 * Fri Dec 09 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-6
- Type:requirement - Type:requirement
- CVE:NA - CVE:NA

Binary file not shown.

BIN
v1.0.2.tar.gz Normal file

Binary file not shown.