diff --git a/runtime/Makefile b/runtime/Makefile index a92b22738..15519fc52 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -22,6 +22,8 @@ DOCKER_IMAGE_TAG?=latest GO_CACHE_VOLUME_NAME?=gocache FIRECRACKER_CONTAINERD_TEST_IMAGE?=localhost/firecracker-containerd-test +REVISION=$(shell git rev-parse HEAD) + INTEG_TEST_SUFFIX := _Isolated INTEG_TESTNAMES=$(shell docker run --rm \ --network=none \ @@ -37,7 +39,7 @@ all: runtime runtime: containerd-shim-aws-firecracker containerd-shim-aws-firecracker: $(SOURCES) $(GOMOD) $(GOSUM) - go build -o containerd-shim-aws-firecracker $(EXTRAGOARGS) + go build -o containerd-shim-aws-firecracker $(EXTRAGOARGS) -ldflags "-X main.revision=$(REVISION)" install: containerd-shim-aws-firecracker install -D -o root -g root -m755 -t $(INSTALLROOT)/bin containerd-shim-aws-firecracker diff --git a/runtime/main.go b/runtime/main.go index 305e44970..015c99d95 100644 --- a/runtime/main.go +++ b/runtime/main.go @@ -23,6 +23,8 @@ import ( const shimID = "aws.firecracker" +var revision string + func init() { logrus.SetFormatter(&logrus.TextFormatter{ TimestampFormat: log.RFC3339NanoFixed, diff --git a/runtime/service.go b/runtime/service.go index 59b402b77..c8f7dea8e 100644 --- a/runtime/service.go +++ b/runtime/service.go @@ -215,6 +215,12 @@ func NewService(shimCtx context.Context, id string, remotePublisher shim.Publish return nil, err } + // The shim cannot support -version flag since + // - flag.Parse() is called by shim.Run(). So our main() cannot call flag.Parse() + // - NewService() won't be called when the TTRPC address is not specified by the flags + // Instead we log the version informaion + s.logger.Infof("successfully started %s (%s) for VM %s", shimID, revision, vmID) + return s, nil }