Skip to content

Commit

Permalink
Merge branch 'v3' into Replicate-PR-3460-for-PMM2docs
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinaadam authored Jan 17, 2025
2 parents 039f6e3 + 698463e commit 3b0f362
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
26 changes: 19 additions & 7 deletions build/docker/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM redhat/ubi9-minimal as users
FROM redhat/ubi9-minimal AS users

RUN microdnf install shadow-utils jq tar -y

Expand All @@ -10,13 +10,25 @@ RUN groupadd -g 1002 pmm-agent && \
FROM redhat/ubi9-micro

ARG VERSION
ARG RELEASE
ARG BUILD_DATE

LABEL org.opencontainers.image.created ${BUILD_DATE}
LABEL org.opencontainers.image.licenses Apache-2.0
LABEL org.opencontainers.image.title Percona Monitoring and Management Client
LABEL org.opencontainers.image.vendor Percona
LABEL org.opencontainers.image.version ${VERSION}
LABEL build-date=${BUILD_DATE} \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.licenses=Apache-2.0 \
org.opencontainers.image.title="Percona Monitoring and Management Client" \
org.opencontainers.image.vendor="Percona, LLC" \
org.opencontainers.image.version=${VERSION} \
version=${VERSION} \
release=${RELEASE} \
name="percona/pmm-client" \
summary="PMM Client image" \
description="The client image for Percona Monitoring and Management" \
io.k8s.description="The client image for Percona Monitoring and Management" \
io.k8s.display-name="Percona Monitoring and Management Client" \
url="https://docs.percona.com/percona-monitoring-and-management" \
vendor="Percona, LLC" \
maintainer="Percona, LLC"

COPY LICENSE /licenses/
COPY --from=users --chown=0:0 /etc/passwd /etc/passwd
Expand Down Expand Up @@ -55,6 +67,6 @@ RUN cd /tmp/pmm-client-* \

USER pmm-agent
WORKDIR /usr/local/percona/pmm/
ENV PATH /usr/local/percona/pmm/bin/:$PATH
ENV PATH=/usr/local/percona/pmm/bin/:$PATH

ENTRYPOINT ["/usr/local/percona/pmm/bin/pmm-agent-entrypoint"]
6 changes: 2 additions & 4 deletions build/scripts/build-client-docker
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ if [ -z "${DOCKER_CLIENT_TAG}" ]; then
DOCKER_CLIENT_TAG=perconalab/pmm-client-fb:${full_pmm_version}
fi


CLIENT_IMAGE_VERSION=`echo $DOCKER_CLIENT_TAG | cut -d ':' -f2`

docker build --build-arg BUILD_DATE="`date --rfc-3339=seconds`" \
--build-arg VERSION="$CLIENT_IMAGE_VERSION" \
--build-arg VERSION=$(cat VERSION) \
--build-arg RELEASE=$(date +%s) \
--squash \
--no-cache \
-f ${DOCKER_FILE_LOCATION}/${docker_file} \
Expand Down
20 changes: 19 additions & 1 deletion managed/models/agent_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ func CreateAgent(q *reform.Querier, agentType AgentType, params *CreateAgentPara
return nil, err
}

encryptedAgent := EncryptAgent(*row)
encryptedAgent := EncryptAgent(trimUnicodeNilsInCertFiles(*row))
if err := q.Insert(&encryptedAgent); err != nil {
return nil, errors.WithStack(err)
}
Expand All @@ -917,6 +917,24 @@ func CreateAgent(q *reform.Querier, agentType AgentType, params *CreateAgentPara
return &agent, nil
}

func trimUnicodeNilsInCertFiles(agent Agent) Agent {
const unicodeNil = "\u0000"

agent.MongoDBOptions.TLSCa = strings.ReplaceAll(agent.MongoDBOptions.TLSCa, unicodeNil, "")
agent.MongoDBOptions.TLSCertificateKey = strings.ReplaceAll(agent.MongoDBOptions.TLSCertificateKey, unicodeNil, "")
agent.MongoDBOptions.TLSCertificateKeyFilePassword = strings.ReplaceAll(agent.MongoDBOptions.TLSCertificateKeyFilePassword, unicodeNil, "")

agent.MySQLOptions.TLSCa = strings.ReplaceAll(agent.MySQLOptions.TLSCa, unicodeNil, "")
agent.MySQLOptions.TLSCert = strings.ReplaceAll(agent.MySQLOptions.TLSCert, unicodeNil, "")
agent.MySQLOptions.TLSKey = strings.ReplaceAll(agent.MySQLOptions.TLSKey, unicodeNil, "")

agent.PostgreSQLOptions.SSLCa = strings.ReplaceAll(agent.PostgreSQLOptions.SSLCa, unicodeNil, "")
agent.PostgreSQLOptions.SSLCert = strings.ReplaceAll(agent.PostgreSQLOptions.SSLCert, unicodeNil, "")
agent.PostgreSQLOptions.SSLKey = strings.ReplaceAll(agent.PostgreSQLOptions.SSLKey, unicodeNil, "")

return agent
}

// ChangeCommonAgentParams contains parameters that can be changed for all Agents.
type ChangeCommonAgentParams struct {
Enabled *bool // true - enable, false - disable, nil - no change
Expand Down

0 comments on commit 3b0f362

Please sign in to comment.