mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
agent: Fix setting of version
Fix the bug where the version string generated by the `Makefile` was not being passed to the agent, resulting in a "unknown" version. Fixes: #725. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
c823b4cd99
commit
f13ca94e10
@ -57,12 +57,16 @@ INIT := no
|
|||||||
# Path to systemd unit directory if installed as not init.
|
# Path to systemd unit directory if installed as not init.
|
||||||
UNIT_DIR := /usr/lib/systemd/system
|
UNIT_DIR := /usr/lib/systemd/system
|
||||||
|
|
||||||
|
GENERATED_CODE = src/generated.rs
|
||||||
|
|
||||||
GENERATED_FILES :=
|
GENERATED_FILES :=
|
||||||
|
|
||||||
|
GENERATED_FILES += $(GENERATED_CODE)
|
||||||
|
|
||||||
ifeq ($(INIT),no)
|
ifeq ($(INIT),no)
|
||||||
# Unit file to start kata agent in systemd systems
|
# Unit file to start kata agent in systemd systems
|
||||||
UNIT_FILES = kata-agent.service
|
UNIT_FILES = kata-agent.service
|
||||||
GENERATED_FILES := $(UNIT_FILES)
|
GENERATED_FILES += $(UNIT_FILES)
|
||||||
# Target to be reached in systemd services
|
# Target to be reached in systemd services
|
||||||
UNIT_FILES += kata-containers.target
|
UNIT_FILES += kata-containers.target
|
||||||
endif
|
endif
|
||||||
@ -86,7 +90,7 @@ endef
|
|||||||
|
|
||||||
default: $(TARGET) show-header
|
default: $(TARGET) show-header
|
||||||
|
|
||||||
$(TARGET): $(TARGET_PATH)
|
$(TARGET): $(GENERATED_CODE) $(TARGET_PATH)
|
||||||
|
|
||||||
$(TARGET_PATH): $(SOURCES) | show-summary
|
$(TARGET_PATH): $(SOURCES) | show-summary
|
||||||
@cargo build --target $(TRIPLE) --$(BUILD_TYPE)
|
@cargo build --target $(TRIPLE) --$(BUILD_TYPE)
|
||||||
@ -101,6 +105,7 @@ $(GENERATED_FILES): %: %.in
|
|||||||
@sed \
|
@sed \
|
||||||
-e 's|[@]bindir[@]|$(BINDIR)|g' \
|
-e 's|[@]bindir[@]|$(BINDIR)|g' \
|
||||||
-e 's|[@]kata-agent[@]|$(TARGET)|g' \
|
-e 's|[@]kata-agent[@]|$(TARGET)|g' \
|
||||||
|
-e 's|[@]VERSION_COMMIT[@]|$(VERSION_COMMIT)|g' \
|
||||||
"$<" > "$@"
|
"$<" > "$@"
|
||||||
|
|
||||||
install: build-service
|
install: build-service
|
||||||
|
10
src/agent/src/generated.rs.in
Normal file
10
src/agent/src/generated.rs.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) 2020 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// WARNING: This file is auto-generated - DO NOT EDIT!
|
||||||
|
//
|
||||||
|
|
||||||
|
pub const VERSION_COMMIT: &str = "@VERSION_COMMIT@";
|
@ -52,6 +52,7 @@ use unistd::Pid;
|
|||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod device;
|
mod device;
|
||||||
|
mod generated;
|
||||||
mod linux_abi;
|
mod linux_abi;
|
||||||
mod metrics;
|
mod metrics;
|
||||||
mod mount;
|
mod mount;
|
||||||
@ -83,13 +84,8 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn announce(logger: &Logger, config: &agentConfig) {
|
fn announce(logger: &Logger, config: &agentConfig) {
|
||||||
let commit = match env::var("VERSION_COMMIT") {
|
|
||||||
Ok(s) => s,
|
|
||||||
Err(_) => String::from(""),
|
|
||||||
};
|
|
||||||
|
|
||||||
info!(logger, "announce";
|
info!(logger, "announce";
|
||||||
"agent-commit" => commit.as_str(),
|
"agent-commit" => generated::VERSION_COMMIT,
|
||||||
|
|
||||||
// Avoid any possibility of confusion with the old agent
|
// Avoid any possibility of confusion with the old agent
|
||||||
"agent-type" => "rust",
|
"agent-type" => "rust",
|
||||||
@ -109,7 +105,7 @@ fn main() -> Result<()> {
|
|||||||
NAME,
|
NAME,
|
||||||
version::AGENT_VERSION,
|
version::AGENT_VERSION,
|
||||||
version::API_VERSION,
|
version::API_VERSION,
|
||||||
env::var("VERSION_COMMIT").unwrap_or("unknown".to_string())
|
generated::VERSION_COMMIT,
|
||||||
);
|
);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user