@@ -5,7 +5,6 @@ use kubelet::container::Container;
5
5
use kubelet:: pod:: Pod ;
6
6
7
7
use crate :: provider:: error:: StackableError ;
8
-
9
8
use crate :: provider:: error:: StackableError :: PodValidationError ;
10
9
use crate :: provider:: states:: pod:: creating_config:: CreatingConfig ;
11
10
use crate :: provider:: states:: pod:: PodState ;
@@ -18,15 +17,6 @@ use std::fmt::{Display, Formatter};
18
17
use std:: iter;
19
18
use strum:: { Display , EnumIter , IntoEnumIterator } ;
20
19
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
-
30
20
/// The default timeout for stopping a service, after this has passed systemd will terminate
31
21
/// the process
32
22
const DEFAULT_TERMINATION_TIMEOUT_SECS : i64 = 30 ;
@@ -205,26 +195,6 @@ impl SystemDUnit {
205
195
}
206
196
} ;
207
197
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
-
228
198
// If `terminationGracePeriodSeconds` was specified in the PodSpec set the value as
229
199
// 'TimeOutStopSec` on the systemd unit
230
200
// This means that the service will be killed after this period if it does not shutdown
@@ -512,14 +482,12 @@ mod test {
512
482
name: stackable
513
483
spec:
514
484
containers: []
515
- restartPolicy: Always
516
485
securityContext:
517
486
windowsOptions:
518
487
runAsUserName: pod-user" ,
519
488
"stackable.service" ,
520
489
indoc! { "
521
490
[Service]
522
- Restart=always
523
491
TimeoutStopSec=30
524
492
User=pod-user" }
525
493
) ]
@@ -557,7 +525,6 @@ mod test {
557
525
[Service]
558
526
Environment="LOG_DIR=/var/log/default-stackable" "LOG_LEVEL=INFO"
559
527
ExecStart=start.sh arg /etc/default-stackable
560
- Restart=no
561
528
StandardError=journal
562
529
StandardOutput=journal
563
530
TimeoutStopSec=30
@@ -591,7 +558,6 @@ mod test {
591
558
592
559
[Service]
593
560
ExecStart=start.sh
594
- Restart=no
595
561
StandardError=journal
596
562
StandardOutput=journal
597
563
TimeoutStopSec=30
@@ -612,7 +578,6 @@ mod test {
612
578
"stackable.service" ,
613
579
indoc! { "
614
580
[Service]
615
- Restart=no
616
581
TimeoutStopSec=10" }
617
582
) ]
618
583
0 commit comments