8484 volumeUsageCheckerScript = `
8585echo "volume percentage checker started....."
8686while 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 ))
8890echo "volume usage percentage $usage_percentage"
8991if [ "$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