@@ -5,7 +5,6 @@ use kubelet::container::Container;
55use kubelet:: pod:: Pod ;
66
77use crate :: provider:: error:: StackableError ;
8-
98use crate :: provider:: error:: StackableError :: PodValidationError ;
109use crate :: provider:: states:: pod:: creating_config:: CreatingConfig ;
1110use crate :: provider:: states:: pod:: PodState ;
@@ -18,15 +17,6 @@ use std::fmt::{Display, Formatter};
1817use std:: iter;
1918use 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
3222const 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