-
Notifications
You must be signed in to change notification settings - Fork 308
[Driver] Enhancement for concurrency #1195
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
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,9 +85,14 @@ type VolumeDriver interface { | |
| ListPools() ([]*model.StoragePoolSpec, error) | ||
| } | ||
|
|
||
| var ( | ||
| OceanStorDriver = oceanstor.Driver{} | ||
| ) | ||
|
|
||
| // Init | ||
| func Init(resourceType string) VolumeDriver { | ||
| func Init(resourceType string) (VolumeDriver, error) { | ||
| var d VolumeDriver | ||
|
|
||
| switch resourceType { | ||
| case config.CinderDriverType: | ||
| d = &cinder.Driver{} | ||
|
|
@@ -102,7 +107,7 @@ func Init(resourceType string) VolumeDriver { | |
| d = &spectrumscale.Driver{} | ||
| break | ||
| case config.HuaweiOceanStorBlockDriverType: | ||
| d = &oceanstor.Driver{} | ||
| d = &OceanStorDriver | ||
| break | ||
| case config.HuaweiFusionStorageDriverType: | ||
| d = &fusionstorage.Driver{} | ||
|
|
@@ -119,12 +124,17 @@ func Init(resourceType string) VolumeDriver { | |
| d = &sample.Driver{} | ||
| break | ||
| } | ||
| d.Setup() | ||
| return d | ||
|
|
||
| err := d.Setup() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return d, nil | ||
| } | ||
|
|
||
| // Clean | ||
| func Clean(d VolumeDriver) VolumeDriver { | ||
| func Clean(d VolumeDriver) { | ||
| // Execute different clean operations according to the VolumeDriver type. | ||
| switch d.(type) { | ||
| case *cinder.Driver: | ||
|
|
@@ -136,7 +146,7 @@ func Clean(d VolumeDriver) VolumeDriver { | |
| case *spectrumscale.Driver: | ||
| break | ||
| case *oceanstor.Driver: | ||
| break | ||
| return // No need to clean anything for oceanstor | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happen, if i really mean to unset/clean the driver??
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oceanstor driver's unset operation just close the connection to back storage, cause we use the same global oceanstor driver for each call now, so there's no need to unset anymore. Instead, we want to keep the connection session active consistently.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| case *fusionstorage.Driver: | ||
| break | ||
| case *nimble.Driver: | ||
|
|
@@ -148,10 +158,9 @@ func Clean(d VolumeDriver) VolumeDriver { | |
| default: | ||
| break | ||
| } | ||
|
|
||
| d.Unset() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to handle Unset error also. I have seen you have handled the error in Setup()
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as the old code's implementation, I think the unset error is ignorable, so I didn't change here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| d = nil | ||
|
|
||
| return d | ||
| } | ||
|
|
||
| func CleanMetricDriver(d MetricDriver) MetricDriver { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any Specific reason to change this format of calling (drivername.Driver{}). I saw above is declared same as variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OceanStorDriver is defined as a global variable, so each time we call Init for Huawei OceanStor driver, we can get the same driver object, not create a new one as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This's also for the concurrency circumstance, because each oceanstor driver maintains a connect to OceanStor storage, if there are big concurrency invokes, the connection number may exceed the limit of OceanStor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok