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

Commit 026d008

Browse files
Restart setting in systemd units removed
1 parent 452f4d1 commit 026d008

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

CHANGELOG.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
* Annotation `featureLogs` added to the pods to indicate if logs can be
1010
retrieved with `kubectl logs` ({188}).
1111

12+
=== Changed
13+
* Restart setting in systemd units removed because the agent already
14+
monitors the units and restarts them according to the restart policy
15+
in the pod spec ({205}).
16+
1217
=== Fixed
1318
* Pods with restart policy `Never` handled correctly ({205}).
1419

src/provider/systemdmanager/systemdunit.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use kubelet::container::Container;
55
use kubelet::pod::Pod;
66

77
use crate::provider::error::StackableError;
8-
98
use crate::provider::error::StackableError::PodValidationError;
109
use crate::provider::states::pod::creating_config::CreatingConfig;
1110
use crate::provider::states::pod::PodState;
@@ -18,15 +17,6 @@ use std::fmt::{Display, Formatter};
1817
use std::iter;
1918
use strum::{Display, EnumIter, IntoEnumIterator};
2019

21-
lazy_static! {
22-
// This is used to map from Kubernetes restart lingo to systemd restart terms
23-
static ref RESTART_POLICY_MAP: HashMap<&'static str, &'static str> = [
24-
("Always", "always"),
25-
("OnFailure", "on-failure"),
26-
("Never", "no")
27-
].iter().cloned().collect();
28-
}
29-
3020
/// The default timeout for stopping a service, after this has passed systemd will terminate
3121
/// the process
3222
const DEFAULT_TERMINATION_TIMEOUT_SECS: i64 = 30;
@@ -205,26 +195,6 @@ impl SystemDUnit {
205195
}
206196
};
207197

208-
// Get restart policy from pod, if none is specified default to "Never"
209-
let restart_policy = pod_spec.restart_policy.as_deref().unwrap_or("Never");
210-
211-
// Lookup the equivalent systemd restart policy for the configured one
212-
// If this lookup fails (which means a restart policy was specified which we do not know
213-
// about) then we fail the entire service to avoid unpredictable behavior
214-
let restart_policy = match RESTART_POLICY_MAP.get(restart_policy) {
215-
Some(policy) => policy,
216-
None => {
217-
return Err(PodValidationError {
218-
msg: format!(
219-
"Unknown value [{}] for RestartPolicy in pod [{}]",
220-
restart_policy, unit.name
221-
),
222-
})
223-
}
224-
};
225-
226-
unit.add_property(Section::Service, "Restart", restart_policy);
227-
228198
// If `terminationGracePeriodSeconds` was specified in the PodSpec set the value as
229199
// 'TimeOutStopSec` on the systemd unit
230200
// This means that the service will be killed after this period if it does not shutdown
@@ -512,14 +482,12 @@ mod test {
512482
name: stackable
513483
spec:
514484
containers: []
515-
restartPolicy: Always
516485
securityContext:
517486
windowsOptions:
518487
runAsUserName: pod-user",
519488
"stackable.service",
520489
indoc! {"
521490
[Service]
522-
Restart=always
523491
TimeoutStopSec=30
524492
User=pod-user"}
525493
)]
@@ -557,7 +525,6 @@ mod test {
557525
[Service]
558526
Environment="LOG_DIR=/var/log/default-stackable" "LOG_LEVEL=INFO"
559527
ExecStart=start.sh arg /etc/default-stackable
560-
Restart=no
561528
StandardError=journal
562529
StandardOutput=journal
563530
TimeoutStopSec=30
@@ -591,7 +558,6 @@ mod test {
591558
592559
[Service]
593560
ExecStart=start.sh
594-
Restart=no
595561
StandardError=journal
596562
StandardOutput=journal
597563
TimeoutStopSec=30
@@ -612,7 +578,6 @@ mod test {
612578
"stackable.service",
613579
indoc! {"
614580
[Service]
615-
Restart=no
616581
TimeoutStopSec=10"}
617582
)]
618583

0 commit comments

Comments
 (0)