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 4 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.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
# 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
Copy link
Member

Choose a reason for hiding this comment

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

Maybe update this comment?
To say why we reference a fork.

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"}
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