Skip to content

Commit 5874556

Browse files
authored
Merge pull request #6 from ruby-no-kai/kea2025
rk25net: dhcp
2 parents 4ff8c09 + 4a29478 commit 5874556

File tree

7 files changed

+210
-354
lines changed

7 files changed

+210
-354
lines changed

.github/workflows/docker-build-simple.libsonnet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ function(name, region='ap-northeast-1', platforms=['linux/arm64']) {
5959
context: std.format('{{defaultContext}}:%s', name),
6060
platforms: '${{ matrix.platform }}',
6161
outputs: std.format('type=image,"name=${{ steps.login-ecr.outputs.registry }}/%s",push-by-digest=true,name-canonical=true,push=true', name),
62+
'cache-from': 'type=gha',
63+
'cache-to': 'type=gha,mode=max',
6264
},
6365
},
6466
{

.github/workflows/docker-kea.yml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kea/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG BASE=public.ecr.aws/ubuntu/ubuntu:24.04
44

55
###
66

7-
FROM public.ecr.aws/docker/library/rust:1.77-slim-bullseye as build-healthz
7+
FROM public.ecr.aws/docker/library/rust:1.85-slim-bookworm as build-healthz
88

99
WORKDIR /build/healthz
1010
COPY healthz/ ./
@@ -21,7 +21,7 @@ RUN apt-get update \
2121
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git rake build-essential wget unzip python3
2222

2323
WORKDIR /build
24-
RUN git clone --depth=1 https://gitlab.isc.org/isc-projects/stork -b v1.15.0
24+
RUN git clone --depth=1 https://gitlab.isc.org/isc-projects/stork -b v2.1.1
2525

2626
WORKDIR /build/stork/backend
2727
ENV GOPATH=/build/go

kea/choose_dhcp_server_id.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
#!/usr/bin/env ruby
22
require 'ipaddr'
3+
require 'json'
34

45
dev = IO.popen(%w(ip -o route get 8.8.8.8), 'r', &:read).match(/dev ([^ ]+)/)[1].chomp
56
addr = IO.popen([*%w(ip -o address show dev), dev], 'r', &:read).match(/inet ([^ ]+)/)[1].chomp
6-
net = IPAddr.new(addr)
7+
#addr = '10.33.137.193'
8+
this = IPAddr.new(addr)
79

8-
candidates = ENV.fetch('DHCP_SERVER_IDS', '').split(',')
10+
#ENV['DHCP_SERVER_IDS'] = '10.33.136.67/21,10.33.152.67/21'
11+
candidates = ENV['DHCP_SERVER_IDS']&.then { _1.split(',') } || begin
12+
JSON.parse(File.read('/server-ids/server-ids.json')).fetch('server_ids')
13+
end
14+
warn(JSON.generate(this:, server_id_candidates: candidates))
915

1016
candidates.each do |candidate|
11-
if net.include?(IPAddr.new(candidate))
12-
puts candidate
17+
warn(JSON.generate(try: {candidate: candidate, this:}))
18+
if IPAddr.new(candidate).include?(this)
19+
warn(JSON.generate(server_id_chosen: candidate))
20+
puts candidate.split(?/)[0]
1321
exit
1422
end
1523
end
1624

25+
warn(JSON.generate(server_id_unchosen: addr, this:))
1726
puts addr.split(?/)[0]

0 commit comments

Comments
 (0)