feat(build): Prune clones directory#6471
Conversation
|
| Filename | Overview |
|---|---|
| press/press/doctype/server/server.py | Adds prune_clone_directory public entry point and _prune_clone_directory worker; contains a misleading log message ("Prune Build Directory Exception") that should say "Prune Clone Directory Exception". |
| press/playbooks/prune_clones_directory.yml | New top-level playbook; uses gather_facts: yes while no facts are needed, inconsistent with the sibling docker_system_prune.yml that uses gather_facts: no. |
| press/playbooks/roles/prune_clones_directory/tasks/main.yml | Runs rm -rf /home/frappe/agent/.clones/* as root and then resets directory ownership to frappe:frappe; root is only strictly needed for the permission-reset step. |
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
press/press/doctype/server/server.py:2455-2457
The exception log message says `"Prune Build Directory Exception"` instead of `"Prune Clone Directory Exception"`. When this exception fires in production, searching logs for it will be misleading and point to the wrong operation.
```suggestion
except Exception:
log_error("Prune Clone Directory Exception", doc=self)
if throw_on_failure:
```
### Issue 2 of 3
press/playbooks/prune_clones_directory.yml:6
`gather_facts: yes` collects host facts (OS, network, hardware) that are unused by this role's two tasks (a `rm -rf` and a `file` permission reset). The sibling `docker_system_prune.yml` uses `gather_facts: no` for the same reason — it adds unnecessary overhead per invocation.
```suggestion
gather_facts: no
```
### Issue 3 of 3
press/playbooks/roles/prune_clones_directory/tasks/main.yml:3
**`rm -rf` with shell glob runs as root**
The `command` module runs `rm -rf /home/frappe/agent/.clones/*` as root (via `become_user: root`). The files inside `.clones` are owned by `frappe`, so root is not strictly required for deletion — only the permission-reset step needs it. Consider dropping privileges for this task by adding `become: no` or `become_user: frappe` so the wildcard expansion and deletion run as the file owner rather than root.
Reviews (1): Last reviewed commit: "feat(build): Prune clone directory on bu..." | Re-trigger Greptile
| except Exception: | ||
| log_error("Prune Build Directory Exception", doc=self) | ||
| if throw_on_failure: |
There was a problem hiding this comment.
The exception log message says
"Prune Build Directory Exception" instead of "Prune Clone Directory Exception". When this exception fires in production, searching logs for it will be misleading and point to the wrong operation.
| except Exception: | |
| log_error("Prune Build Directory Exception", doc=self) | |
| if throw_on_failure: | |
| except Exception: | |
| log_error("Prune Clone Directory Exception", doc=self) | |
| if throw_on_failure: |
Prompt To Fix With AI
This is a comment left during a code review.
Path: press/press/doctype/server/server.py
Line: 2455-2457
Comment:
The exception log message says `"Prune Build Directory Exception"` instead of `"Prune Clone Directory Exception"`. When this exception fires in production, searching logs for it will be misleading and point to the wrong operation.
```suggestion
except Exception:
log_error("Prune Clone Directory Exception", doc=self)
if throw_on_failure:
```
How can I resolve this? If you propose a fix, please make it concise.| hosts: all | ||
| become: yes | ||
| become_user: root | ||
| gather_facts: yes |
There was a problem hiding this comment.
gather_facts: yes collects host facts (OS, network, hardware) that are unused by this role's two tasks (a rm -rf and a file permission reset). The sibling docker_system_prune.yml uses gather_facts: no for the same reason — it adds unnecessary overhead per invocation.
| gather_facts: yes | |
| gather_facts: no |
Prompt To Fix With AI
This is a comment left during a code review.
Path: press/playbooks/prune_clones_directory.yml
Line: 6
Comment:
`gather_facts: yes` collects host facts (OS, network, hardware) that are unused by this role's two tasks (a `rm -rf` and a `file` permission reset). The sibling `docker_system_prune.yml` uses `gather_facts: no` for the same reason — it adds unnecessary overhead per invocation.
```suggestion
gather_facts: no
```
How can I resolve this? If you propose a fix, please make it concise.| @@ -0,0 +1,11 @@ | |||
| --- | |||
| - name: Prune Clones Directory | |||
| command: rm -rf /home/frappe/agent/.clones/* | |||
There was a problem hiding this comment.
rm -rf with shell glob runs as root
The command module runs rm -rf /home/frappe/agent/.clones/* as root (via become_user: root). The files inside .clones are owned by frappe, so root is not strictly required for deletion — only the permission-reset step needs it. Consider dropping privileges for this task by adding become: no or become_user: frappe so the wildcard expansion and deletion run as the file owner rather than root.
Prompt To Fix With AI
This is a comment left during a code review.
Path: press/playbooks/roles/prune_clones_directory/tasks/main.yml
Line: 3
Comment:
**`rm -rf` with shell glob runs as root**
The `command` module runs `rm -rf /home/frappe/agent/.clones/*` as root (via `become_user: root`). The files inside `.clones` are owned by `frappe`, so root is not strictly required for deletion — only the permission-reset step needs it. Consider dropping privileges for this task by adding `become: no` or `become_user: frappe` so the wildcard expansion and deletion run as the file owner rather than root.
How can I resolve this? If you propose a fix, please make it concise.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (14.28%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #6471 +/- ##
===========================================
+ Coverage 49.69% 56.29% +6.60%
===========================================
Files 953 953
Lines 78831 78845 +14
Branches 360 500 +140
===========================================
+ Hits 39173 44387 +5214
+ Misses 39634 34429 -5205
- Partials 24 29 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.