Skip to content

Commit

Permalink
Merge pull request #214 from qiangzii/master
Browse files Browse the repository at this point in the history
describe snapshot by name rather than search word;
  • Loading branch information
liangcd authored Apr 14, 2023
2 parents b292a83 + 0e9aa74 commit c16f035
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 22 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.PHONY: all disk

DISK_IMAGE_NAME=csiplugin/csi-qingcloud
DISK_VERSION=v1.3.7
DISK_VERSION=v1.3.8
ROOT_PATH=$(pwd)
PACKAGE_LIST=./cmd/... ./pkg/...

Expand Down Expand Up @@ -55,3 +55,6 @@ sanity-test:
clean:
go clean -r -x ./...
rm -rf ./_output

push:
docker buildx build -t ${DISK_IMAGE_NAME}:${DISK_VERSION} --platform=linux/amd64,linux/arm64 -f deploy/disk/docker/Dockerfile . --push
2 changes: 1 addition & 1 deletion deploy/disk/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.16.7-alpine as builder
FROM golang:1.19-alpine as builder
WORKDIR /qingcloud-csi
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=vendor -ldflags "-s -w" -o _output/qingcloud-disk-csi-driver ./cmd/disk
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.6.1
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/yunify/qingcloud-sdk-go v0.0.0-20220919105434-86f5ff120dad
github.com/yunify/qingcloud-sdk-go v0.0.0-20230406022709-e32d107bcab7
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yunify/qingcloud-sdk-go v0.0.0-20220919105434-86f5ff120dad h1:7ijSqtn0cvjn7okHFORUf3QEEDXCOUGlXb0uXg0GZJ4=
github.com/yunify/qingcloud-sdk-go v0.0.0-20220919105434-86f5ff120dad/go.mod h1:OfwXDPSOiv0Si+1iyH8+JDPPApt73Em03muEf9iKM+c=
github.com/yunify/qingcloud-sdk-go v0.0.0-20230406022709-e32d107bcab7 h1:I/3xAf2tlng0W2oGoubMPd6QvsoUAb4VvQDiY7puwJo=
github.com/yunify/qingcloud-sdk-go v0.0.0-20230406022709-e32d107bcab7/go.mod h1:OfwXDPSOiv0Si+1iyH8+JDPPApt73Em03muEf9iKM+c=
go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v0.0.0-20180122172545-ddea229ff1df/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v0.0.0-20180814183419-67bc79d13d15/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
Expand Down
34 changes: 20 additions & 14 deletions pkg/cloud/qingcloud_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func NewQingCloudManagerFromFile(filePath string) (*qingCloudManager, error) {

// Find snapshot by snapshot id
// Return: nil, nil: not found snapshot
// snapshot, nil: found snapshot
// nil, error: internal error
//
// snapshot, nil: found snapshot
// nil, error: internal error
func (cm *qingCloudManager) FindSnapshot(id string) (snapshot *qcservice.Snapshot, err error) {
verboseMode := EnableDescribeSnapshotVerboseMode
// Set DescribeSnapshot input
Expand Down Expand Up @@ -121,17 +122,18 @@ func (cm *qingCloudManager) FindSnapshot(id string) (snapshot *qcservice.Snapsho
// In Kubernetes, the CO will set a unique PV name.
// CSI driver take the PV name as a snapshot name.
// Return: nil, nil: not found snapshots
// snapshots, nil: found snapshot
// nil, error: internal error
//
// snapshots, nil: found snapshot
// nil, error: internal error
func (cm *qingCloudManager) FindSnapshotByName(name string) (snapshot *qcservice.Snapshot, err error) {
if len(name) == 0 {
return nil, nil
}
verboseMode := EnableDescribeSnapshotVerboseMode
// Set input arguments
input := &qcservice.DescribeSnapshotsInput{
SearchWord: &name,
Verbose: &verboseMode,
SnapshotName: &name,
Verbose: &verboseMode,
}
// Call DescribeSnapshot
output, err := cm.snapshotService.DescribeSnapshots(input)
Expand Down Expand Up @@ -215,8 +217,9 @@ func (sm *qingCloudManager) DeleteSnapshot(snapshotId string) error {

// Find volume by volume ID
// Return: nil, nil: not found volumes
// volume, nil: found volume
// nil, error: internal error
//
// volume, nil: found volume
// nil, error: internal error
func (cm *qingCloudManager) FindVolume(id string) (volInfo *qcservice.Volume, err error) {
// Set DescribeVolumes input
input := &qcservice.DescribeVolumesInput{
Expand Down Expand Up @@ -259,8 +262,9 @@ func (cm *qingCloudManager) FindVolume(id string) (volInfo *qcservice.Volume, er
// In Kubernetes, the CO will set a unique PV name.
// CSI driver take the PV name as a volume name.
// Return: nil, nil: not found volumes
// volumes, nil: found volume
// nil, error: internal error
//
// volumes, nil: found volume
// nil, error: internal error
func (cm *qingCloudManager) FindVolumeByName(name string) (volume *qcservice.Volume, err error) {
if len(name) == 0 {
return nil, nil
Expand Down Expand Up @@ -499,8 +503,9 @@ func (cm *qingCloudManager) ResizeVolume(volumeId string, requestSize int) error

// CloneVolume clones a volume
// Return:
// volume id, nil: succeed to clone volume and return volume id
// nil, error: failed to clone volume
//
// volume id, nil: succeed to clone volume and return volume id
// nil, error: failed to clone volume
func (qm *qingCloudManager) CloneVolume(volName string, volType int, srcVolId string, zone string) (newVolId string,
err error) {
// 0. Set CreateVolume args
Expand Down Expand Up @@ -536,8 +541,9 @@ func (qm *qingCloudManager) CloneVolume(volName string, volType int, srcVolId st

// Find instance by instance ID
// Return: nil, nil: not found instance
// instance, nil: found instance
// nil, error: internal error
//
// instance, nil: found instance
// nil, error: internal error
func (cm *qingCloudManager) FindInstance(id string) (instance *qcservice.Instance, err error) {
seeAppCluster := EnableDescribeInstanceAppCluster
verboseMode := EnableDescribeInstanceVerboseMode
Expand Down
10 changes: 9 additions & 1 deletion vendor/github.com/yunify/qingcloud-sdk-go/request/unpacker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/yunify/qingcloud-sdk-go/service/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/yunify/qingcloud-sdk-go/service/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ github.com/modern-go/reflect2
## explicit
# github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus
# github.com/yunify/qingcloud-sdk-go v0.0.0-20220919105434-86f5ff120dad
# github.com/yunify/qingcloud-sdk-go v0.0.0-20230406022709-e32d107bcab7
## explicit
github.com/yunify/qingcloud-sdk-go/client
github.com/yunify/qingcloud-sdk-go/config
Expand Down

0 comments on commit c16f035

Please sign in to comment.