@@ -26,6 +26,7 @@ import (
26
26
"os/exec"
27
27
"os/user"
28
28
"path/filepath"
29
+ "regexp"
29
30
"runtime"
30
31
"strconv"
31
32
"strings"
@@ -210,6 +211,8 @@ func runStart(cmd *cobra.Command, args []string) {
210
211
exit .WithError ("Failed to save config" , err )
211
212
}
212
213
214
+ validateDriverVersion (viper .GetString (vmDriver ))
215
+
213
216
m , err := machine .NewAPIClient ()
214
217
if err != nil {
215
218
exit .WithError ("Failed to get machine client" , err )
@@ -850,3 +853,50 @@ func saveConfig(clusterConfig cfg.Config) error {
850
853
}
851
854
return nil
852
855
}
856
+
857
+ func validateDriverVersion (vmDriver string ) {
858
+ if vmDriver == constants .DriverKvm2 {
859
+ cmd := exec .Command ("docker-machine-driver-kvm2" , "version" )
860
+ output , err := cmd .Output ()
861
+
862
+ // we don't want to fail if an error was returned, libmachine has a nice message for the user if
863
+ // the driver isn't present
864
+ if err != nil {
865
+ console .Warning ("Error checking driver version: %v" , err )
866
+ }
867
+
868
+ v := extractVMDriverVersion (string (output ))
869
+
870
+ if len (v ) == 0 {
871
+ exit .WithCode (exit .Failure , "Please upgrade the 'docker-machine-driver-kvm2'." )
872
+ }
873
+
874
+ vmDriverVersion , err := semver .Make (v )
875
+ if err != nil {
876
+ console .Warning ("Error parsing vmDriver version: %v" , err )
877
+ return
878
+ }
879
+
880
+ minikubeVersion , err := version .GetSemverVersion ()
881
+ if err != nil {
882
+ console .Warning ("Error parsing minukube version: %v" , err )
883
+ return
884
+ }
885
+
886
+ if vmDriverVersion .LT (minikubeVersion ) {
887
+ console .Warning ("The 'docker-machine-driver-kvm2' version is old. Please consider upgrading." )
888
+ }
889
+ }
890
+ }
891
+
892
+ func extractVMDriverVersion (s string ) string {
893
+ versionRegex := regexp .MustCompile (`version:(.*)` )
894
+ matches := versionRegex .FindStringSubmatch (s )
895
+
896
+ if len (matches ) != 2 {
897
+ return ""
898
+ }
899
+
900
+ v := strings .TrimSpace (matches [1 ])
901
+ return strings .TrimPrefix (v , version .VersionPrefix )
902
+ }
0 commit comments