Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tag info to docker label meta data #2058

Merged
merged 3 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ sonic_get_version() {
local latest_tag=$(git describe --tags --abbrev=0)
local branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$(git status --untracked-files=no -s --ignore-submodules)" ]; then
local dirty="-dirty-$DIRTY_SUFFIX"
if [ -z "$DIRTY_SUFFIX" ]; then
local dirty="-dirty-"$(date +%Y%m%d\.%H%M%S)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIRTY_SUFFIX is defined in slave.mk, why do we need this check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried changes like moving DIRTY_SUFFIX before SONIC_GET_VERSION

DIRTY_SUFFIX="$(shell date +%Y%m%d\.%H%M%S)"
SONIC_GET_VERSION=$(shell . functions.sh && sonic_get_version)

And even export DIRTY_SUFFIX before docker build. They didn't work, tag like "warm-reboot.0-dirty-" was populated.
I guess there is some evaluation issue with layered macro with shell command in Makefile.

If you have any new idea or different way of handling it, I may give it a try.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does DIRTY_SUFFIX work now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIRTY_SUFFIX works if sonic_get_version() is called from another shell script. But calling it in Makefile is not working. I have not figured out how to do it.

Since DIRTY_SUFFIX is only used in sonic_get_version(), but defined in slave.mk, maybe it should be moved to sonic_get_version() to get rid of the issue introduced with jumping from Makefile to shell and back to Makefile again.

else
local dirty="-dirty-$DIRTY_SUFFIX"
fi
fi
BUILD_NUMBER=${BUILD_NUMBER:-0}
## Check if we are on tagged commit
Expand Down
3 changes: 3 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SHELL = /bin/bash
USER = $(shell id -un)
UID = $(shell id -u)
GUID = $(shell id -g)
SONIC_GET_VERSION=$(shell . functions.sh && sonic_get_version)

.SECONDEXPANSION:

Expand Down Expand Up @@ -393,6 +394,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.g
--build-arg uid=$(UID) \
--build-arg guid=$(GUID) \
--build-arg docker_container_name=$($*.gz_CONTAINER_NAME) \
--label Tag=$(SONIC_GET_VERSION) \
-t $* $($*.gz_PATH) $(LOG)
docker save $* | gzip -c > $@
# Clean up
Expand Down Expand Up @@ -425,6 +427,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .pl
--build-arg uid=$(UID) \
--build-arg guid=$(GUID) \
--build-arg docker_container_name=$($*.gz_CONTAINER_NAME) \
--label Tag=$(SONIC_GET_VERSION) \
-t $* $($*.gz_PATH) $(LOG)
docker save $* | gzip -c > $@
# Clean up
Expand Down