From 06c6abcf1419f44b0787353827a7eee219d60eed Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Dec 2024 22:14:50 +0200 Subject: [PATCH 1/3] Fix version parsing The fix in a416af51a48d5d49cc0f17b069b3fc6e8566bedd was not enough by itself and that needs to be applied comprehensively. (cherry picked from commit 047d0314aa91c7e81a87914789e75b97b330ed5e) --- cmd/nfd-gc/main.go | 2 +- cmd/nfd-master/main.go | 2 +- cmd/nfd-topology-updater/main.go | 2 +- cmd/nfd-worker/main.go | 2 +- scripts/github/update-gh-pages.sh | 4 ++-- scripts/test-infra/test-e2e-presubmit.sh | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/nfd-gc/main.go b/cmd/nfd-gc/main.go index 6093ac761..799185514 100644 --- a/cmd/nfd-gc/main.go +++ b/cmd/nfd-gc/main.go @@ -47,7 +47,7 @@ func main() { // Assert that the version is known if version.Undefined() { - klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.") + klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always --match 'v*'`\" during build or run.") } // Get new garbage collector instance diff --git a/cmd/nfd-master/main.go b/cmd/nfd-master/main.go index bfc781a8f..56c60ec64 100644 --- a/cmd/nfd-master/main.go +++ b/cmd/nfd-master/main.go @@ -102,7 +102,7 @@ func main() { // Assert that the version is known if version.Undefined() { - klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.") + klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always --match 'v*'`\" during build or run.") } // Plug klog into grpc logging infrastructure diff --git a/cmd/nfd-topology-updater/main.go b/cmd/nfd-topology-updater/main.go index dc6bee50d..89fe8c57e 100644 --- a/cmd/nfd-topology-updater/main.go +++ b/cmd/nfd-topology-updater/main.go @@ -49,7 +49,7 @@ func main() { // Assert that the version is known if version.Undefined() { - klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.") + klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always --match 'v*'`\" during build or run.") } // Plug klog into grpc logging infrastructure diff --git a/cmd/nfd-worker/main.go b/cmd/nfd-worker/main.go index 83ff12445..cdbdc478d 100644 --- a/cmd/nfd-worker/main.go +++ b/cmd/nfd-worker/main.go @@ -56,7 +56,7 @@ func main() { // Assert that the version is known if version.Undefined() { - klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.") + klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always --match 'v*'`\" during build or run.") } // Check deprecated flags diff --git a/scripts/github/update-gh-pages.sh b/scripts/github/update-gh-pages.sh index 94d53a452..44515c706 100755 --- a/scripts/github/update-gh-pages.sh +++ b/scripts/github/update-gh-pages.sh @@ -111,7 +111,7 @@ if [ "$site_subdir" != "master" ]; then ;; *) echo "Not a released version. Parsed release branch is $site_subdir but based on tag $_base_tag. Stopping here." - echo "SHA `git describe` (`git rev-parse HEAD`)" + echo "SHA `git describe` (`git rev-parse --match 'v*' HEAD`)" exit 0 ;; esac @@ -130,7 +130,7 @@ make site-build if [ -n "$_GIT_TAG" ]; then commit_hash=${GIT_TAG:10} else - commit_hash=`git describe --tags --dirty --always` + commit_hash=`git describe --tags --dirty --always --match "v*"` fi # Sync OWNERS file from master branch diff --git a/scripts/test-infra/test-e2e-presubmit.sh b/scripts/test-infra/test-e2e-presubmit.sh index 6905d148f..dd10fa8d2 100755 --- a/scripts/test-infra/test-e2e-presubmit.sh +++ b/scripts/test-infra/test-e2e-presubmit.sh @@ -4,7 +4,7 @@ set -o pipefail # Configure environment KIND_IMAGE="kindest/node:v1.25.3" export IMAGE_REGISTRY="localhost:5001" -export CLUSTER_NAME=$(git describe --tags --dirty --always) +export CLUSTER_NAME=$(git describe --tags --dirty --always --match "v*") export KUBECONFIG="/tmp/kubeconfig_$CLUSTER_NAME" # create registry container unless it already exists From 2dc9589602165b2eab4da054c0ebb97a9e547371 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 13 Dec 2024 10:49:42 +0200 Subject: [PATCH 2/3] Makefile: fix version parsing One bit that was accidentally left out from 047d0314aa91c7e81a87914789e75b97b330ed5e (cherry picked from commit 55961cc337b60d6c0d6c593e38227f51f81a1004) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7132d3beb..27a870aa6 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ SITE_BASEURL ?= SITE_DESTDIR ?= _site JEKYLL_OPTS := -d '$(SITE_DESTDIR)' $(if $(SITE_BASEURL),-b '$(SITE_BASEURL)',) -VERSION := $(shell git describe --tags --dirty --always) +VERSION := $(shell git describe --tags --dirty --always --match "v*") IMAGE_REGISTRY ?= registry.k8s.io/nfd IMAGE_TAG_NAME ?= $(VERSION) From f99c1dda4196106ef209b538d9f25ae19314e39a Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Dec 2024 11:01:17 +0200 Subject: [PATCH 3/3] scripts/update-gh-pages: fix release version parsing When determining the release branch only consider "main" release tags, refusing to pick api/nfd/v* tags. (cherry picked from commit a416af51a48d5d49cc0f17b069b3fc6e8566bedd) --- scripts/github/update-gh-pages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/github/update-gh-pages.sh b/scripts/github/update-gh-pages.sh index 44515c706..f3e3ba553 100755 --- a/scripts/github/update-gh-pages.sh +++ b/scripts/github/update-gh-pages.sh @@ -105,7 +105,7 @@ site_subdir=${site_subdir:-master} # Check if this ref is for a released version if [ "$site_subdir" != "master" ]; then - _base_tag=`git describe --abbrev=0 || :` + _base_tag=`git describe --abbrev=0 --match "v*" || :` case "$_base_tag" in $site_subdir*) ;;