@@ -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,51 @@ 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
+ return
867
+ }
868
+
869
+ v := extractVMDriverVersion (string (output ))
870
+
871
+ if len (v ) == 0 {
872
+ exit .WithCode (exit .Failure , "Please upgrade the 'docker-machine-driver-kvm2'." )
873
+ }
874
+
875
+ vmDriverVersion , err := semver .Make (v )
876
+ if err != nil {
877
+ console .Warning ("Error parsing vmDriver version: %v" , err )
878
+ return
879
+ }
880
+
881
+ minikubeVersion , err := version .GetSemverVersion ()
882
+ if err != nil {
883
+ console .Warning ("Error parsing minukube version: %v" , err )
884
+ return
885
+ }
886
+
887
+ if vmDriverVersion .LT (minikubeVersion ) {
888
+ console .Warning ("The 'docker-machine-driver-kvm2' version is old. Please consider upgrading." )
889
+ }
890
+ }
891
+ }
892
+
893
+ func extractVMDriverVersion (s string ) string {
894
+ versionRegex := regexp .MustCompile (`version:(.*)` )
895
+ matches := versionRegex .FindStringSubmatch (s )
896
+
897
+ if len (matches ) != 2 {
898
+ return ""
899
+ }
900
+
901
+ v := strings .TrimSpace (matches [1 ])
902
+ return strings .TrimPrefix (v , version .VersionPrefix )
903
+ }
0 commit comments