Skip to content

Commit

Permalink
fix(precheck): imp disk check
Browse files Browse the repository at this point in the history
imp disk check

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Aug 16, 2023
1 parent f44061e commit 71f9ee3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const (
ControlPlaneMem = 1700
// ControlPlaneNumDisk is the number of Disk required on control-plane
ControlPlaneNumDisk = 40
// ControlPlaneLowDisk is the number of Disk required on node
ControlPlaneLowDisk = 20
)

const (
Expand Down
11 changes: 8 additions & 3 deletions internal/pkg/util/preflight/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ func (ncc NumCPUCheck) Check() error {
// NumDiskCheck checks if current number of Disk is not less than required
type NumDiskCheck struct {
NumDisk int
LowDisk int
}

// Name returns the label for NumDiskCheck
Expand All @@ -706,10 +707,14 @@ func (ndc NumDiskCheck) Check() error {
return errors.Errorf("disk check failed, reason: %v", err)
}
numDisk := float64(mountRoot.Total) / 1024.0 / 1024.0 / 1024.0
if numDisk < float64(ndc.LowDisk) {
return errors.Errorf("the number of available Disk %.2f GB is less than the required %d GB", numDisk, ndc.LowDisk)
}
if numDisk < float64(ndc.NumDisk) {
return errors.Errorf("the number of available Disk %.2f GB is less than the required %d GB", numDisk, ndc.NumDisk)
log.Warnf("the number of available Disk %.2f GB, suggest the number of available Disk greater than the required %d GB", numDisk, ndc.NumDisk)
} else {
log.Donef("the number of available Disk %.2f GB is greater than the required %d GB", numDisk, ndc.NumDisk)
}
log.Donef("the number of available Disk %.2f GB is greater than the required %d GB", numDisk, ndc.NumDisk)
return nil
}

Expand Down Expand Up @@ -740,7 +745,7 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *types.Metadata, ignorePr
// manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
checks := []Checker{
NumCPUCheck{NumCPU: common.ControlPlaneNumCPU},
NumDiskCheck{NumDisk: common.ControlPlaneNumDisk},
NumDiskCheck{NumDisk: common.ControlPlaneNumDisk, LowDisk: common.ControlPlaneLowDisk},
// Linux only
// TODO: support other OS, if control-plane is supported on it.
MemCheck{Mem: common.ControlPlaneMem},
Expand Down

0 comments on commit 71f9ee3

Please sign in to comment.