-
Notifications
You must be signed in to change notification settings - Fork 8
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
Update on demand for the git cache on build server #262
base: master
Are you sure you want to change the base?
Changes from all commits
43fa1f0
a42c40e
1cb1a2a
443eb27
983484d
2e61907
d970d68
6872388
8260fee
04e8656
7b460a7
88880fc
f52d4f2
0b329f8
98a4e52
77df556
67c2063
6af6780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
- concent-builder | ||
vars_files: | ||
- consts.yml | ||
- repositories.yml | ||
- "{{ deployment_values }}/var.yml" | ||
- "{{ deployment_values }}/var-{{ cluster }}.yml" | ||
tasks: | ||
|
@@ -14,9 +13,15 @@ | |
path: "{{ build_dir }}" | ||
state: absent | ||
|
||
- name: Clone or update git repositories | ||
service: | ||
name: update-git-mirror | ||
state: started | ||
become_user: root | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not have to run it as root. The whole idea with EDIT: After finishing the review I see that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, we agreed to use systemctl with sudo. We only run sudo with systemctl that is less dangerous than when we run all scripts with sudo. The systemd service control what is execute. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we agreed to use |
||
|
||
- name: Check out working copy of concent-deployment repositories | ||
git: | ||
repo: "{{ data_dir }}/concent-deployment" | ||
repo: "{{ git_mirror_dir }}/concent-deployment" | ||
dest: "{{ build_dir }}/concent-deployment" | ||
version: "{{ versions['concent-deployment'] }}" | ||
clone: yes | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
shared_user: builder | ||
data_dir: /var/concent-data | ||
git_mirror_dir: /var/git-mirror | ||
secret_dir: /var/concent-secrets | ||
build_dir: /home/{{ shared_user }}/build/{{ cluster }} | ||
local_secret_dir: ../../concent-secrets | ||
deployment_values: ../../concent-deployment-values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /bin/bash -e | ||
|
||
declare -A repositories | ||
|
||
repositories=( | ||
["concent"]="https://github.com/golemfactory/concent.git" | ||
["concent-deployment"]="https://github.com/golemfactory/concent-deployment.git" | ||
["golem"]="https://github.com/golemfactory/golem.git" | ||
) | ||
bartoszbetka marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=Update git repository | ||
|
||
[Service] | ||
Type=oneshot | ||
User=root | ||
Group=root | ||
WorkingDirectory={{ git_mirror_dir }}/ | ||
ExecStart=/usr/local/bin/update-git-mirror.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#! /bin/bash -e | ||
|
||
source /usr/local/lib/repositories.sh | ||
export repositories | ||
|
||
list_of_directories=( | ||
$(ls {{ git_mirror_dir }}/) | ||
) | ||
|
||
# Check list of directories in `/var/git-mirror/` path with repositories list in the `repositories.sh` file. | ||
for directory in "${list_of_directories[@]}"; do | ||
if [[ ! " ${!repositories[@]} " =~ " ${directory} " ]]; then | ||
rm -rf "/var/git-mirror/$directory/" | ||
fi | ||
done | ||
|
||
# Check if repositories from the `repositories.sh` file exist in `/var/git-mirror` path | ||
# and clone or update them. | ||
for repository in "${!repositories[@]}"; do | ||
repository_path="/var/git-mirror/$repository/" | ||
if [ ! -d $repository_path ]; then | ||
git clone --mirror "${repositories[$repository]}" "$repository_path" | ||
else | ||
cd "$repository_path" | ||
git fetch origin --prune | ||
fi | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put it in a separate block. It makes it easier to see that you're switching users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This require also add second block for task below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.