Skip to content

Commit

Permalink
Pin agent version
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Jan 17, 2025
1 parent 849fd7c commit 91ce545
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
7 changes: 5 additions & 2 deletions .ci/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ if [[ -z $OPERATOR_VERSION ]]; then
exit 1
fi



JAEGER_VERSION=$(echo $JAEGER_VERSION | tr -d '"')


PREVIOUS_VERSION=$(grep operator= versions.txt | awk -F= '{print $2}')

# change the versions.txt, bump only operator version.
Expand All @@ -20,11 +23,11 @@ sed "s~replaces: jaeger-operator.v.*~replaces: jaeger-operator.v${PREVIOUS_VERSI
sed -i "s~all-in-one:.*~all-in-one:${JAEGER_VERSION}~gi" examples/all-in-one-with-options.yaml

# statefulset-manual-sidecar
sed -i "s~jaeger-agent:.*~jaeger-agent:${JAEGER_VERSION}~gi" examples/statefulset-manual-sidecar.yaml
sed -i "s~jaeger-agent:.*~jaeger-agent:${JAEGER_AGENT_VERSION}~gi" examples/statefulset-manual-sidecar.yaml

# operator-with-tracing
sed -i "s~jaeger-operator:.*~jaeger-operator:${OPERATOR_VERSION}~gi" examples/operator-with-tracing.yaml
sed -i "s~jaeger-agent:.*~jaeger-agent:${JAEGER_VERSION}~gi" examples/operator-with-tracing.yaml
sed -i "s~jaeger-agent:.*~jaeger-agent:${JAEGER_AGENT_VERSION}~gi" examples/operator-with-tracing.yaml

# tracegen
sed -i "s~jaeger-tracegen:.*~jaeger-tracegen:${JAEGER_VERSION}~gi" examples/tracegen.yaml
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ COPY pkg/ pkg/
COPY versions.txt versions.txt

ARG JAEGER_VERSION
ARG JAEGER_AGENT_VERSION
ARG VERSION_PKG
ARG VERSION
ARG VERSION_DATE
Expand All @@ -32,7 +33,7 @@ ARG VERSION_DATE
# see last part of https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images
ARG TARGETARCH
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.defaultJaeger=${JAEGER_VERSION}" -a -o jaeger-operator main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.defaultJaeger=${JAEGER_VERSION} -X ${VERSION_PKG}.defaultAgent=${JAEGER_AGENT_VERSION}" -a -o jaeger-operator main.go

FROM quay.io/centos/centos:stream9

Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ BUNDLE_IMG ?= ${IMG_PREFIX}/${OPERATOR_NAME}-bundle:$(addprefix v,${VERSION})
OUTPUT_BINARY ?= "$(BIN_DIR)/jaeger-operator"
VERSION_PKG ?= "github.com/jaegertracing/jaeger-operator/pkg/version"
export JAEGER_VERSION ?= "$(shell grep jaeger= versions.txt | awk -F= '{print $$2}')"
export JAEGER_AGENT_VERSION ?= "1.64.0"

# Kafka and Kafka Operator variables
STORAGE_NAMESPACE ?= "${shell kubectl get sa default -o jsonpath='{.metadata.namespace}' || oc project -q}"
KAFKA_NAMESPACE ?= "kafka"
Expand Down Expand Up @@ -81,7 +83,7 @@ else
GOBIN=$(shell go env GOBIN)
endif

LD_FLAGS ?= "-X $(VERSION_PKG).version=$(VERSION) -X $(VERSION_PKG).buildDate=$(VERSION_DATE) -X $(VERSION_PKG).defaultJaeger=$(JAEGER_VERSION)"
LD_FLAGS ?= "-X $(VERSION_PKG).version=$(VERSION) -X $(VERSION_PKG).buildDate=$(VERSION_DATE) -X $(VERSION_PKG).defaultJaeger=$(JAEGER_VERSION) -X $(VERSION_PKG).defaultAgent=$(JAEGER_AGENT_VERSION)"

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST ?= $(LOCALBIN)/setup-envtest
Expand Down Expand Up @@ -152,11 +154,11 @@ build: format

