Skip to content

Commit

Permalink
Update V4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cabbetlong committed Jul 28, 2024
1 parent 4e1466d commit 2af513d
Show file tree
Hide file tree
Showing 120 changed files with 11,955 additions and 2,317 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

[Releases](https://github.com/Huawei/eSDK_K8S_Plugin/releases)

## Changes since v4.3.0

- Support Kubernetes 1.30
- Support OceanStor 6.1.8
- Support OceanStor Dorado 6.1.8
- Support Red Hat CoreOS 4.15 x86_64
- Support OpenEuler 22.03 LTS SP1 x86_64
- The new feature Modify Volume allows a normal PV to be changed to a HyperMetro PV
- Create VolumeSnapshot and Clone Persistent Volume support HyperMetro PV

## Changes since v4.2.0

- Support UltraPath 31.2.1/NVMe over RoCE on Rocky Linux 8.6 X86_64
Expand Down
14 changes: 10 additions & 4 deletions CI/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fi
package_name="eSDK_Huawei_Storage_${RELEASE_VER}_Kubernetes_CSI_Plugin_V${VER}_${PLATFORM}_64"

cd eSDK_Enterprise_Storage_Kubernetes
go mod tidy || go mod tidy
make -f Makefile RELEASE_VER=$1 VER=$2 PLATFORM=$3

# -------------------------------------------------------------------------------
Expand All @@ -59,26 +60,31 @@ rm -rf build_dir
rm -f ./huawei-csi
rm -f ./storage-backend-controller
rm -f ./storage-backend-sidecar
rm -f ./huawei-csi-extender
unzip -d build_dir -q ${package_name}.zip
cp build_dir/${package_name}/bin/huawei-csi ./
cp build_dir/${package_name}/bin/storage-backend-controller ./
cp build_dir/${package_name}/bin/storage-backend-sidecar ./
mv build_dir/${package_name}/bin/huawei-csi ./
mv build_dir/${package_name}/bin/storage-backend-controller ./
mv build_dir/${package_name}/bin/storage-backend-sidecar ./
mv build_dir/${package_name}/bin/huawei-csi-extender ./

docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target huawei-csi-driver -f Dockerfile -t huawei-csi:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target storage-backend-controller -f Dockerfile -t storage-backend-controller:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target storage-backend-sidecar -f Dockerfile -t storage-backend-sidecar:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target huawei-csi-extender -f Dockerfile -t huawei-csi-extender:${VER} .


plat=$(echo ${PLATFORM}|tr 'A-Z' 'a-z')
docker save huawei-csi:${VER} -o huawei-csi-v${VER}-${plat}.tar
docker save storage-backend-controller:${VER} -o storage-backend-controller-v${VER}-${plat}.tar
docker save storage-backend-sidecar:${VER} -o storage-backend-sidecar-v${VER}-${plat}.tar
docker save huawei-csi-extender:${VER} -o huawei-csi-extender-v${VER}-${plat}.tar


mkdir build_dir/${package_name}/image
mv huawei-csi-v${VER}-${plat}.tar build_dir/${package_name}/image
mv storage-backend-controller-v${VER}-${plat}.tar build_dir/${package_name}/image
mv storage-backend-sidecar-v${VER}-${plat}.tar build_dir/${package_name}/image
mv huawei-csi-extender-v${VER}-${plat}.tar build_dir/${package_name}/image
# -------------------------------------------------------------------------------

rm -rf ${package_name}.zip
Expand All @@ -92,4 +98,4 @@ sh esdk_ci/ci/build_product_signature.sh $(pwd)/sign
mkdir cms
mv sign/*.cms .
sh esdk_ci/ci/build_product_signature_hwp7s.sh $(pwd)/sign
mv sign/* .
mv sign/* ${WORKSPACE}/eSDK_Enterprise_Storage_Kubernetes
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ LABEL description="Storage Backend Sidecar"
ARG binary=./storage-backend-sidecar
COPY ${binary} storage-backend-sidecar
ENTRYPOINT ["/storage-backend-sidecar"]


FROM gcr.io/distroless/base:latest as huawei-csi-extender
LABEL version="${VERSION}"
LABEL maintainers="Huawei eSDK CSI development team"
LABEL description="Huawei CSI Extender"

ARG binary=./huawei-csi-extender
COPY ${binary} huawei-csi-extender
ENTRYPOINT ["/huawei-csi-extender"]
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ BUILD:
${env} go build -o ./${PACKAGE}/bin/huawei-csi ${flag} ./csi
${env} go build -o ./${PACKAGE}/bin/storage-backend-controller ${flag} ./cmd/storage-backend-controller
${env} go build -o ./${PACKAGE}/bin/storage-backend-sidecar ${flag} ./cmd/storage-backend-sidecar
${env} go build -o ./${PACKAGE}/bin/huawei-csi-extender ${flag} ./cmd/huawei-csi-extender
${env} go build -o ./${PACKAGE}/bin/oceanctl ${flag} ./cli

COPY_FILE:
Expand All @@ -58,9 +59,6 @@ COPY_FILE:
cp -r ./manual/* ./${PACKAGE}/manual/
cp -r ./helm/esdk/crds ./${PACKAGE}/manual/esdk/crds

mkdir -p ./${PACKAGE}/tools
cp -r ./tools/imageUpload/* ./${PACKAGE}/tools

PACK:
zip -r ${PACKAGE}.zip ./${PACKAGE}
rm -rf ./${PACKAGE}
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,31 @@ rm -rf build_dir
rm -f ./huawei-csi
rm -f ./storage-backend-controller
rm -f ./storage-backend-sidecar
rm -f ./huawei-csi-extender
unzip -d build_dir -q ${package_name}.zip
mv build_dir/${package_name}/bin/huawei-csi ./
mv build_dir/${package_name}/bin/storage-backend-controller ./
mv build_dir/${package_name}/bin/storage-backend-sidecar ./
mv build_dir/${package_name}/bin/huawei-csi-extender ./

docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target huawei-csi-driver -f Dockerfile -t huawei-csi:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target storage-backend-controller -f Dockerfile -t storage-backend-controller:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target storage-backend-sidecar -f Dockerfile -t storage-backend-sidecar:${VER} .
docker build ${BUILD_FLAG} --build-arg VERSION=${VER} --target huawei-csi-extender -f Dockerfile -t huawei-csi-extender:${VER} .

echo "Start to save image file"
plat=$(echo ${PLATFORM}|tr 'A-Z' 'a-z')
docker save huawei-csi:${VER} -o huawei-csi-v${VER}-${plat}.tar
docker save storage-backend-controller:${VER} -o storage-backend-controller-v${VER}-${plat}.tar
docker save storage-backend-sidecar:${VER} -o storage-backend-sidecar-v${VER}-${plat}.tar
docker save huawei-csi-extender:${VER} -o huawei-csi-extender-v${VER}-${plat}.tar

echo "Start to move image file"
mkdir build_dir/${package_name}/image
mv huawei-csi-v${VER}-${plat}.tar build_dir/${package_name}/image
mv storage-backend-controller-v${VER}-${plat}.tar build_dir/${package_name}/image
mv storage-backend-sidecar-v${VER}-${plat}.tar build_dir/${package_name}/image
mv huawei-csi-extender-v${VER}-${plat}.tar build_dir/${package_name}/image

echo "Start to packing files"
rm -rf ${package_name}.zip
Expand Down
7 changes: 6 additions & 1 deletion cli/cmd/collect_logs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@ func init() {
WithNameSpace(true).
WithAllNodes().
WithNodeName().
WithMaxThreads().
WithParent(collectCmd)
}

Expand All @@ -44,6 +45,9 @@ var (
# Collect logs of all nodes in specified namespace
oceanctl collect logs -n <namespace> -a
# Collect logs of all nodes in specified namespace with a maximum of 50 nodes collected at the same time
oceanctl collect logs -n <namespace> -a --threads-max=50
# Collect logs of specified node in specified namespace
oceanctl collect logs -n <namespace> -N <node> -a`)
)
Expand All @@ -62,6 +66,7 @@ func runCollectLogs() error {
AllNodes(config.IsAllNodes).
NodeName(config.NodeName).
NamespaceParam(config.Namespace).
MaxNodeThreads(config.MaxNodeThreads).
Build()

return resources.NewLogs(res).Collect()
Expand Down
9 changes: 8 additions & 1 deletion cli/cmd/options/flag_options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -140,3 +140,10 @@ func (b *FlagsOptions) WithLogDir() *FlagsOptions {
"directory for printing log files.")
return b
}

// WithMaxThreads This function will add max node threads num
func (b *FlagsOptions) WithMaxThreads() *FlagsOptions {
b.cmd.PersistentFlags().IntVarP(&config.MaxNodeThreads, "threads-max", "", config.DefaultMaxNodeThreads,
"set maximum number[1~1000] of threads for nodes to be collected.")
return b
}
10 changes: 8 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@ import (

const (
// CliVersion oceanctl version
CliVersion = "v4.3.0"
CliVersion = "v4.4.0"

// DefaultMaxClientThreads default max client threads
DefaultMaxClientThreads = "30"
Expand Down Expand Up @@ -57,6 +57,9 @@ const (

// DefaultLogDir default log dir
DefaultLogDir = "/var/log/huawei"

// DefaultMaxNodeThreads default max Node Threads num
DefaultMaxNodeThreads = 50
)

var (
Expand Down Expand Up @@ -103,4 +106,7 @@ var (

// LogDir the value of log-dir flag, set by options.WithLogDir()
LogDir string

// MaxNodeThreads the value of threads-max flag, set by options.WithMaxThreads()
MaxNodeThreads int
)
77 changes: 23 additions & 54 deletions cli/helper/goroutine_limit.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,78 +18,47 @@ package helper

import (
"sync"
"sync/atomic"

"huawei-csi-driver/utils/log"
)

// GlobalGoroutineLimit Configure the total goroutine limit
// GlobalGoroutineLimit is used to limit concurrency of goroutine
type GlobalGoroutineLimit struct {
localNum int32
maxGoroutineNum int32
limit int32
allCond []*sync.Cond
}

// LocalGoroutineLimit Record local goroutine limit under total limit
type LocalGoroutineLimit struct {
cond *sync.Cond
currentGoroutineNum int32
limit *int32
sem chan struct{}
wg *sync.WaitGroup
}

// NewGlobalGoroutineLimit initialize a GlobalGoroutineLimit instance
func NewGlobalGoroutineLimit(maxGoroutineNum int32) *GlobalGoroutineLimit {
func NewGlobalGoroutineLimit(maxGoroutineNum int) *GlobalGoroutineLimit {
res := &GlobalGoroutineLimit{
allCond: make([]*sync.Cond, maxGoroutineNum),
maxGoroutineNum: maxGoroutineNum,
limit: maxGoroutineNum,
}
return res
}

// NewLocalGoroutineLimit initialize a LocalGoroutineLimit instance
func NewLocalGoroutineLimit(global *GlobalGoroutineLimit) *LocalGoroutineLimit {
res := &LocalGoroutineLimit{
limit: &global.limit,
cond: sync.NewCond(&sync.Mutex{}),
sem: make(chan struct{}, maxGoroutineNum),
wg: &sync.WaitGroup{},
}
atomic.AddInt32(&global.localNum, 1)
atomic.StoreInt32(&global.limit, global.maxGoroutineNum/global.localNum)
global.allCond = append(global.allCond, res.cond)
return res
}

// Do create a Goroutine to Execution function
func (l *LocalGoroutineLimit) Do(f func()) {
l.cond.L.Lock()
for atomic.LoadInt32(&l.currentGoroutineNum) >= atomic.LoadInt32(l.limit) {
l.cond.Wait()
}
l.cond.L.Unlock()
atomic.AddInt32(&l.currentGoroutineNum, 1)
// HandleWork handle the work func with limit
func (n *GlobalGoroutineLimit) HandleWork(work func()) {
go func() {
n.sem <- struct{}{}
defer func() {
if e := recover(); e != nil {
log.Errorf("an error occurred when executing the sub-goroutine, error: %v", e)
log.Errorf("an error occurred when executing the work goroutine, error: %v", e)
}
atomic.AddInt32(&l.currentGoroutineNum, -1)
l.cond.Signal()

<-n.sem
n.wg.Done()
}()
f()
work()
}()
}

// Update LocalGoroutine number to Decrease the limit per LocalGoroutine
func (g *GlobalGoroutineLimit) Update() {
atomic.AddInt32(&g.localNum, -1)
if atomic.LoadInt32(&g.localNum) == 0 {
return
}
atomic.StoreInt32(&g.limit, g.maxGoroutineNum/atomic.LoadInt32(&g.localNum))
for _, cond := range g.allCond {
if cond != nil {
cond.Signal()
}
}
// AddWork add the work num for wait
func (n *GlobalGoroutineLimit) AddWork(num int) {
n.wg.Add(num)
}

// Wait wait all works done
func (n *GlobalGoroutineLimit) Wait() {
n.wg.Wait()
}
18 changes: 5 additions & 13 deletions cli/resources/file_logs_factory.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,16 +25,14 @@ import (
"strings"
"time"

corev1 "k8s.io/api/core/v1"

"huawei-csi-driver/cli/config"
"huawei-csi-driver/cli/helper"
"huawei-csi-driver/utils/log"
)

// FileLogsCollect is the interface to collect file logs.
type FileLogsCollect interface {
GetFileLogs(namespace, podName string, container *corev1.Container) (err error)
GetFileLogs(namespace, podName, nodeName, fileLogPath string) (err error)
GetHostInformation(namespace, containerName, nodeName, podName string) error
CopyToLocal(namespace, nodeName, podName, containerName string) error
}
Expand All @@ -45,7 +43,6 @@ type BaseFileLogsCollect struct{}
// FileLogsCollector collect specific file logs.
type FileLogsCollector struct {
BaseFileLogsCollect
fileLogPath string
}

// PodType defines the type of pod.
Expand Down Expand Up @@ -163,18 +160,13 @@ func (b *BaseFileLogsCollect) GetHostInformation(namespace, containerName, nodeN
}

// GetFileLogs get the file log of a specified node.
func (c *FileLogsCollector) GetFileLogs(namespace, podName string, container *corev1.Container) (err error) {
if c.fileLogPath, err = getContainerFileLogPaths(container); err != nil {
log.Errorf("get container file Log paths failed, error: %v", err)
return
}

if err = c.getContainerFileLogs(namespace, podName, container.Name, c.fileLogPath); err != nil {
func (c *FileLogsCollector) GetFileLogs(namespace, podName, containerName, fileLogPath string) (err error) {
if err = c.getContainerFileLogs(namespace, podName, containerName, fileLogPath); err != nil {
log.Errorf("get container file logs failed, error: %v", err)
return
}

if err = c.compressLogsInContainer(namespace, podName, container.Name); err != nil {
if err = c.compressLogsInContainer(namespace, podName, containerName); err != nil {
log.Errorf("compress logs in container failed, error: %v", err)
}
return
Expand Down
Loading

0 comments on commit 2af513d

Please sign in to comment.