Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update basicsystem info usage for probe to reduce authentication calls #224

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/dell/gocsi v1.11.0
github.com/dell/gofsutil v1.16.1
github.com/dell/goiscsi v1.9.0
github.com/dell/gounity v1.18.0
github.com/dell/gounity v1.18.1-0.20240814125025-10cd8681b981
github.com/fsnotify/fsnotify v1.4.9
github.com/kubernetes-csi/csi-lib-utils v0.7.0
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ github.com/dell/goiscsi v1.9.0 h1:VvMHbAO4vk80oc/TAbQPYlxysscCqVBW78GyPoUxgik=
github.com/dell/goiscsi v1.9.0/go.mod h1:NI/W/0O1UrMW2zVdMxy4z395Jn0r7utH6RQDFSZiFyQ=
github.com/dell/gonvme v1.8.1 h1:46M5lPqj7+Xjen+qxooRN9cx/+uJG4xtK9TpwduWDgE=
github.com/dell/gonvme v1.8.1/go.mod h1:ajbuF+fswq+ty2tRTG5FN4ecIMJsG7aDu/bkMynTKAs=
github.com/dell/gounity v1.18.0 h1:vE8nS2bMt6SEN5KLFlUysoxbtt4bQtOGnwFOBFAMEq8=
github.com/dell/gounity v1.18.0/go.mod h1:pf6iJHk4mVPqb6/O+fJNUaRek65mzyCaiwlyULViBPc=
github.com/dell/gounity v1.18.1-0.20240814125025-10cd8681b981 h1:9ZjXo9YaFwSmoFu4GZIj0hgviqLpoEr3ZhrYOuTJH7s=
github.com/dell/gounity v1.18.1-0.20240814125025-10cd8681b981/go.mod h1:pf6iJHk4mVPqb6/O+fJNUaRek65mzyCaiwlyULViBPc=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
Expand Down
45 changes: 26 additions & 19 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,15 @@ func (s *service) syncDriverSecret(ctx context.Context) error {
if err != nil {
return fmt.Errorf("unable to initialize the Unity client [%v]", err)
}
err = unityClient.Authenticate(ctx, &gounity.ConfigConnect{
Endpoint: endpoint,
Username: secret.Username,
Password: secret.Password,
Insecure: insecure,
})
if err != nil {
log.Errorf("unable to authenticate [%v]", err)
}
secret.UnityClient = unityClient

copyStorage := StorageArrayConfig{}
Expand Down Expand Up @@ -794,28 +803,26 @@ func (s *service) requireProbe(ctx context.Context, arrayID string) error {
func singleArrayProbe(ctx context.Context, probeType string, array *StorageArrayConfig) error {
rid, log := utils.GetRunidAndLogger(ctx)
ctx, log = setArrayIDContext(ctx, array.ArrayID)
if array.UnityClient.GetToken() == "" {
err := array.UnityClient.Authenticate(ctx, &gounity.ConfigConnect{
Endpoint: array.Endpoint,
Username: array.Username,
Password: array.Password,
Insecure: *array.SkipCertificateValidation,
})
if err != nil {
log.Errorf("Unity authentication failed for array %s error: %v", array.ArrayID, err)
if e, ok := status.FromError(err); ok {
if e.Code() == codes.Unauthenticated {
array.IsProbeSuccess = false
return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Unable to login to Unity. Error: %s", err.Error()))
}

err := array.UnityClient.BasicSystemInfo(ctx, &gounity.ConfigConnect{
Endpoint: array.Endpoint,
Username: array.Username,
Password: array.Password,
Insecure: *array.SkipCertificateValidation,
})
if err != nil {
log.Errorf("Unity probe failed for array %s error: %v", array.ArrayID, err)
if e, ok := status.FromError(err); ok {
if e.Code() == codes.Unauthenticated {
array.IsProbeSuccess = false
return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Unable Get basic system info from Unity. Error: %s", err.Error()))
}
array.IsProbeSuccess = false
return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Unable to login to Unity. Verify hostname/IP Address of unity. Error: %s", err.Error()))
}
array.IsProbeSuccess = true
log.Debugf("%s Probe Success", probeType)
return nil
array.IsProbeSuccess = false
return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Unable Get basic system info from Unity. Verify hostname/IP Address of unity. Error: %s", err.Error()))
}
array.IsProbeSuccess = true
log.Debugf("%s Probe Success", probeType)
return nil
}

Expand Down
Loading