From f3ec9acbaebc77966f07e78c6fc81f96bfdb5e2b Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Sat, 21 Dec 2024 15:08:59 -0800 Subject: [PATCH 01/11] CASMHMS-6324: Added support for ppprof builds --- .version | 2 +- CHANGELOG.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.version b/.version index bf50e910..ebeef2f2 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.37.0 +1.38.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 244055bf..257c7ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.38.0] - 2025-01-08 + +### Added + +- Added support for ppprof builds + ## [1.37.0] - 2024-12-20 ### Changed From 29643aacec8730a74f2abf2ff2d23c8e5adb46da Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Sat, 21 Dec 2024 15:27:07 -0800 Subject: [PATCH 02/11] CASMHMS-6324: Dockerfile changes --- Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce3173ca..4b96d34a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # MIT License # -# (C) Copyright 2020-2024 Hewlett Packard Enterprise Development LP +# (C) Copyright 2020-2025 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -43,7 +43,15 @@ COPY .version $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/.version ### Build Stage ### FROM base AS builder -RUN set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action +# Set profiling to disabled by default +ARG ENABLE_PPROF=true + +# Conditionally build with the pprof tag if profiling is enabled +RUN if [ "$ENABLE_PPROF" = "true" ]; then \ + set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action + else \ + set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action + fi ### Build python base ### From e41c35dbb6bbbf10d5bedf0db08a41932f9607b7 Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Sat, 21 Dec 2024 15:31:33 -0800 Subject: [PATCH 03/11] CASMHMS-6324: Fix syntax error --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b96d34a..8ae8de83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,9 +48,9 @@ ARG ENABLE_PPROF=true # Conditionally build with the pprof tag if profiling is enabled RUN if [ "$ENABLE_PPROF" = "true" ]; then \ - set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action + set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action \ else \ - set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action + set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action \ fi ### Build python base ### From 7c2f5b52f7fb1e4b3385f7a29fb4e767c19f4cdf Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Sat, 21 Dec 2024 15:36:26 -0800 Subject: [PATCH 04/11] CASMHMS-6324: Forgot semi-colon... --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ae8de83..fb22d980 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,9 +48,9 @@ ARG ENABLE_PPROF=true # Conditionally build with the pprof tag if profiling is enabled RUN if [ "$ENABLE_PPROF" = "true" ]; then \ - set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action \ + set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action; \ else \ - set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action \ + set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action; \ fi ### Build python base ### From 8831dad24e017f44e7fc23afe30f425b81d58b53 Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Mon, 23 Dec 2024 09:07:43 -0800 Subject: [PATCH 05/11] CASMHMS-6324: Add pprof support code --- internal/api/pprof.go | 54 ++++++++++++++++++++++++++++++++++++++ internal/api/pprof_stub.go | 33 +++++++++++++++++++++++ internal/api/routers.go | 6 ++++- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 internal/api/pprof.go create mode 100644 internal/api/pprof_stub.go diff --git a/internal/api/pprof.go b/internal/api/pprof.go new file mode 100644 index 00000000..2e6c082c --- /dev/null +++ b/internal/api/pprof.go @@ -0,0 +1,54 @@ +// This file contains the code to enable pprof profiling. It is only +// included in the build when the 'pprof' build tag is set in the Dockerfile. +// +//go:build pprof + +/* + * (C) Copyright [2025] Hewlett Packard Enterprise Development LP + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +package api + +import ( + "net/http/pprof" + _ "net/http/pprof" + + "github.com/gorilla/mux" +) + +func RegisterPProfHandlers(router *mux.Router) { + // Main profiling entry point + router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints + + // Specific profiling handlers + router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments + router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) + router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses + router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) + + // Additional profiling endpoints + router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples + router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events + router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines + router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile + router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile + router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation +} \ No newline at end of file diff --git a/internal/api/pprof_stub.go b/internal/api/pprof_stub.go new file mode 100644 index 00000000..3c037b4e --- /dev/null +++ b/internal/api/pprof_stub.go @@ -0,0 +1,33 @@ +// This file contains a stub implementation of the RegisterPProfHandlers() +// function which is a noop.  It is included in the build by default by +// way of the 'pprof' build tag not being set in the Dockerfile. +// +//go:build !pprof + +/* + * (C) Copyright [2025] Hewlett Packard Enterprise Development LP + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +package api + +import "github.com/gorilla/mux" + +func RegisterPProfHandlers(router *mux.Router) { } \ No newline at end of file diff --git a/internal/api/routers.go b/internal/api/routers.go index 21b0cc89..17249201 100644 --- a/internal/api/routers.go +++ b/internal/api/routers.go @@ -1,7 +1,7 @@ /* * MIT License * - * (C) Copyright [2020-2023] Hewlett Packard Enterprise Development LP + * (C) Copyright [2020-2023,2025] Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -77,6 +77,10 @@ func NewRouter() *mux.Router { Handler(handler) } + // If the 'pprof' build tag is set, then this will register pprof handlers, + // otherwise this function is stubbed and will do nothing. + RegisterPProfHandlers(router) + return router } From 29f99852446f1f733f65def7a69233c55d8f373b Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Mon, 23 Dec 2024 11:57:40 -0800 Subject: [PATCH 06/11] CASMHMS-6324: No /v1 prefix in APIs --- internal/api/pprof.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/api/pprof.go b/internal/api/pprof.go index 2e6c082c..802083f6 100644 --- a/internal/api/pprof.go +++ b/internal/api/pprof.go @@ -36,19 +36,19 @@ import ( func RegisterPProfHandlers(router *mux.Router) { // Main profiling entry point - router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints + router.HandleFunc("/debug/pprof/", pprof.Index) // Index listing all pprof endpoints // Specific profiling handlers - router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments - router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) - router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses - router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) + router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments + router.HandleFunc("/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) + router.HandleFunc("/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses + router.HandleFunc("/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) // Additional profiling endpoints - router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples - router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events - router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines - router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile - router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile - router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation -} \ No newline at end of file + router.Handle("/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples + router.Handle("/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events + router.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines + router.Handle("/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile + router.Handle("/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile + router.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation +} From 70a53fc17f8858d6aa37c52bb20aeafedc1371bd Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Mon, 23 Dec 2024 12:13:02 -0800 Subject: [PATCH 07/11] CASMHMS-6324: Put /v1 prefix back --- internal/api/pprof.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/api/pprof.go b/internal/api/pprof.go index 802083f6..066fc45f 100644 --- a/internal/api/pprof.go +++ b/internal/api/pprof.go @@ -36,19 +36,19 @@ import ( func RegisterPProfHandlers(router *mux.Router) { // Main profiling entry point - router.HandleFunc("/debug/pprof/", pprof.Index) // Index listing all pprof endpoints + router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints // Specific profiling handlers - router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments - router.HandleFunc("/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) - router.HandleFunc("/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses - router.HandleFunc("/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) + router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments + router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) + router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses + router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) // Additional profiling endpoints - router.Handle("/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples - router.Handle("/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events - router.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines - router.Handle("/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile - router.Handle("/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile - router.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation + router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples + router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events + router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines + router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile + router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile + router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation } From 3d3ecb1f9112e1ffbd4940938677357962fe42db Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Tue, 7 Jan 2025 09:36:50 -0800 Subject: [PATCH 08/11] CASMHMS-6324: Always build a pprof enabled image, alongside the original --- .../build_and_release_pprof_image.yaml | 13 ++ Dockerfile | 12 +- Dockerfile.pprof | 138 ++++++++++++++++++ 3 files changed, 153 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/build_and_release_pprof_image.yaml create mode 100644 Dockerfile.pprof diff --git a/.github/workflows/build_and_release_pprof_image.yaml b/.github/workflows/build_and_release_pprof_image.yaml new file mode 100644 index 00000000..00d6df5f --- /dev/null +++ b/.github/workflows/build_and_release_pprof_image.yaml @@ -0,0 +1,13 @@ +name: Build and Publish PProf Enabled Docker Images +on: + - push # Perform a build of the contents from the branch + - pull_request # Perform a build after merging with the target branch + - workflow_dispatch +jobs: + build_and_release: + uses: Cray-HPE/hms-build-image-workflows/.github/workflows/build_and_release_image.yaml@v2 + with: + image-name: cray-firmware-action-pprof + docker-build-file: Dockerfile.pprof + enable-pr-comment: true + secrets: inherit diff --git a/Dockerfile b/Dockerfile index fb22d980..ce3173ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # MIT License # -# (C) Copyright 2020-2025 Hewlett Packard Enterprise Development LP +# (C) Copyright 2020-2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -43,15 +43,7 @@ COPY .version $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/.version ### Build Stage ### FROM base AS builder -# Set profiling to disabled by default -ARG ENABLE_PPROF=true - -# Conditionally build with the pprof tag if profiling is enabled -RUN if [ "$ENABLE_PPROF" = "true" ]; then \ - set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action; \ - else \ - set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action; \ - fi +RUN set -ex && go build -v -tags musl -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action ### Build python base ### diff --git a/Dockerfile.pprof b/Dockerfile.pprof new file mode 100644 index 00000000..de54e207 --- /dev/null +++ b/Dockerfile.pprof @@ -0,0 +1,138 @@ +# MIT License +# +# (C) Copyright 2020-2025 Hewlett Packard Enterprise Development LP +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +# Dockerfile for building hms-firmware-action with pprof support. +# The only difference from primary dockerfile is building with the pprof tag + +# Build base just has the packages installed we need. +FROM artifactory.algol60.net/docker.io/library/golang:1.23-alpine AS build-base + +RUN set -ex \ + && apk -U upgrade \ + && apk add build-base + +# Base copies in the files we need to test/build. +FROM build-base AS base + +RUN go env -w GO111MODULE=auto + +# Copy all the necessary files to the image. +COPY cmd $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/cmd +COPY vendor $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/vendor +COPY internal $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/internal +COPY .version $GOPATH/src/github.com/Cray-HPE/hms-firmware-action/.version + +### Build Stage ### +FROM base AS builder + +RUN set -ex && go build -v -tags "musl pprof" -o /usr/local/bin/hms-firmware-action github.com/Cray-HPE/hms-firmware-action/cmd/hms-firmware-action + +### Build python base ### + +FROM artifactory.algol60.net/csm-docker/stable/docker.io/library/alpine:3.19 AS deploy-base + +COPY cmd/fw-loader/Pipfile / + +#### System Setup + +RUN set -x \ + && apk -U upgrade \ + && apk add --no-cache \ + bash \ + curl \ + python3 \ + py3-pip \ + rpm + +#### Environment Preparation + +RUN mkdir -p /.local \ + && mkdir -p /.cache \ + && ln -s /.local /root/.local \ + && ln -s /.cache /root/.cache \ + && export LANG="en_US.UTF-8" + +#### Python Virtual Environment and Dependencies + +RUN python3 -m venv /venv \ + && . /venv/bin/activate \ + && pip install --upgrade pip \ + && pip install pipenv \ + && pipenv install --deploy --ignore-pipfile + +ENV PATH="/venv/bin:$PATH" + +#### Final Configuration + +RUN mkdir -p /fw && chown 65534:65534 /fw + +### Final Stage ### + +FROM deploy-base +LABEL maintainer="Hewlett Packard Enterprise" +EXPOSE 28800 +STOPSIGNAL SIGTERM + +# Get the hms-firmware-action from the builder stage. +COPY --from=builder /usr/local/bin/hms-firmware-action /usr/local/bin/. +COPY configs configs +COPY entrypoint.sh / +COPY wait-for.sh / +COPY .version / +COPY fw-loader / +COPY cmd/fw-loader /src + +### IGNORE THIS VVVV +# Can also set KV_URL to point to the Key Value service access. +# This can be a reference to an etcd service, or "mem:", in which +# case, this will store everything directly in memory. +# If this is not set, then the service will look for the env vars +# ETCD_HOST and ETCD_PORT, and if those are set, it will construct +# the service name as http://$ETCD_HOST:$ETCD_PORT. +# ENV KV_URL=mem: +### ENDOF IGNORE ^^^ + +# Setup environment variables. +ENV SMS_SERVER=https://api-gateway.default.svc.cluster.local/apis/smd +ENV VAULT_ENABLED="true" +ENV VAULT_ADDR="http://cray-vault.vault:8200" +ENV VAULT_KEYPATH="secret/hms-creds" + +ENV LOG_LEVEL "INFO" +ENV SERVICE_RESERVATION_VERBOSITY "INFO" +ENV TRS_IMPLEMENTATION "LOCAL" +ENV STORAGE "ETCD" +ENV ETCD_HOST "etcd" +ENV ETCD_PORT "2379" +ENV HSMLOCK_ENABELD "true" +ENV NODE_BLACKLIST "ignore_ignore_ignore" + +ENV API_URL "http://cray-fas" +ENV API_SERVER_PORT ":28800" +ENV API_BASE_PATH "/v1" +ENV NUKE_FAS "false" +ENV IGNORE_POPULATED_FAS "true" + +#nobody 65534:65534 +USER 65534:65534 + +CMD ["sh", "-c", "/entrypoint.sh"] From 263c981d6073ee5ff3a28ff7bf91e23b13c86b7f Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Wed, 8 Jan 2025 07:57:45 -0800 Subject: [PATCH 09/11] CASMHMS-6324: Test not using custom paths --- internal/api/pprof.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/api/pprof.go b/internal/api/pprof.go index 066fc45f..d8b880af 100644 --- a/internal/api/pprof.go +++ b/internal/api/pprof.go @@ -28,7 +28,6 @@ package api import ( - "net/http/pprof" _ "net/http/pprof" "github.com/gorilla/mux" @@ -36,19 +35,19 @@ import ( func RegisterPProfHandlers(router *mux.Router) { // Main profiling entry point - router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints + //router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints // Specific profiling handlers - router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments - router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) - router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses - router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) + //router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments + //router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) + //router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses + //router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) // Additional profiling endpoints - router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples - router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events - router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines - router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile - router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile - router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation + //router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples + //router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events + //router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines + //router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile + //router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile + //router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation } From 0760fe4ccc302526405c6c3f9ef78dbc8f1ac1cf Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Wed, 8 Jan 2025 08:12:03 -0800 Subject: [PATCH 10/11] CASMHMS-6324: Seemed to work, now try much simpler approach --- internal/api/pprof.go | 23 +---------------------- internal/api/pprof_stub.go | 4 ---- internal/api/routers.go | 6 +----- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/internal/api/pprof.go b/internal/api/pprof.go index d8b880af..09041a72 100644 --- a/internal/api/pprof.go +++ b/internal/api/pprof.go @@ -29,25 +29,4 @@ package api import ( _ "net/http/pprof" - - "github.com/gorilla/mux" -) - -func RegisterPProfHandlers(router *mux.Router) { - // Main profiling entry point - //router.HandleFunc("/v1/debug/pprof/", pprof.Index) // Index listing all pprof endpoints - - // Specific profiling handlers - //router.HandleFunc("/v1/debug/pprof/cmdline", pprof.Cmdline) // Command-line arguments - //router.HandleFunc("/v1/debug/pprof/profile", pprof.Profile) // CPU profile (default: 30 seconds) - //router.HandleFunc("/v1/debug/pprof/symbol", pprof.Symbol) // Symbol resolution for addresses - //router.HandleFunc("/v1/debug/pprof/trace", pprof.Trace) // Execution trace (default: 1 second) - - // Additional profiling endpoints - //router.Handle("/v1/debug/pprof/allocs", pprof.Handler("allocs")) // Heap allocation samples - //router.Handle("/v1/debug/pprof/block", pprof.Handler("block")) // Goroutine blocking events - //router.Handle("/v1/debug/pprof/goroutine", pprof.Handler("goroutine")) // Stack traces of all goroutines - //router.Handle("/v1/debug/pprof/heap", pprof.Handler("heap")) // Memory heap profile - //router.Handle("/v1/debug/pprof/mutex", pprof.Handler("mutex")) // Mutex contention profile - //router.Handle("/v1/debug/pprof/threadcreate", pprof.Handler("threadcreate")) // Stack traces of thread creation -} +) \ No newline at end of file diff --git a/internal/api/pprof_stub.go b/internal/api/pprof_stub.go index 3c037b4e..cbf95af7 100644 --- a/internal/api/pprof_stub.go +++ b/internal/api/pprof_stub.go @@ -27,7 +27,3 @@ */ package api - -import "github.com/gorilla/mux" - -func RegisterPProfHandlers(router *mux.Router) { } \ No newline at end of file diff --git a/internal/api/routers.go b/internal/api/routers.go index 17249201..21b0cc89 100644 --- a/internal/api/routers.go +++ b/internal/api/routers.go @@ -1,7 +1,7 @@ /* * MIT License * - * (C) Copyright [2020-2023,2025] Hewlett Packard Enterprise Development LP + * (C) Copyright [2020-2023] Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -77,10 +77,6 @@ func NewRouter() *mux.Router { Handler(handler) } - // If the 'pprof' build tag is set, then this will register pprof handlers, - // otherwise this function is stubbed and will do nothing. - RegisterPProfHandlers(router) - return router } From 0177f7a0aac70ee5ce300d393b7780f999e3af49 Mon Sep 17 00:00:00 2001 From: Joshua Williams Date: Wed, 8 Jan 2025 08:36:52 -0800 Subject: [PATCH 11/11] CASMHMS-6324: Update comment --- internal/api/pprof_stub.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/api/pprof_stub.go b/internal/api/pprof_stub.go index cbf95af7..2f955d9d 100644 --- a/internal/api/pprof_stub.go +++ b/internal/api/pprof_stub.go @@ -1,6 +1,5 @@ -// This file contains a stub implementation of the RegisterPProfHandlers() -// function which is a noop.  It is included in the build by default by -// way of the 'pprof' build tag not being set in the Dockerfile. +// This file is a noop stub for the pprof package that is used when +// pprof is not enabled. // //go:build !pprof