operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.24k stars 1.74k forks source link

Semantic version in `metrics.builder` label is always off by 1 #5612

Closed adambkaplan closed 2 years ago

adambkaplan commented 2 years ago

Bug Report

When generating the bundle.Dockerfile and annotations.yml file, the version reported in the operators.operatorframework.io.metrics.builder label does not match the version of operator-sdk.

What did you do?

Run make bundle based on the standard operator-sdk scaffolding. (ultimately calls operator-sdk generate bundle)

What did you expect to see?

Version number in operators.operatorframework.io.metrics.builder matches the version of operator-sdk that generated the bundle

What did you see instead? Under which circumstances?

Version reported is one minor version behind, plus a +git extension:

LABEL operators.operatorframework.io.metrics.builder: operator-sdk-v1.16.0+git

Environment

Operator type:

/language go

Kubernetes cluster type:

"vanilla"

$ operator-sdk version

operator-sdk version: "v1.17.0", commit: "704b02a9ba86e85f43edb1b20457859e9eedc6e6", kubernetes version: "1.21", go version: "go1.17.6", GOOS: "linux", GOARCH: "amd64"

$ go version (if language is Go)

1.17.7

Possible Solution

Additional context

varshaprasad96 commented 2 years ago

+git is usually added if an unreleased (https://github.com/operator-framework/operator-sdk/blob/707240f006ecfc0bc86e5c21f6874d302992d598/internal/annotations/metrics/metrics.go#L72-L75) SDK version is used. Is this the downstream operator-sdk (shipped with openshift) or the upstream release?

adambkaplan commented 2 years ago

@varshaprasad96 this is the upstream release published on GitHub.

VenkatRamaraju commented 2 years ago

Hi @adambkaplan,

I am unable to reproduce this issue. I have tried checking the bundle labels with the exact version commit you referenced, and I get the following in the Dockerfile:

LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.17.0

I also tested this on the latest release (v1.18.1) and I get the correct labels in the Dockerfile.

Can you confirm that the version you referenced in your operator-sdk version command comes from the binary that is in your PATH?

VenkatRamaraju commented 2 years ago

Hi @adambkaplan,

I am closing this issue for now. Feel free to reopen it if the error persists.

steknowis commented 2 years ago

@VenkatRamaraju Unfortunately I also have this issue.

I am building a container image and pull the operator-sdk binary directly from the GitHub releases like this:

# Operator-SDK
RUN export OPERATORSDK_SRC="https://github.com/operator-framework/operator-sdk/releases/download/v1.18.0/operator-sdk_linux_amd64" \
  && export OPERATORSDK_DST="/usr/local/bin/operator-sdk" \
  && echo "Download operator-sdk [OPERATORSDK_SRC=${OPERATORSDK_SRC}, OPERATORSDK_DST=${OPERATORSDK_DST}]" \
  && wget -q "${OPERATORSDK_SRC}" -O "${OPERATORSDK_DST}" \
  && chmod a+rx,a-w "${OPERATORSDK_DST}"

Output of operator-sdk version:

operator-sdk version: "v1.18.0", commit: "c9c61b6921b29d731e64cd3cc33d268215fb3b25", kubernetes version: "1.21", go version: "go1.17.7", GOOS: "linux", GOARCH: "amd64"

I get the same output as @adambkaplan that make bundle produces following line in the bundle/metadata/annotations.yaml:

operators.operatorframework.io.metrics.builder: operator-sdk-v1.17.0+git

Even though the operator-sdk version is 1.18.0 and is an official release, the annotation shows an older version and a "+git" suffix.

I also noticed that if you have a patch version, like 1.18.1, then the annotation looks like this: operators.operatorframework.io.metrics.builder: operator-sdk-v1.18.0+git

VenkatRamaraju commented 2 years ago

Hey @steknowis @adambkaplan,

Thanks for bringing this up again. I spent some more time looking into it. Looks like the command in our Makefile that adds the SDK version annotations did not include lightweight tags. The PR linked above fixes this issue. I'll follow up on this issue once it gets merged into master.

VenkatRamaraju commented 2 years ago

Hey @steknowis @adambkaplan,

The PR that fixes this issue just went in. Please rebase on the master branch and let me know if the correct SDK version shows up in the annotations. I'll leave the issue open for now.

@steknowis I tested this fix on the latest 1.20.0 release commit and saw this exact version show up in the annotations (without the +git).

steknowis commented 2 years ago

As far as I can tell, this is fixed. Thank you for the quick response!