@@ -23,6 +23,8 @@ import (
23
23
"os/exec"
24
24
"path"
25
25
"path/filepath"
26
+ "strconv"
27
+ "strings"
26
28
"time"
27
29
28
30
"github.com/docker/machine/libmachine"
@@ -37,6 +39,7 @@ import (
37
39
"k8s.io/minikube/pkg/minikube/config"
38
40
"k8s.io/minikube/pkg/minikube/constants"
39
41
"k8s.io/minikube/pkg/minikube/driver"
42
+ "k8s.io/minikube/pkg/minikube/exit"
40
43
"k8s.io/minikube/pkg/minikube/localpath"
41
44
"k8s.io/minikube/pkg/minikube/out"
42
45
"k8s.io/minikube/pkg/minikube/out/register"
@@ -149,6 +152,7 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) (
149
152
if err != nil {
150
153
return nil , errors .Wrap (err , "new host" )
151
154
}
155
+ defer postStartValidations (h , cfg .Driver )
152
156
153
157
h .HostOptions .AuthOptions .CertDir = localpath .MiniPath ()
154
158
h .HostOptions .AuthOptions .StorePath = localpath .MiniPath ()
@@ -202,6 +206,31 @@ func timedCreateHost(h *host.Host, api libmachine.API, t time.Duration) error {
202
206
}
203
207
}
204
208
209
+ // postStartValidations are validations against the host after it is created
210
+ // TODO: Add validations for VM drivers as well, see issue #9035
211
+ func postStartValidations (h * host.Host , drvName string ) {
212
+ if ! driver .IsKIC (drvName ) {
213
+ return
214
+ }
215
+ // make sure /var isn't full, otherwise warn
216
+ output , err := h .RunSSHCommand ("df -h /var | awk 'NR==2{print $5}'" )
217
+ if err != nil {
218
+ glog .Warningf ("error running df -h /var: %v" , err )
219
+ }
220
+ output = strings .Trim (output , "\n " )
221
+ percentageFull , err := strconv .Atoi (output [:len (output )- 1 ])
222
+ if err != nil {
223
+ glog .Warningf ("error getting percentage of /var that is free: %v" , err )
224
+ }
225
+ if percentageFull >= 99 {
226
+ exit .WithError ("" , fmt .Errorf ("docker daemon out of memory. No space left on device" ))
227
+ }
228
+
229
+ if percentageFull > 80 {
230
+ out .WarningT ("The docker daemon is almost out of memory, run 'docker system prune' to free up space" )
231
+ }
232
+ }
233
+
205
234
// postStart are functions shared between startHost and fixHost
206
235
func postStartSetup (h * host.Host , mc config.ClusterConfig ) error {
207
236
glog .Infof ("post-start starting for %q (driver=%q)" , h .Name , h .DriverName )
0 commit comments