KubeOS:fix bugs of checks in generate.sh and change module path

Signed-off-by: liyuanr <liyuanrong1@huawei.com>
This commit is contained in:
liyuanr 2021-11-11 06:59:13 +00:00
parent 7aef9d3345
commit 5753d7f7bf
2 changed files with 272 additions and 1 deletions

View File

@ -0,0 +1,264 @@
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

@ -2,10 +2,11 @@
Name: KubeOS Name: KubeOS
Version: 1.0.1 Version: 1.0.1
Release: 2 Release: 3
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
ExclusiveArch: x86_64 ExclusiveArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: make BuildRequires: make
@ -77,6 +78,12 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
rm -rfv %{buildroot} rm -rfv %{buildroot}
%changelog %changelog
* Thu Nov 11 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-3
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fix bugs of checks in generate.sh and change module path
* Fri Oct 30 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-2 * Fri Oct 30 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-2
- Type:requirement - Type:requirement
- CVE:NA - CVE:NA