Skip to content

Commit

Permalink
services/nomad/build/buildsync-{aarch64,musl}.nomad: use lsyncd
Browse files Browse the repository at this point in the history
instead of a cron job, use lsyncd to trigger rsync jobs. This should also
push to the glibc builder now, instead of the glibc builder pulling from
the other builders
  • Loading branch information
classabbyamp committed Aug 17, 2023
1 parent 75773b3 commit 43b9696
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 56 deletions.
64 changes: 36 additions & 28 deletions services/nomad/build/buildsync-aarch64.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,60 @@ job "buildsync-aarch64" {
datacenters = ["VOID"]
namespace = "build"

group "rsync" {
group "lsyncd" {
count = 1
network { mode = "bridge" }

volume "root-pkgs" {
volume "hostdir" {
type = "host"
source = "root-pkgs"
read_only = false
source = "aarch64_hostdir"
read_only = true
}

task "rsync" {
leader = true
driver = "docker"

vault {
policies = ["void-secrets-buildsync"]
}

config {
image = "eeacms/rsync"
args = ["client"]
}

env {
CRON_TASK_1="*/5 * * * * flock -n /run/rsync.lock rsync -vurk -e 'ssh -i /secrets/id_rsa -o UserKnownHostsFile=/local/known_hosts' --exclude '*.sig' --delete-after -f '+ */' -f '+ aarch64*-repodata' -f '+ *.aarch64*.xbps' -f '+ *.noarch*.xbps' -f '+ otime' -f '- *' [email protected]:/hostdir/binpkgs/ /pkgs/aarch64"
image = "ghcr.io/void-linux/infra-lsyncd:20230814"
}

volume_mount {
volume = "root-pkgs"
destination = "/pkgs"
volume = "hostdir"
destination = "/hostdir"
}

template {
data = <<EOF
{{- with secret "secret/buildsync/ssh" -}}
{{.Data.private_key}}
{{- end -}}
EOF
destination = "secrets/id_rsa"
perms = "0400"
}
settings {
statusFile = "/tmp/lsyncd.status",
nodaemon = true,
}
template {
data = <<EOF
b-fsn-de.node.consul ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP1ykMRsB3/DOv/NhnhajQIB99xUdM7RauBS5ptj2i4q
sync {
default.rsync,
source = "/hostdir/binpkgs",
{{- range nomadService "build-rsyncd" -}}
target = "rsync://a-fsn-de.node.consul:{{ .Port }}/pkgs/aarch64",
{{- end -}}
delay = 15,
filter = {
"+ */",
"+ *-repodata",
"+ *.xbps",
"+ otime",
"- .*",
"- *",
},
rsync = {
verbose = true,
update = true,
copy_dirlinks = true,
_extra = { "--delete-after" },
}
}
EOF
destination = "local/known_hosts"
destination = "local/lsyncd.conf"
perms = "0644"
}
}
}
Expand Down
64 changes: 36 additions & 28 deletions services/nomad/build/buildsync-musl.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,60 @@ job "buildsync-musl" {
datacenters = ["VOID"]
namespace = "build"

group "rsync" {
group "lsyncd" {
count = 1
network { mode = "bridge" }

volume "root-pkgs" {
volume "musl_hostdir" {
type = "host"
source = "root-pkgs"
read_only = false
source = "musl_hostdir"
read_only = true
}

task "rsync" {
leader = true
driver = "docker"

vault {
policies = ["void-secrets-buildsync"]
}

config {
image = "eeacms/rsync"
args = ["client"]
}

env {
CRON_TASK_1="*/5 * * * * flock -n /run/rsync.lock rsync -vurk -e 'ssh -i /secrets/id_rsa -o UserKnownHostsFile=/local/known_hosts' --exclude '*.sig' --delete-after -f '+ */' -f '+ *-repodata' -f '+ *.xbps' -f '+ otime' -f '- *' [email protected]:/hostdir/binpkgs/ /pkgs/musl/"
image = "ghcr.io/void-linux/infra-lsyncd:20230814"
}

volume_mount {
volume = "root-pkgs"
destination = "/pkgs"
volume = "musl_hostdir"
destination = "/hostdir"
}

template {
data = <<EOF
{{- with secret "secret/buildsync/ssh" -}}
{{.Data.private_key}}
{{- end -}}
EOF
destination = "secrets/id_rsa"
perms = "0400"
}
settings {
statusFile = "/tmp/lsyncd.status",
nodaemon = true,
}
template {
data = <<EOF
a-hel-fi.node.consul ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIW8voCZh9nQpdx3fAsvfZO4mCYv0/OUVNPF9A/GsHtX
sync {
default.rsync,
source = "/hostdir/binpkgs",
{{- range nomadService "build-rsyncd" -}}
target = "rsync://a-fsn-de.node.consul:{{ .Port }}/pkgs/musl",
{{- end -}}
delay = 15,
filter = {
"+ */",
"+ *-repodata",
"+ *.xbps",
"+ otime",
"- .*",
"- *",
},
rsync = {
verbose = true,
update = true,
copy_dirlinks = true,
_extra = { "--delete-after" },
}
}
EOF
destination = "local/known_hosts"
destination = "local/lsyncd.conf"
perms = "0644"
}
}
}
Expand Down

0 comments on commit 43b9696

Please sign in to comment.