Skip to content

Commit

Permalink
feat: Update to seagate-exos-x-api-go version 2.3.0 for controller fa…
Browse files Browse the repository at this point in the history
…ilover

Integrate the new api lib feature to allow controller failover/retry.
Accept multiple IP addresses in the API storage class
  • Loading branch information
David-T-White committed Jun 21, 2024
1 parent 180713f commit 50a4711
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions example/secret-example1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ metadata:
type: Opaque
data:
apiAddress: aHR0cDovLzxpcGFkZHJlc3M+ # base64 encoded api address 'http://<ipaddress>'
apiAddressB: aHR0cDovLzxpcGFkZHJlc3M+ # Optional second base64 encoded api address 'http://<ipaddress>'
username: dXNlcm5hbWU= # base64 encoded 'username'
password: cGFzc3dvcmQ= # base64 encoded 'password'
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/Seagate/csi-lib-iscsi v1.1.0
github.com/Seagate/csi-lib-sas v1.0.2
github.com/Seagate/seagate-exos-x-api-go/v2 v2.2.0
github.com/Seagate/seagate-exos-x-api-go/v2 v2.3.0
github.com/container-storage-interface/spec v1.8.0
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.3.1
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/Seagate/csi-lib-sas v1.0.2 h1:rR/tPmQMYt7nwor5YC1LInxrYvueLjCxFKHxkh0
github.com/Seagate/csi-lib-sas v1.0.2/go.mod h1:lX/OnO0sLm4vXCFwsPADyzZxSFkmXv5t+WleiYNkN8U=
github.com/Seagate/seagate-exos-x-api-go/v2 v2.2.0 h1:dFd0Oqpzg1s2vU0FDs+a4aMYtGnwl7tQVqqDu9Gzt3I=
github.com/Seagate/seagate-exos-x-api-go/v2 v2.2.0/go.mod h1:ldU5jMQEpfOhPZlx1zYkDN7fIaFCGhD4ZB5GFQiYgvI=
github.com/Seagate/seagate-exos-x-api-go/v2 v2.3.0 h1:dWtb8ZoHfqZKzUnInloRq2VxVQ47hx3+uxlLiQIYvOA=
github.com/Seagate/seagate-exos-x-api-go/v2 v2.3.0/go.mod h1:ldU5jMQEpfOhPZlx1zYkDN7fIaFCGhD4ZB5GFQiYgvI=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand All @@ -30,6 +32,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -57,6 +60,9 @@ github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand All @@ -68,6 +74,9 @@ github.com/kubernetes-csi/csi-test v0.0.0-20191016154743-6931aedb3df0 h1:ecL3Aaj
github.com/kubernetes-csi/csi-test v0.0.0-20191016154743-6931aedb3df0/go.mod h1:0JHYXISG0wKK4OoXtuyT6CkVyEqmHme4k5VzZphSB3s=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs=
github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
Expand Down
1 change: 1 addition & 0 deletions pkg/common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
FsTypeConfigKey = "fsType"
PoolConfigKey = "pool"
APIAddressConfigKey = "apiAddress"
APIAddressBConfigKey = "apiAddressB"
UsernameSecretKey = "username"
PasswordSecretKey = "password"
CHAPUsernameKey = "CHAPusername"
Expand Down
12 changes: 7 additions & 5 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func (controller *Controller) configureClient(credentials map[string]string) err
username := string(credentials[common.UsernameSecretKey])
password := string(credentials[common.PasswordSecretKey])
apiAddr := string(credentials[common.APIAddressConfigKey])
secondaryapiAddr := string(credentials[common.APIAddressBConfigKey])

if len(username) == 0 {
return status.Error(codes.InvalidArgument, fmt.Sprintf("(%s) is missing from secrets", common.UsernameSecretKey))
Expand All @@ -243,17 +244,18 @@ func (controller *Controller) configureClient(credentials map[string]string) err
return status.Error(codes.InvalidArgument, fmt.Sprintf("(%s) is missing from secrets", common.PasswordSecretKey))
}

// at least one api address must be defined, the secondary address is an optional parameter
if len(apiAddr) == 0 {
return status.Error(codes.InvalidArgument, fmt.Sprintf("(%s) is missing from secrets", common.APIAddressConfigKey))
}

klog.InfoS("using API", "address", apiAddr)
if controller.client.SessionValid(apiAddr, username) {
return nil
apiAddresses := []string{apiAddr}
if secondaryapiAddr != "" {
apiAddresses = append(apiAddresses, secondaryapiAddr)
}
klog.InfoS("using API", "addresses", apiAddresses)

//these stored credentials are still used for the session valid check
controller.client.StoreCredentials(apiAddr, "", username, password)
controller.client.StoreCredentials(apiAddresses, "", username, password)

ctx := context.WithValue(context.Background(), client.ContextBasicAuth, client.BasicAuth{
UserName: username,
Expand Down

0 comments on commit 50a4711

Please sign in to comment.