action #131471
Updated by tinita over 1 year ago
## Motivation While investigating #131447 we noticed that there are quite a few leftover temporary directories in `/tmp`. These appear to have been created by the scheduler or webui, and under certain circumstances are not cleaned up even if they are no longer needed. ``` ... drwx------ 2 geekotest nogroup 40 Jun 24 14:42 Y7FKl4lvbt drwx------ 2 geekotest nogroup 40 Jun 22 08:39 yblAcg26X3 drwx------ 2 geekotest nogroup 40 Jun 25 09:09 YeBlK48awn drwx------ 2 geekotest nogroup 40 Jun 23 19:55 yENrB8ToeU drwx------ 2 geekotest nogroup 40 Jun 27 12:04 Y_F6OzG5_3 drwx------ 2 geekotest nogroup 40 Jun 23 17:46 yfGT2ppHyr drwx------ 2 geekotest nogroup 40 Jun 25 09:09 yfneSFCwls drwx------ 2 geekotest nogroup 40 Jun 22 16:54 yHqfyU6xnC drwx------ 2 geekotest nogroup 40 Jun 26 02:26 YHrukyCIn5 drwx------ 2 geekotest nogroup 40 Jun 27 11:22 yIlfzjoPpj drwx------ 2 geekotest nogroup 40 Jun 23 21:16 Yixisovjrn drwx------ 2 geekotest nogroup 40 Jun 23 17:48 Yj1yuoh_7D drwx------ 2 geekotest nogroup 40 Jun 22 11:50 YlIRb1a69M drwx------ 2 geekotest nogroup 40 Jun 27 12:19 YLqGsMNpZ9 ... ``` What triggers the directories not to be cleaned up? From the openqa_scheduler_log: ``` [2023-06-27T19:25:43.422205Z] [warn] [pid:5909] Failed sending job(s) '3387016' to worker '425': Unable to assign job to worker 425: the worker up is not connected anymore ``` In those cases `$schema->txn_do(sub { $worker->unprepare_for_work; });` is called, which simply deletes the setting in the DB, but doesn't remove the dirctory. unclear. ## Acceptance criteria * **AC1:** No more leftover temporary directories on OSD and O3 ## Suggestions * `tempdir()` is called in two places ([here](https://github.com/os-autoinst/openQA/blob/74f3352b05303c0f91b570695cfce9dd0d718a6e/lib/OpenQA/Schema/Result/Jobs.pm#L390) and [here](https://github.com/os-autoinst/openQA/blob/74f3352b05303c0f91b570695cfce9dd0d718a6e/lib/OpenQA/Scheduler/Model/Jobs.pm#L461)) * Focus on fixing the cleanup code * It might make sense to change the default directory from `/tmp` to some directory under `/var/lib/openqa/...` too, since that's usually where we have our faster larger disks mounted ## Out of scope * Using a tmpfs is out of scope (we have https://progress.opensuse.org/issues/131516 for that)