Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Enable agent restart without impacting running services #63

Merged
merged 6 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ authors = ["Sönke Liebau <soenke.liebau@stackable.de>"]
edition = "2018"

[dependencies]
# We are currently referencing the Krustlet directly from the repository, because some features that we are using have
# (exponential backoff most prominently) have not yet been included in a release
# We will look to move this to officially released versions as soon as possible
kubelet = { git="https://github.com/deislabs/krustlet.git", rev="ac218b38ba564de806568e49d9e38aaef9f41537", default-features = true, features= ["derive", "cli"] }
oci-distribution = { git="https://github.com/deislabs/krustlet.git", rev="ac218b38ba564de806568e49d9e38aaef9f41537"}
# We are currently referencing the Krustlet directly from a Stackable fork of the official repository.
# There are two reasons for this, the fork is needed to remove the node draining behavior of the Krustlet (see
# https://github.com/deislabs/krustlet/issues/523)
# Our fork / the referenced commit is quite a bit behind the official repo, as there were some breaking changes in the
# 0.6 release that we need to adapt the Krustlet to.
# We will look to move to the latest version as soon as possible, but may need to continue releasing from a fork.
kubelet = { git="https://github.com/stackabletech/krustlet.git", rev="bb8bb42c9400a565df4be04f357e61934fb277c6", default-features = true, features= ["derive", "cli"] }
oci-distribution = { git="https://github.com/stackabletech/krustlet.git", rev="bb8bb42c9400a565df4be04f357e61934fb277c6"}
k8s-openapi = { version = "0.9", default-features = false, features = ["v1_18"] }
kube = { version= "0.42", default-features = false, features = ["native-tls"] }
kube-derive = "0.43"
Expand Down
22 changes: 22 additions & 0 deletions src/provider/states/starting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ impl State<PodState> for Starting {
async fn next(self: Box<Self>, pod_state: &mut PodState, _: &Pod) -> Transition<PodState> {
if let Some(systemd_units) = &pod_state.service_units {
for unit in systemd_units {
match pod_state.systemd_manager.is_running(&unit.get_name()) {
Copy link
Member

Choose a reason for hiding this comment

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

I hate that this is basically a copy from below but I don't know a better way right now either...

Ok(true) => {
debug!(
"Unit [{}] for service [{}] already running, nothing to do..",
&unit.get_name(),
&pod_state.service_name
);
// Skip rest of loop as the service is already running
continue;
}
Err(dbus_error) => {
debug!(
"Error retrieving activestate of unit [{}] for service [{}]: [{}]",
&unit.get_name(),
&pod_state.service_name,
dbus_error
);
return Transition::Complete(Err(dbus_error));
}
_ => { // nothing to do, just keep going
}
}
info!("Starting systemd unit [{}]", unit);
if let Err(start_error) = pod_state.systemd_manager.start(&unit.get_name()) {
error!(
Expand Down