Skip to content

Commit 9b2ae28

Browse files
Merge pull request #2042 from ardaguclu/revert-2028-ocpbugs-56691
OCPBUGS-57635: Revert "OCPBUGS-56691: Rely on overall available disk space of the mounted volume"
2 parents f9d98d6 + 9e34509 commit 9b2ae28

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/cli/admin/mustgather/mustgather.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ var (
8484
volumeUsageCheckerScript = `
8585
echo "volume percentage checker started....."
8686
while true; do
87-
usage_percentage=$(df -P "%s" | awk 'NR==2 {print $5}' | sed 's/%%//')
87+
disk_usage=$(du -s "%s" | awk '{print $1}')
88+
disk_space=$(df -P "%s" | awk 'NR==2 {print $2}')
89+
usage_percentage=$(( (disk_usage * 100) / disk_space ))
8890
echo "volume usage percentage $usage_percentage"
8991
if [ "$usage_percentage" -gt "%d" ]; then
9092
echo "Disk usage exceeds the volume percentage of %d for mounted directory. Exiting..."
@@ -141,7 +143,7 @@ func NewMustGatherOptions(streams genericiooptions.IOStreams) *MustGatherOptions
141143
SourceDir: "/must-gather/",
142144
IOStreams: streams,
143145
Timeout: 10 * time.Minute,
144-
VolumePercentage: 50,
146+
VolumePercentage: 30,
145147
}
146148
opts.LogOut = opts.newPrefixWriter(streams.Out, "[must-gather ] OUT", false, true)
147149
opts.RawOut = opts.newPrefixWriter(streams.Out, "", false, false)
@@ -467,7 +469,7 @@ func (o *MustGatherOptions) Run() error {
467469
}
468470
var hasMaster bool
469471
for _, node := range nodes.Items {
470-
if _, ok := node.Labels["node-role.kubernetes.io/control-plane"]; ok {
472+
if _, ok := node.Labels["node-role.kubernetes.io/master"]; ok {
471473
hasMaster = true
472474
break
473475
}
@@ -929,7 +931,7 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool) *corev1.P
929931
corev1.LabelOSStable: "linux",
930932
}
931933
if node == "" && hasMaster {
932-
nodeSelector["node-role.kubernetes.io/control-plane"] = ""
934+
nodeSelector["node-role.kubernetes.io/master"] = ""
933935
}
934936

935937
executedCommand := "/usr/bin/gather"
@@ -938,7 +940,7 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool) *corev1.P
938940
}
939941

940942
cleanedSourceDir := path.Clean(o.SourceDir)
941-
volumeUsageChecker := fmt.Sprintf(volumeUsageCheckerScript, cleanedSourceDir, o.VolumePercentage, o.VolumePercentage, executedCommand)
943+
volumeUsageChecker := fmt.Sprintf(volumeUsageCheckerScript, cleanedSourceDir, cleanedSourceDir, o.VolumePercentage, o.VolumePercentage, executedCommand)
942944

943945
ret := &corev1.Pod{
944946
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)