eggo/0004-add-host-name-checker-add-bin-execute-permission.patch
zhangxiaoyu a7c766a98c upgrade to v0.9.4-2
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2021-11-26 09:40:50 +08:00

199 lines
6.3 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From ae822ab2b0fd07d33adb7c244e78f2fcd31e1c05 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 3 Nov 2021 15:16:09 +0800
Subject: [PATCH 04/12] add host name checker, add bin execute permission
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
cmd/checker.go | 6 ++++++
config/all_online_install.config | 1 +
config/openEuler.config | 8 ++++----
docs/configuration_file_description.md | 2 +-
pkg/utils/dependency/dependency.go | 19 +++++++++++++-----
pkg/utils/dependency/install.go | 27 ++++++++++++++------------
6 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/cmd/checker.go b/cmd/checker.go
index 4530f2b..9d1fda6 100644
--- a/cmd/checker.go
+++ b/cmd/checker.go
@@ -140,6 +140,12 @@ func checkHostconfig(h *HostConfig) error {
if h == nil {
return fmt.Errorf("empty hostconfig")
}
+ if h.Name == "" {
+ return fmt.Errorf("empty host name")
+ }
+ if errs := validation.IsDNS1123Subdomain(h.Name); len(errs) > 0 {
+ return fmt.Errorf("invalid host name: %v", errs)
+ }
if h.Ip == "" {
return fmt.Errorf("host: %s ip is null", h.Name)
}
diff --git a/config/all_online_install.config b/config/all_online_install.config
index dfc3ad4..c8a5eae 100644
--- a/config/all_online_install.config
+++ b/config/all_online_install.config
@@ -17,6 +17,7 @@ workers:
arch: arm64
runtime: iSulad
runtime-endpoint: unix:///var/run/isulad.sock
+pause-image: docker.io/mirrorgcrio/pause:3.2
open-ports:
worker:
- port: 111
diff --git a/config/openEuler.config b/config/openEuler.config
index 07acf9b..a69154b 100755
--- a/config/openEuler.config
+++ b/config/openEuler.config
@@ -1,17 +1,17 @@
-cluster-id: k8s-openEuler
+cluster-id: k8s-openeuler
username: root
password: "123456"
masters:
-- name: openEuler1
+- name: openeuler1
ip: 192.168.0.1
port: 22
arch: arm64
workers:
-- name: openEuler1
+- name: openeuler1
ip: 192.168.0.1
port: 22
arch: arm64
-- name: openEuler2
+- name: openeuler2
ip: 192.168.0.2
port: 22
arch: arm64
diff --git a/docs/configuration_file_description.md b/docs/configuration_file_description.md
index c169f49..4c84e5f 100644
--- a/docs/configuration_file_description.md
+++ b/docs/configuration_file_description.md
@@ -8,7 +8,7 @@ username: root // 需要部署k8s集群的机器的ssh登录
password: 123456 // 需要部署k8s集群的机器的ssh登录密码所有机器都需要使用同一个密码
private-key-path: ~/.ssh/pri.key // ssh免密登录的密钥可以替代password防止密码泄露
masters: // 配置master节点的列表建议每个master节点同时作为worker节点否则master节点可以无法直接访问pod
-- name: test0 // 该节点的名称为k8s集群看到的该节点的名称
+- name: test0 // 该节点的名称为k8s集群看到的该节点的名称名字需要符合RFC 1123 subdomain规范
ip: 192.168.0.1 // 该节点的ip地址
port: 22 // ssh登录的端口
arch: arm64 // 机器架构x86_64的填amd64
diff --git a/pkg/utils/dependency/dependency.go b/pkg/utils/dependency/dependency.go
index 3d0bf8f..9e6ac22 100644
--- a/pkg/utils/dependency/dependency.go
+++ b/pkg/utils/dependency/dependency.go
@@ -143,15 +143,23 @@ func (dd *dependencyDeb) Remove(r runner.Runner) error {
}
// install file and dir
-type dependencyFD struct {
- srcPath string
- software []*api.PackageConfig
+type dependencyFileDir struct {
+ executable bool
+ srcPath string
+ software []*api.PackageConfig
}
-func (df *dependencyFD) Install(r runner.Runner) error {
+func (df *dependencyFileDir) Install(r runner.Runner) error {
shell := `
#!/bin/bash
cd {{ .srcPath }}
+
+{{- if .executable }}
+{{- range $i, $v := .software }}
+chmod +x {{ $v.Name }}
+{{- end }}
+{{- end }}
+
{{- range $i, $v := .software }}
if [ ! -e {{ JoinPath $v.Dst $v.Name }} ]; then
mkdir -p {{ $v.Dst }} && cp -r {{ $v.Name }} {{ $v.Dst }}
@@ -161,6 +169,7 @@ fi
datastore := make(map[string]interface{})
datastore["srcPath"] = df.srcPath
datastore["software"] = df.software
+ datastore["executable"] = df.executable
shellStr, err := template.TemplateRender(shell, datastore)
if err != nil {
@@ -175,7 +184,7 @@ fi
return nil
}
-func (df *dependencyFD) Remove(r runner.Runner) error {
+func (df *dependencyFileDir) Remove(r runner.Runner) error {
var sb strings.Builder
sb.WriteString("sudo -E /bin/sh -c \"")
for _, s := range df.software {
diff --git a/pkg/utils/dependency/install.go b/pkg/utils/dependency/install.go
index 611c006..e2c0621 100644
--- a/pkg/utils/dependency/install.go
+++ b/pkg/utils/dependency/install.go
@@ -125,23 +125,26 @@ func installFD(r runner.Runner, bin, file, dir []*api.PackageConfig, hcf *api.Ho
dp := []dependency{}
if len(bin) != 0 {
- dp = append(dp, &dependencyFD{
- srcPath: path.Join(packagePath, constants.DefaultBinPath),
- software: bin,
+ dp = append(dp, &dependencyFileDir{
+ srcPath: path.Join(packagePath, constants.DefaultBinPath),
+ software: bin,
+ executable: true,
})
}
if len(file) != 0 {
- dp = append(dp, &dependencyFD{
- srcPath: path.Join(packagePath, constants.DefaultFilePath),
- software: file,
+ dp = append(dp, &dependencyFileDir{
+ srcPath: path.Join(packagePath, constants.DefaultFilePath),
+ software: file,
+ executable: false,
})
}
if len(dir) != 0 {
- dp = append(dp, &dependencyFD{
- srcPath: path.Join(packagePath, constants.DefaultDirPath),
- software: dir,
+ dp = append(dp, &dependencyFileDir{
+ srcPath: path.Join(packagePath, constants.DefaultDirPath),
+ software: dir,
+ executable: false,
})
}
@@ -233,19 +236,19 @@ func uninstallFD(r runner.Runner, bin, file, dir []*api.PackageConfig, hcf *api.
dp := []dependency{}
if len(bin) != 0 {
- dp = append(dp, &dependencyFD{
+ dp = append(dp, &dependencyFileDir{
software: bin,
})
}
if len(file) != 0 {
- dp = append(dp, &dependencyFD{
+ dp = append(dp, &dependencyFileDir{
software: file,
})
}
if len(dir) != 0 {
- dp = append(dp, &dependencyFD{
+ dp = append(dp, &dependencyFileDir{
software: dir,
})
}
--
2.25.1