[backport-1.4]: Fix bug in Thanos cleanup script
Main:
!4697 (merged)