Skip to content

Commit f86251a

Browse files
committed
[KubeSonic] Add bmp container watchdog
1 parent 2f167bb commit f86251a

File tree

13 files changed

+286
-0
lines changed

13 files changed

+286
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} AS builder
2+
3+
# Update apt's cache of available packages
4+
RUN apt-get update && apt-get install -y \
5+
build-essential
6+
7+
# Install Rust/Cargo via rustup
8+
ARG RUST_ROOT=/usr/.cargo
9+
RUN RUSTUP_HOME=$RUST_ROOT CARGO_HOME=$RUST_ROOT bash -c \
10+
'curl --proto "=https" -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.79.0 -y'
11+
ENV RUSTUP_HOME=$RUST_ROOT
12+
ENV PATH $PATH:$RUST_ROOT/bin
13+
14+
# Copy watchdog source into /watchdog
15+
WORKDIR /watchdog
16+
COPY watchdog/ ./
17+
18+
# Build from within /watchdog
19+
RUN cargo build --release
20+
21+
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}
22+
23+
ARG docker_container_name
24+
ARG image_version
25+
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf
26+
27+
ENV DEBIAN_FRONTEND=noninteractive
28+
ENV IMAGE_VERSION=$image_version
29+
30+
RUN apt-get update
31+
32+
# Copy supervisord.conf into final stage
33+
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
34+
35+
# Copy the compiled Rust binary from the builder stage
36+
COPY --from=builder /watchdog/target/release/watchdog /usr/bin/bmp_watchdog
37+
RUN chmod +x /usr/bin/bmp_watchdog
38+
39+
ENTRYPOINT ["/usr/local/bin/supervisord"]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[supervisord]
2+
logfile_maxbytes=1MB
3+
logfile_backups=2
4+
nodaemon=true
5+
6+
[eventlistener:dependent-startup]
7+
command=python3 -m supervisord_dependent_startup
8+
autostart=true
9+
autorestart=unexpected
10+
startretries=0
11+
exitcodes=0,3
12+
events=PROCESS_STATE
13+
buffer_size=1024
14+
15+
[program:rsyslogd]
16+
command=/usr/sbin/rsyslogd -n -iNONE
17+
priority=1
18+
autostart=false
19+
autorestart=unexpected
20+
stdout_logfile=NONE
21+
stdout_syslog=true
22+
stderr_logfile=NONE
23+
stderr_syslog=true
24+
dependent_startup=true
25+
26+
[program:bmp_watchdog]
27+
command=/usr/bin/bmp_watchdog
28+
priority=3
29+
autostart=false
30+
autorestart=false
31+
startsecs=0
32+
stdout_logfile=NONE
33+
stdout_syslog=true
34+
stderr_logfile=NONE
35+
stderr_syslog=true
36+
dependent_startup=true
37+
dependent_startup_wait_for=rsyslogd:running

dockers/docker-bmp-watchdog/watchdog/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "bmp_watchdog"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "watchdog for bmp container"
6+
license = "MIT"
7+
authors = ["Feng Pan"]
8+
9+
[dependencies]
10+
daemonize = "0.5"
11+
chrono = "0.4"
12+
serde = { version = "1.0", features = ["derive"] }
13+
serde_json = "1.0"
14+
15+
[[bin]]
16+
name = "bmp_watchdog"
17+
path = "src/main.rs"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.ONESHELL:
2+
SHELL = /bin/bash
3+
.SHELLFLAGS += -e
4+
5+
#
6+
# Debug build targets
7+
#
8+
build:
9+
cargo build --all
10+
11+
test:
12+
cargo test --all
13+
14+
clean:
15+
cargo clean
16+
17+
#
18+
# Release build targets
19+
#
20+
build-release:
21+
cargo build --release --all
22+
23+
test-release:
24+
cargo test --release --all
25+
26+
clean-release:
27+
cargo clean --release
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sonic (1.0.0) stable; urgency=medium
2+
3+
* Initial release
4+
5+
-- Feng Pan <[email protected]> Tue, 15 Apr 2025 03:13:12 +0000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Source: sonic
2+
Maintainer: Feng Pan <[email protected]>
3+
Section: net
4+
Priority: optional
5+
Standards-Version: 1.0.0
6+
7+
Package: sonic-bmp-watchdog
8+
Architecture: any
9+
Description: bmp watchdog for KubeSONiC project
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/release/watchdog /usr/bin
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/make -f
2+
# See debhelper(7) (uncomment to enable)
3+
# output every command that modifies files on the build system.
4+
#export DH_VERBOSE = 1
5+
6+
%:
7+
dh $@
8+
9+
override_dh_auto_build:
10+
cargo build --release --all
11+
12+
override_dh_auto_clean:
13+
cargo clean --release
14+
15+
override_dh_auto_test:
16+
# do nothing
17+
:

0 commit comments

Comments
 (0)