.PHONY: docker
docker:
$(VECHO)[ ! -z "$(PIPELINE)" ] || docker build --build-arg=GOPROXY=${GOPROXY} --build-arg=VERSION=${VERSION} --build-arg=JAEGER_VERSION=${JAEGER_VERSION} --build-arg=TARGETARCH=$(GOARCH) --build-arg VERSION_DATE=${VERSION_DATE} --build-arg VERSION_PKG=${VERSION_PKG} -t "$(IMG)" . ${DOCKER_BUILD_OPTIONS}
$(VECHO)[ ! -z "$(PIPELINE)" ] || docker build --build-arg=GOPROXY=${GOPROXY} --build-arg=VERSION=${VERSION} --build-arg=JAEGER_VERSION=${JAEGER_VERSION} --build-arg=JAEGER_AGENT_VERSION=${JAEGER_AGENT_VERSION} --build-arg=TARGETARCH=$(GOARCH) --build-arg VERSION_DATE=${VERSION_DATE} --build-arg VERSION_PKG=${VERSION_PKG} -t "$(IMG)" . ${DOCKER_BUILD_OPTIONS}

.PHONY: dockerx
dockerx:
$(VECHO)[ ! -z "$(PIPELINE)" ] || docker buildx build --push --progress=plain --build-arg=VERSION=${VERSION} --build-arg=JAEGER_VERSION=${JAEGER_VERSION} --build-arg=GOPROXY=${GOPROXY} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg VERSION_PKG=${VERSION_PKG} --platform=$(PLATFORMS) $(IMAGE_TAGS) .
$(VECHO)[ ! -z "$(PIPELINE)" ] || docker buildx build --push --progress=plain --build-arg=VERSION=${VERSION} --build-arg=JAEGER_VERSION=${JAEGER_VERSION} --build-arg=JAEGER_AGENT_VERSION=${JAEGER_AGENT_VERSION} --build-arg=GOPROXY=${GOPROXY} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg VERSION_PKG=${VERSION_PKG} --platform=$(PLATFORMS) $(IMAGE_TAGS) .

.PHONY: push
push:
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (a *Agent) Get() *appsv1.DaemonSet {
Spec: corev1.PodSpec{
ImagePullSecrets: a.jaeger.Spec.Agent.ImagePullSecrets,
Containers: []corev1.Container{{
Image: util.ImageName(a.jaeger.Spec.Agent.Image, "jaeger-agent-image"),
Image: util.AgentImageName(a.jaeger.Spec.Agent.Image, "jaeger-agent-image"),
Name: "jaeger-agent-daemonset",
Args: args,
Env: proxy.ReadProxyVarsFromEnv(),
Expand Down
12 changes: 12 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,18 @@ func ImageName(image, param string) string {
return image
}

func AgentImageName(image, param string) string {
if image == "" {
param := viper.GetString(param)
if strings.IndexByte(param, ':') == -1 {
image = fmt.Sprintf("%s:%s", param, version.Get().Agent)
} else {
image = param
}
}
return image
}

// RemoveEmptyVars removes empty variables from the input slice.
func RemoveEmptyVars(envVars []corev1.EnvVar) []corev1.EnvVar {
var notEmpty []corev1.EnvVar
Expand Down
20 changes: 17 additions & 3 deletions pkg/version/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (
)

var (
version string
buildDate string
defaultJaeger string
version string
buildDate string
defaultJaeger string
defaultJaegerAgent string
)

// Version holds this Operator's version as well as the version of some of the components it uses
type Version struct {
Operator string `json:"jaeger-operator"`
BuildDate string `json:"build-date"`
Jaeger string `json:"jaeger-version"`
Agent string `json:"agent-version"`
Go string `json:"go-version"`
}

Expand All @@ -26,6 +28,7 @@ func Get() Version {
Operator: version,
BuildDate: buildDate,
Jaeger: DefaultJaeger(),
Agent: DefaultAgent(),
Go: runtime.Version(),
}
}
Expand All @@ -51,6 +54,17 @@ func DefaultJaeger() string {
return "0.0.0"
}

// DefaultAgent returns the default Jaeger to use when no versions are specified via CLI or configuration
func DefaultAgent() string {
if len(defaultJaegerAgent) > 0 {
// this should always be set, as it's specified during the build
return defaultJaegerAgent
}

// fallback value, useful for tests
return "0.0.0"
}

// DefaultJaegerMajorMinor returns the major.minor format of the default Jaeger version
func DefaultJaegerMajorMinor() string {
version := DefaultJaeger()
Expand Down

0 comments on commit 91ce545

Please sign in to comment.