From 6612eba3b8ac1c71fa6e69fd6e1e4daa0a089b0c Mon Sep 17 00:00:00 2001 From: Vishal Thapar <5137689+vthapar@users.noreply.github.com> Date: Tue, 20 Jun 2023 19:46:07 +0530 Subject: [PATCH] Log version in lighthouse pods Log version for Lighthoue agent and coredns pods on startup. Fixes #1279 Signed-off-by: Vishal Thapar <5137689+vthapar@users.noreply.github.com> --- Makefile | 1 + coredns/main.go | 5 ++++- coredns/plugin/setup.go | 3 ++- pkg/agent/main.go | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 88b58cdc9..0c672c478 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ TARGETS := $(shell ls -p scripts | grep -v -e / -e deploy) override E2E_ARGS += cluster1 cluster2 cluster3 override UNIT_TEST_ARGS += test/e2e export LIGHTHOUSE = true +export LDFLAGS = -X main.version=$(VERSION) # Targets to make diff --git a/coredns/main.go b/coredns/main.go index a90548c69..c57505309 100644 --- a/coredns/main.go +++ b/coredns/main.go @@ -61,7 +61,7 @@ import ( _ "github.com/coredns/coredns/plugin/tls" _ "github.com/coredns/coredns/plugin/trace" _ "github.com/coredns/coredns/plugin/whoami" - _ "github.com/submariner-io/lighthouse/coredns/plugin" + lighthouse "github.com/submariner-io/lighthouse/coredns/plugin" ) var directives = []string{ @@ -105,7 +105,10 @@ var directives = []string{ "on", } +var version = "not-compiled-properly" + func init() { + lighthouse.Version = version dnsserver.Directives = directives } diff --git a/coredns/plugin/setup.go b/coredns/plugin/setup.go index 21658546c..b081e4aec 100644 --- a/coredns/plugin/setup.go +++ b/coredns/plugin/setup.go @@ -42,6 +42,7 @@ import ( var ( masterURL string kubeconfig string + Version string ) // Hooks for unit tests. @@ -70,7 +71,7 @@ func init() { // setup is the function that gets called when the config parser see the token "lighthouse". Setup is responsible // for parsing any extra options the this plugin may have. The first token this function sees is "lighthouse". func setupLighthouse(c *caddy.Controller) error { - log.Debug("In setupLighthouse") + log.Infof("submariner-lighthouse-coredns version: %v", Version) l, err := lighthouseParse(c) if err != nil { diff --git a/pkg/agent/main.go b/pkg/agent/main.go index 6e860a979..00a48d226 100644 --- a/pkg/agent/main.go +++ b/pkg/agent/main.go @@ -48,6 +48,7 @@ var ( kubeConfig string help = false logger = log.Logger{Logger: logf.Log.WithName("main")} + version = "not-compiled-properly" ) func init() { @@ -111,7 +112,7 @@ func main() { localClient, err := dynamic.NewForConfig(cfg) exitOnError(err, "Error creating dynamic client") - logger.Info("Starting submariner-lighthouse-agent") + logger.Infof("submariner-lighthouse-agent version: %v", version) // set up signals so we handle the first shutdown signal gracefully ctx := signals.SetupSignalHandler()