...

Source file src/k8s.io/kubernetes/cmd/kube-controller-manager/app/options/attachdetachcontroller.go

Documentation: k8s.io/kubernetes/cmd/kube-controller-manager/app/options

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    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  // AttachDetachControllerOptions holds the AttachDetachController options.
    28  type AttachDetachControllerOptions struct {
    29  	*attachdetachconfig.AttachDetachControllerConfiguration
    30  }
    31  
    32  // AddFlags adds flags related to AttachDetachController for controller manager to the specified FlagSet.
    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  // ApplyTo fills up AttachDetachController config with options.
    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  // Validate checks validation of AttachDetachControllerOptions.
    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