mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-10 15:02:56 +00:00
Exposes an endpoint "/profile/cpu" for profiling the postgres processes (currently spawned and the new ones) using "perf". Adds the corresponding python test to test the added endpoint and confirm the output expected is the profiling data in the expected format. Add "perf" binary to the sudo list. Fix python poetry ruff Address the clippy lints Document the code Format python code Address code review Prettify Embed profile_pb2.py and small code/test fixes. Make the code slightly better. 1. Makes optional the sampling_frequency parameter for profiling. 2. Avoids using unsafe code when killing a child. Better code, better tests More tests Separate start and stop of profiling Correctly check for the exceptions Address clippy lint Final fixes. 1. Allows the perf to be found in $PATH instead of having the path hardcoded. 2. Changes the path to perf in the sudoers file so that the compute can run it properly. 3. Changes the way perf is invoked, now it is with sudo and the path from $PATH. 4. Removes the authentication requirement from the /profile/cpu/ endpoint. hakari thing Python fixes Fix python formatting More python fixes Update poetry lock Fix ruff Address the review comments Fix the tests Try fixing the flaky test for pg17? Try fixing the flaky test for pg17? PYTHON Fix the tests Remove the PROGRESS parameter Remove unused Increase the timeout due to concurrency Increase the timeout to 60 Increase the profiling window timeout Try this Lets see the error Just log all the errors Add perf into the build environment uijdfghjdf Update tempfile to 3.20 Snapshot Use bbc-profile Update tempfile to 3.20 Provide bpfcc-tools in debian Properly respond with status Python check Fix build-tools dockerfile Add path probation for the bcc profile Try err printing Refactor Add bpfcc-tools to the final image Add error context sudo not found? Print more errors for verbosity Remove procfs and use libproc Update hakari Debug sudo in CI Rebase and adjust hakari remove leftover Add archiving support Correct the paths to the perf binary Try hardcoded sudo path Add sudo into build-tools dockerfile Minor cleanup Print out the sudoers file from github Stop the tests earlier Add the sudoers entry for nonroot, install kmod for modprobe for bcc-profile Try hacking the kernel headers for bcc-profile Redeclare the kernel version argument Try using the kernel of the runner Try another way Check bpfcc-tools
171 lines
7.5 KiB
Docker
171 lines
7.5 KiB
Docker
### Creates a storage Docker image with postgres, pageserver, safekeeper and proxy binaries.
|
|
### The image itself is mainly used as a container for the binaries and for starting e2e tests with custom parameters.
|
|
### By default, the binaries inside the image have some mock parameters and can start, but are not intended to be used
|
|
### inside this image in the real deployments.
|
|
ARG REPOSITORY=ghcr.io/neondatabase
|
|
ARG IMAGE=build-tools
|
|
ARG TAG=pinned
|
|
ARG DEBIAN_VERSION=bookworm
|
|
ARG DEBIAN_FLAVOR=${DEBIAN_VERSION}-slim
|
|
|
|
# Here are the INDEX DIGESTS for the images we use.
|
|
# You can get them following next steps for now:
|
|
# 1. Get an authentication token from DockerHub:
|
|
# TOKEN=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/debian:pull" | jq -r .token)
|
|
# 2. Using that token, query index for the given tag:
|
|
# curl -s -H "Authorization: Bearer $TOKEN" \
|
|
# -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" \
|
|
# "https://registry.hub.docker.com/v2/library/debian/manifests/bullseye-slim" \
|
|
# -I | grep -i docker-content-digest
|
|
# 3. As a next step, TODO(fedordikarev): create script and schedule workflow to run these checks
|
|
# and updates on regular bases and in automated way.
|
|
ARG BOOKWORM_SLIM_SHA=sha256:40b107342c492725bc7aacbe93a49945445191ae364184a6d24fedb28172f6f7
|
|
ARG BULLSEYE_SLIM_SHA=sha256:e831d9a884d63734fe3dd9c491ed9a5a3d4c6a6d32c5b14f2067357c49b0b7e1
|
|
|
|
# Here we use ${var/search/replace} syntax, to check
|
|
# if base image is one of the images, we pin image index for.
|
|
# If var will match one the known images, we will replace it with the known sha.
|
|
# If no match, than value will be unaffected, and will process with no-pinned image.
|
|
ARG BASE_IMAGE_SHA=debian:${DEBIAN_FLAVOR}
|
|
ARG BASE_IMAGE_SHA=${BASE_IMAGE_SHA/debian:bookworm-slim/debian@$BOOKWORM_SLIM_SHA}
|
|
ARG BASE_IMAGE_SHA=${BASE_IMAGE_SHA/debian:bullseye-slim/debian@$BULLSEYE_SLIM_SHA}
|
|
|
|
# Naive way:
|
|
#
|
|
# 1. COPY . .
|
|
# 1. make neon-pg-ext
|
|
# 2. cargo build <storage binaries>
|
|
#
|
|
# But to enable docker to cache intermediate layers, we perform a few preparatory steps:
|
|
#
|
|
# - Build all postgres versions, depending on just the contents of vendor/
|
|
# - Use cargo chef to build all rust dependencies
|
|
|
|
# 1. Build all postgres versions
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS pg-build
|
|
WORKDIR /home/nonroot
|
|
|
|
COPY --chown=nonroot vendor/postgres-v14 vendor/postgres-v14
|
|
COPY --chown=nonroot vendor/postgres-v15 vendor/postgres-v15
|
|
COPY --chown=nonroot vendor/postgres-v16 vendor/postgres-v16
|
|
COPY --chown=nonroot vendor/postgres-v17 vendor/postgres-v17
|
|
COPY --chown=nonroot Makefile Makefile
|
|
COPY --chown=nonroot postgres.mk postgres.mk
|
|
COPY --chown=nonroot scripts/ninstall.sh scripts/ninstall.sh
|
|
|
|
ENV BUILD_TYPE=release
|
|
RUN set -e \
|
|
&& mold -run make -j $(nproc) -s postgres
|
|
|
|
# 2. Prepare cargo-chef recipe
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS plan
|
|
WORKDIR /home/nonroot
|
|
|
|
COPY --chown=nonroot . .
|
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
# Main build image
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS build
|
|
WORKDIR /home/nonroot
|
|
ARG GIT_VERSION=local
|
|
ARG BUILD_TAG
|
|
ARG ADDITIONAL_RUSTFLAGS=""
|
|
|
|
# 3. Build cargo dependencies. Note that this step doesn't depend on anything else than
|
|
# `recipe.json`, so the layer can be reused as long as none of the dependencies change.
|
|
COPY --from=plan /home/nonroot/recipe.json recipe.json
|
|
RUN set -e \
|
|
&& RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment -Cforce-frame-pointers=yes ${ADDITIONAL_RUSTFLAGS}" cargo chef cook --locked --release --recipe-path recipe.json
|
|
|
|
# Perform the main build. We reuse the Postgres build artifacts from the intermediate 'pg-build'
|
|
# layer, and the cargo dependencies built in the previous step.
|
|
COPY --chown=nonroot --from=pg-build /home/nonroot/pg_install/ pg_install
|
|
COPY --chown=nonroot . .
|
|
|
|
RUN set -e \
|
|
&& RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment -Cforce-frame-pointers=yes ${ADDITIONAL_RUSTFLAGS}" cargo build \
|
|
--bin pg_sni_router \
|
|
--bin pageserver \
|
|
--bin pagectl \
|
|
--bin safekeeper \
|
|
--bin storage_broker \
|
|
--bin storage_controller \
|
|
--bin proxy \
|
|
--bin endpoint_storage \
|
|
--bin neon_local \
|
|
--bin storage_scrubber \
|
|
--locked --release \
|
|
&& mold -run make -j $(nproc) -s neon-pg-ext
|
|
|
|
# Assemble the final image
|
|
FROM $BASE_IMAGE_SHA
|
|
WORKDIR /data
|
|
|
|
RUN set -e \
|
|
&& echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retries \
|
|
&& apt update \
|
|
&& apt install -y \
|
|
libreadline-dev \
|
|
libseccomp-dev \
|
|
ca-certificates \
|
|
bpfcc-tools \
|
|
sudo \
|
|
openssl \
|
|
unzip \
|
|
curl \
|
|
&& ARCH=$(uname -m) \
|
|
&& if [ "$ARCH" = "x86_64" ]; then \
|
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"; \
|
|
elif [ "$ARCH" = "aarch64" ]; then \
|
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"; \
|
|
else \
|
|
echo "Unsupported architecture: $ARCH" && exit 1; \
|
|
fi \
|
|
&& unzip awscliv2.zip \
|
|
&& ./aws/install \
|
|
&& rm -rf aws awscliv2.zip \
|
|
&& rm -f /etc/apt/apt.conf.d/80-retries \
|
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
|
&& useradd -d /data neon \
|
|
&& chown -R neon:neon /data
|
|
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pg_sni_router /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pageserver /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pagectl /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/safekeeper /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_broker /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_controller /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/proxy /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/endpoint_storage /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/neon_local /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_scrubber /usr/local/bin
|
|
COPY --from=build /home/nonroot/pg_install/v14 /usr/local/v14/
|
|
COPY --from=build /home/nonroot/pg_install/v15 /usr/local/v15/
|
|
COPY --from=build /home/nonroot/pg_install/v16 /usr/local/v16/
|
|
COPY --from=build /home/nonroot/pg_install/v17 /usr/local/v17/
|
|
|
|
# Deprecated: Old deployment scripts use this tarball which contains all the Postgres binaries.
|
|
# That's obsolete, since all the same files are also present under /usr/local/v*. But to keep the
|
|
# old scripts working for now, create the tarball.
|
|
RUN tar -C /usr/local -cvzf /data/postgres_install.tar.gz v14 v15 v16 v17
|
|
|
|
# By default, pageserver uses `.neon/` working directory in WORKDIR, so create one and fill it with the dummy config.
|
|
# Now, when `docker run ... pageserver` is run, it can start without errors, yet will have some default dummy values.
|
|
RUN mkdir -p /data/.neon/ && \
|
|
echo "id=1234" > "/data/.neon/identity.toml" && \
|
|
echo "broker_endpoint='http://storage_broker:50051'\n" \
|
|
"pg_distrib_dir='/usr/local/'\n" \
|
|
"listen_pg_addr='0.0.0.0:6400'\n" \
|
|
"listen_http_addr='0.0.0.0:9898'\n" \
|
|
"availability_zone='local'\n" \
|
|
> /data/.neon/pageserver.toml && \
|
|
chown -R neon:neon /data/.neon
|
|
|
|
VOLUME ["/data"]
|
|
USER neon
|
|
EXPOSE 6400
|
|
EXPOSE 9898
|
|
|
|
CMD ["/usr/local/bin/pageserver", "-D", "/data/.neon"]
|