Merge "limit-log-files: allow unlimited files"

This commit is contained in:
Zuul
2025-07-25 13:46:01 +00:00
committed by Gerrit Code Review
4 changed files with 35 additions and 10 deletions

View File

@@ -14,9 +14,10 @@ and reports a warning to Zuul.
.. zuul:rolevar:: limit_log_files_file_limit: .. zuul:rolevar:: limit_log_files_file_limit:
:type: int :type: int
:default: 100 :default: 0
Maximum number of files allowed in the logs directory. Maximum number of files allowed in the logs directory.
If set to 0, no limit is enforced on the number of files.
.. zuul:rolevar:: limit_log_files_file_rules: .. zuul:rolevar:: limit_log_files_file_rules:
:type: string :type: string

View File

@@ -3,7 +3,7 @@ limit_log_files_log_dir: "{{ zuul.executor.log_root }}"
limit_log_files_fail: false limit_log_files_fail: false
limit_log_files_file_limit: 100 limit_log_files_file_limit: 0
limit_log_files_file_rules: limit_log_files_file_rules:
- ".*job-output.json$ 500k" - ".*job-output.json$ 500k"

View File

@@ -18,6 +18,8 @@
exit 1 exit 1
fi fi
# If FILE_LIMIT is 0 allow any number of files
if (( FILE_LIMIT != 0 )); then
# Count files in target directory # Count files in target directory
TOTAL_FILES=$(find "$TARGET_DIR" -type f | wc -l) TOTAL_FILES=$(find "$TARGET_DIR" -type f | wc -l)
@@ -26,6 +28,8 @@
exit 2 exit 2
fi fi
fi
ERROR=0 ERROR=0
# check for violations off each rule # check for violations off each rule

View File

@@ -44,10 +44,10 @@
limit_log_files_file_rules: limit_log_files_file_rules:
- ".* 250c" - ".* 250c"
- ".* 150c" - ".* 150c"
# execute role with fail, should fail # execute role with big file, should fail
- name: Block to rescue failing of role - name: Block to rescue failing of role
block: block:
- name: Execute role in fail mode - name: Execute role with big file
include_role: include_role:
name: limit-log-files name: limit-log-files
vars: vars:
@@ -59,6 +59,26 @@
- name: Set fact for assertion - name: Set fact for assertion
set_fact: set_fact:
has_failed: true has_failed: true
- name: Assert that second run failed - name: Assert that run failed
assert:
that: has_failed is defined
# execute too many files, should fail
- name: Block to rescue failing of role
block:
- name: Execute role with too many files
include_role:
name: limit-log-files
vars:
limit_log_files_fail: true
limit_log_files_file_limit: 1
limit_log_files_log_dir: "{{ test_folder }}"
limit_log_files_file_rules:
- ".* 500c"
rescue:
- name: Set fact for assertion
set_fact:
has_failed: true
- name: Assert that run failed
assert: assert:
that: has_failed is defined that: has_failed is defined