...
1
16
17 package options
18
19 import (
20 "fmt"
21 "github.com/spf13/pflag"
22 "time"
23
24 attachdetachconfig "k8s.io/kubernetes/pkg/controller/volume/attachdetach/config"
25 )
26
27
28 type AttachDetachControllerOptions struct {
29 *attachdetachconfig.AttachDetachControllerConfiguration
30 }
31
32
33 func (o *AttachDetachControllerOptions) AddFlags(fs *pflag.FlagSet) {
34 if o == nil {
35 return
36 }
37
38 fs.BoolVar(&o.DisableAttachDetachReconcilerSync, "disable-attach-detach-reconcile-sync", false, "Disable volume attach detach reconciler sync. Disabling this may cause volumes to be mismatched with pods. Use wisely.")
39 fs.DurationVar(&o.ReconcilerSyncLoopPeriod.Duration, "attach-detach-reconcile-sync-period", o.ReconcilerSyncLoopPeriod.Duration, "The reconciler sync wait time between volume attach detach. This duration must be larger than one second, and increasing this value from the default may allow for volumes to be mismatched with pods.")
40 fs.BoolVar(&o.DisableForceDetachOnTimeout, "disable-force-detach-on-timeout", false, "Prevent force detaching volumes based on maximum unmount time and node status. If this flag is set to true, the non-graceful node shutdown feature must be used to recover from node failure. See https://k8s.io/docs/storage-disable-force-detach-on-timeout/.")
41 }
42
43
44 func (o *AttachDetachControllerOptions) ApplyTo(cfg *attachdetachconfig.AttachDetachControllerConfiguration) error {
45 if o == nil {
46 return nil
47 }
48
49 cfg.DisableAttachDetachReconcilerSync = o.DisableAttachDetachReconcilerSync
50 cfg.ReconcilerSyncLoopPeriod = o.ReconcilerSyncLoopPeriod
51 cfg.DisableForceDetachOnTimeout = o.DisableForceDetachOnTimeout
52
53 return nil
54 }
55
56
57 func (o *AttachDetachControllerOptions) Validate() []error {
58 if o == nil {
59 return nil
60 }
61
62 errs := []error{}
63
64 if o.ReconcilerSyncLoopPeriod.Duration < time.Second {
65 errs = append(errs, fmt.Errorf("duration time must be greater than one second as set via command line option reconcile-sync-loop-period"))
66 }
67
68 return errs
69 }
70
View as plain text