Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for jenkins-workspace binary temporaries repository #1515

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ansible/roles/jenkins-workspace/files/clean_binary_tmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -ex

cd ~binary_tmp/binary_tmp.git
(echo; date) >> ~binary_tmp/clean_binary_tmp.log
du -sh ~binary_tmp/binary_tmp.git/ >> ~binary_tmp/clean_binary_tmp.log

git fetch origin +master:master

for b in $(git branch | sed /\*/d); do
if [ -z "$(git log -1 --since='7 days ago' -s $b)" ]; then
(git branch -D $b |& tee -a ~binary_tmp/clean_binary_tmp.log) || true
fi
done

git prune
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a nohup git gc >& ~binary_tmp/git_gc_`date +"%s"`.log ?
That way we won't get an auto gc in the middle of a future fetch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see below about gc.


du -sh ~binary_tmp/binary_tmp.git/ >> ~binary_tmp/clean_binary_tmp.log
8 changes: 8 additions & 0 deletions ansible/roles/jenkins-workspace/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

#
# generic handlers for jenkins-workspace stuff
#

- name: restart sshd
service: name="{{ sshd_service_name }}" state=restarted
26 changes: 26 additions & 0 deletions ansible/roles/jenkins-workspace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,29 @@
owner: "binary_tmp"
group: "binary_tmp"
mode: 0755

- name: Increase the maximum number of connections trying to authenticate
notify: restart sshd
lineinfile:
line: "MaxStartups 100:30:150"
dest: "{{ ssh_config }}"
regexp: "MaxStartups"

- name: Create clean-up script
copy:
src: "{{ role_path }}/files/clean_binary_tmp.sh"
dest: "~binary_tmp/clean_binary_tmp.sh"
owner: "binary_tmp"
group: "binary_tmp"
mode: 0755

- name: Schedule clean-up script to run daily
lineinfile:
line: "0 5 * * * binary_tmp ~binary_tmp/clean_binary_tmp.sh"
dest: "/etc/crontab"
regexp: "clean_binary_tmp"

- name: Disable automatic garbage collection
command: "git config gc.auto 0"
args:
chdir: "~binary_tmp/binary_tmp.git/"
13 changes: 13 additions & 0 deletions ansible/roles/jenkins-workspace/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

#
# variables for jenkins-workspace
#

ssh_config: /etc/ssh/sshd_config

sshd_service_map: {
'ubuntu1604': 'ssh',
}

sshd_service_name: "{{ sshd_service_map[os]|default(sshd_service_map[os|stripversion])|default('sshd') }}"