Skip to content

Commit b3e36f6

Browse files
ardagucluopenshift-cherrypick-robot
authored andcommitted
Rely on overall available disk space of the mounted volume
1 parent 010fac4 commit b3e36f6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/cli/admin/mustgather/mustgather.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ echo "[disk usage checker] Started"
9292
target_dir="%s"
9393
usage_percentage_limit="%d"
9494
while true; do
95-
disk_usage=$(du -s "$target_dir" | awk '{print $1}')
96-
disk_space=$(df -P "$target_dir" | awk 'NR==2 {print $2}')
97-
usage_percentage=$(( (disk_usage * 100) / disk_space ))
95+
usage_percentage=$(df -P "$target_dir" | awk 'NR==2 {print $5}' | sed 's/%%//')
9896
echo "[disk usage checker] Volume usage percentage: current = ${usage_percentage} ; allowed = ${usage_percentage_limit}"
9997
if [ "$usage_percentage" -gt "$usage_percentage_limit" ]; then
10098
echo "[disk usage checker] Disk usage exceeds the volume percentage of ${usage_percentage_limit} for mounted directory, terminating..."
@@ -177,7 +175,7 @@ func NewMustGatherOptions(streams genericiooptions.IOStreams) *MustGatherOptions
177175
SourceDir: "/must-gather/",
178176
IOStreams: streams,
179177
Timeout: 10 * time.Minute,
180-
VolumePercentage: 30,
178+
VolumePercentage: 70,
181179
}
182180
opts.LogOut = opts.newPrefixWriter(streams.Out, "[must-gather ] OUT", false, true)
183181
opts.RawOut = opts.newPrefixWriter(streams.Out, "", false, false)
@@ -420,8 +418,8 @@ func (o *MustGatherOptions) Validate() error {
420418
if o.VolumePercentage <= 0 || o.VolumePercentage > 100 {
421419
return fmt.Errorf("invalid volume usage percentage, please specify a value between 0 and 100")
422420
}
423-
if o.VolumePercentage >= 80 {
424-
klog.Warningf("volume percentage greater than or equal to 80 might cause filling up the disk space and have an impact on other components running on master")
421+
if o.VolumePercentage >= 90 {
422+
klog.Warningf("volume percentage greater than or equal to 90 might cause filling up the disk space and have an impact on other components running on master")
425423
}
426424

427425
if len(o.SinceTime) > 0 && o.Since != 0 {
@@ -621,7 +619,7 @@ func (o *MustGatherOptions) Run() error {
621619
}
622620
var hasMaster bool
623621
for _, node := range nodes.Items {
624-
if _, ok := node.Labels["node-role.kubernetes.io/master"]; ok {
622+
if _, ok := node.Labels["node-role.kubernetes.io/control-plane"]; ok {
625623
hasMaster = true
626624
break
627625
}
@@ -1086,7 +1084,7 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool, affinity
10861084
corev1.LabelOSStable: "linux",
10871085
}
10881086
if node == "" && hasMaster {
1089-
nodeSelector["node-role.kubernetes.io/master"] = ""
1087+
nodeSelector["node-role.kubernetes.io/control-plane"] = ""
10901088
}
10911089

10921090
executedCommand := "/usr/bin/gather"

0 commit comments

Comments
 (0)