-
Notifications
You must be signed in to change notification settings - Fork 95
Add compile support of new plugin/driver "vsphere-shared" #1574
Conversation
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.
It's a big change so I did not get all the details reviewed but all in all it looks good to me.
A few comments/requests inline.
Makefile
Outdated
@@ -42,6 +42,11 @@ build-all: dockerized-build-ui | |||
$(MAKE) --directory=client_plugin $@ | |||
$(MAKE) --directory=plugin_dockerbuild all | |||
|
|||
# build shared plugin | |||
build-shared: dockerized-build-ui | |||
$(MAKE) --directory=client_plugin dockerbuild-shared |
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.
its generally a good idea to add
) | ||
|
||
// VolumeDriver - vsphere shared plugin volume driver struct | ||
type CommonUtilDriver struct { |
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.
the name looks redundant. commonutilsdriver.CommonUtilsDriver
? And why its "commonUtils" not simply driver or pluginDriver ?
d.refCounts.Init(d, mountDir, cfg.Driver) | ||
d.mountIDtoName = make(map[string]string) | ||
|
||
d.utils = &commonUtilDriver.CommonUtilDriver{ |
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.
yeah, that's what I meant. THis looks slightly redundant
os.Exit(1) | ||
} | ||
|
||
if reflect.ValueOf(driver).IsNil() == true { |
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.
so if driver == Nil
does not work ?
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.
Did some googling and it seems we cannot compare an interface with nil.
And here driver is an interface.
Although I tried to change the code to if driver == nil
, compile still works.
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.
:-(
@@ -21,7 +21,7 @@ | |||
"Options": ["rbind"] | |||
}, | |||
{ | |||
"Description" : "Location to look for config file (/etc/docker-volume-vsphere.conf)", | |||
"Description" : "Location to look for config file (/etc/BINARY.conf)", |
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.
I strongly recommend using some pattern like %BINARY% to separate from comments etc.
Or better , try using golang template module
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.
Hmmm I am not sure how to use golang template here.
We don't have any go code. This is where we build the docker plugins.
So it's the script world...
It might be an overkill to add and compile some go code here in order to replace texts only :)
Let me add the pattern thing instead.
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.
Agreed
New plugin: client_plugin/shared_plugin New driver: client_plugin/drivers/shared To build the new plugin: make shared-all Plugin is pushed into: [DOCKER_HUB_REPO]/vsphere-shared:[VERSION_TAG][EXTRA_TAG] Functions in the new shared_driver are to be implemented.
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.
some minor comments.
@@ -42,6 +42,11 @@ build-all: dockerized-build-ui | |||
$(MAKE) --directory=client_plugin $@ | |||
$(MAKE) --directory=plugin_dockerbuild all | |||
|
|||
# build shared plugin | |||
build-shared: dockerized-build-ui |
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.
I guess we don't need to invoke dockerized-build-ui
anymore, can you please confirm with @msterin ?
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package shared |
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.
golang naming convention doesn't recommend _
in filename ..shared_driver.go
.. it is better to avoid using _
.. how aboutsharedvolume.go
?
As you are proposing new files I would suggest to correct the naming.
one more thing, package level comment should be above L15 .. that means before package xxx
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.
Hmmm I know that the golang naming convention doesn't recommend _
in package name. But I don't think there is a convention that doesn't recommend _
in filename.
I saw _
in filenames almost everywhere in the codebase :)
In vDVS codebase we already have:
client_plugin/utils/plugin_utils/plugin_utils.go
client_plugin/vmdk_plugin/sanity_test.go
client_plugin/drivers/vmdk/vmdk_driver.go
....
I don't think you ignore them on purpose before? ;)
Also please see my comment below.
Even golang's source code has _
in their filenames :)
|
||
package utils | ||
|
||
// |
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.
- Package level comment should be above L15 .. that means before
package xxx
- file name should be corrected too
Reference: "By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps."
Generally, file names follow the same convention as package names (https://golang.org/doc/effective_go.html#package-names)
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.
Same as the comment above...
I don't think filename need to follow this rule...
|
||
package main | ||
|
||
// A vSphere Shared Docker Data Volume plugin - main |
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.
need to move above L17
@@ -54,7 +54,8 @@ EXTRA_TAG ?= -dev | |||
PLUGIN_TAG := $(VERSION_TAG)$(EXTRA_TAG) | |||
|
|||
# plugin name - used as a base for full plugin name and container for extracting rootfs | |||
PLUGIN_NAME=$(DOCKER_HUB_REPO)/docker-volume-vsphere | |||
PLUGIN_NAME ?= $(DOCKER_HUB_REPO)/docker-volume-vsphere |
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.
curious to know here .. ?=
why is this change?
- is it passed or set?
- don't we need for L58?
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.
?= indicates to set the variable only if it's not set/doesn't have a value.
This change is because of we will recursively call the Makefile for the shared plugin, to avoid duplicate Makefile code.
See Line 67 in the new plugin_dockerbuild/Makefile:
shared-clean:
PLUGIN_NAME=$(SHARED_PLUGIN_NAME) BINARY=$(SHARED_BINARY) $(MAKE) clean
L58 doesn't need ?=
because there is no recursively setting of SHARED_PLUGIN_NAME.
// DefaultVMDKPluginLogPath is the default location of log (trace) file | ||
DefaultVMDKPluginLogPath = "/var/log/docker-volume-vsphere.log" | ||
// DefaultSharedPluginConfigPath is the default location of Log configuration file for shared plugin | ||
DefaultSharedPluginConfigPath = "/etc/vsphere-shared.conf" |
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.
Haven't come across any document file .. would like to make sure to document this newly introduced conf/log file location. will it be in the following PR?
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.
Yes. We will have readme for the new plugin. And it will be documented there.
"github.com/docker/go-plugins-helpers/volume" | ||
"github.com/vmware/docker-volume-vsphere/client_plugin/drivers/shared" | ||
"github.com/vmware/docker-volume-vsphere/client_plugin/utils/config" | ||
"github.com/vmware/docker-volume-vsphere/client_plugin/utils/plugin_server" |
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.
I might have missed the PR where plugin_server
is introduced ..
see import package seems ugly as go doesn't recommend _
in the PR (not for this PR though)
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.
Please don't ignore the _
in "client_plugin" part. :)
@shuklanirdesh82 Besides that there is special use for So I guess there isn't a recommendation about not using |
|
Lots of code is not compliant with standards and code style guidance, so examples do not work very well.
BTW, they actually advice against generic name. e.g. So I am with @shuklanirdesh82 here, though IMO it's not a huge issue and we are not compliant in many other places already. Still, I suggest something like |
I don't mind if we apply this rule to vDVS code! And of course as @msterin mentioned, we didn't follow such rule before. All files under client_plugin mainly are not compliant with this rule. So if someone want to open an issue and adjust all the current filenames, I won't have an opinion. |
New plugin: client_plugin/shared_plugin
New driver: client_plugin/drivers/shared
To build the new plugin: make shared-all
Plugin is pushed into: [DOCKER_HUB_REPO]/vsphere-shared:[VERSION_TAG][EXTRA_TAG]
Functions in the new shared_driver are to be implemented.
There are a few layout change in drivers directory.
Common utility functions are grouped under drivers/commonUtilDriver.
The new plugin shares the same plugin_dockerbuild Makefile with original vmdk plugin.
Thus the Dockerfile and config.json are replaced by Dockerfile-template and config.json-template in order to be generic.
Testing result:
test-e2e runalways passed.
Skipped local run of test-e2e runonce due to testbed requirements not ideal, and will use CI for final check.