-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add registry to discover driver in different platforms #2526
Conversation
Can one of the admins verify this patch? |
5c0c9a8
to
30ceaa5
Compare
I found the machine package has very similar stuff. I think it's possible to merge them. I will update this PR. but @r2d4 feel free to review this. |
Probably related to #2527 ? |
@afbjorklund kind of, but not just that. the intention is to remove the hardcoded |
@praveenkumar WDYT? |
@minikube-bot ok to test |
Nice. I like this pattern. Do you have any immediate use-cases in mind? |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: anfernee Assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Guys, I moved all driver logic together and register them in registry, so it's easier to add new driver support in minikube (potentally minishift and other tools). simply register with a name, and couple of functions. Specifically:
@dlorenc for use cases, the top of my mind is #2527 all supported drivers were hardcoded. With this change, we only need to call |
@minishift/minishift-dev @praveenkumar @LalatenduMohanty Please, have a look |
With this PR we are adding now more and more stuff to A lot of great work is done in this PR which actually help us some of the plans we thought before like installing driver plugin as part of pre-start. |
@praveenkumar I think you can import individual packages into your vendor folder without importing the whole repo. There are tools that can do that. You probably need those packages:
The config package might not make sense for minishift, because you probably have different |
@anfernee we use
Yes, as of now we do have some more datatype in that structure for some validations. |
@praveenkumar Just try doing this using $ cat main.go
package main
import (
"fmt"
"k8s.io/kubernetes/pkg/util/slice"
)
func main() {
fmt.Println(slice.SortStrings([]string{"foo", "bar"}))
}
$ dep init
Using ^1.9.3 as constraint for direct dep k8s.io/kubernetes
Locking in v1.9.3 (d283541) for direct dep k8s.io/kubernetes
Locking in master (cced8e6) for transitive dep k8s.io/apimachinery It will not copy everything into vendor. In terms of minishift's machine config, I think there are several ways to make it more generic. One of them is to take a viper like interface, instead of |
@anfernee Looks like it does most of the things.
|
Looks like there's a conflict in kubeadm.go. Woul you mind rebasing to kick off a final test run? |
Different platform has differnet list of supported drivers. The registry contains the correct list of drivers that are supported. In future we could add commands like `minikube list-drivers`
Use ListDrivers() method to get the list of VM drivers. SupportedVMDrivers become the whole list of VM drivers on all platforms, which is used in gendocs only.
The OSX test looks suspicious. I would go grab a mac and test it. I assume it would be either red herring or small change. The rest of this PR should be ready for review. @dlorenc @r2d4 if you guys can take a look at the basic structure of this PR and give me some feedback, it would be great. thanks! |
I tried to run this PR on OSX, it works well. Still not sure why test fails though. |
maybe a fluke? does /retest work here? |
I think the mac slave needed a reboot. I'll kick it off again after the machine comes back up. |
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.
Two small nits, otherwise LGTM. The test passed after the reboot.
pkg/minikube/cluster/cluster.go
Outdated
@@ -308,6 +296,7 @@ func MountHost(api libmachine.API, ip net.IP, path, port, mountVersion string, u | |||
} | |||
|
|||
// GetVMHostIP gets the ip address to be used for mapping host -> VM and VM -> host | |||
// TODO: remove this (why not just using driver.GetIP?) |
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 is kind of the opposite - driver.GetIP is the IP address of the VM from the host, this is the IP of the host from the VM.
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. I see. I am removing this comment. but i still want to see if it's possible to remove the switch for driver names sometime in future.
pkg/minikube/cluster/cluster_test.go
Outdated
@@ -67,15 +68,17 @@ func TestCreateHost(t *testing.T) { | |||
} | |||
|
|||
found := false | |||
for _, driver := range constants.SupportedVMDrivers { | |||
if h.DriverName == driver { | |||
drivers := []string{} |
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.
If you add a "String()" method to DriverDef that returns the .Name field, I think you can simplify this a bit and avoid collecting the drivers slice.
- Add registry to register all supported drivers in different platforms. - Add DriverDef to define driver's metadata. - All driver support logic moved to pkg/minikube/drivers, removed all driver name switches scattered in different packages.
done, thanks @dlorenc |
Is there any quick guide on how to convert a driver to this new regime ? |
@anfernee Can you also send a PR to minishift side? I think it would be good if you send instead we copy stuff and then paste. |
thanks @dlorenc @afbjorklund Good question. Not yet. but I am going to write one maybe in the drivers folder. @praveenkumar will do. but I would need to get myself familiar to minishift source. I don't mind if you guys want to copy&paste it. |
@anfernee Thanks, no hurry from our side (Take your time)
Right but I really like you to put that code instead we copy&paste :) |
Different platform has differnet list of supported drivers. The
registry contains the correct list of drivers that are supported. In
future we could add commands like
minikube list-drivers