...

Source file src/k8s.io/kubernetes/cmd/kube-controller-manager/app/options/jobcontroller.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  
    22  	"github.com/spf13/pflag"
    23  
    24  	jobconfig "k8s.io/kubernetes/pkg/controller/job/config"
    25  )
    26  
    27  // JobControllerOptions holds the JobController options.
    28  type JobControllerOptions struct {
    29  	*jobconfig.JobControllerConfiguration
    30  }
    31  
    32  // AddFlags adds flags related to JobController for controller manager to the specified FlagSet.
    33  func (o *JobControllerOptions) AddFlags(fs *pflag.FlagSet) {
    34  	if o == nil {
    35  		return
    36  	}
    37  
    38  	fs.Int32Var(&o.ConcurrentJobSyncs, "concurrent-job-syncs", o.ConcurrentJobSyncs, "The number of job objects that are allowed to sync concurrently. Larger number = more responsive jobs, but more CPU (and network) load")
    39  }
    40  
    41  // ApplyTo fills up JobController config with options.
    42  func (o *JobControllerOptions) ApplyTo(cfg *jobconfig.JobControllerConfiguration) error {
    43  	if o == nil {
    44  		return nil
    45  	}
    46  
    47  	cfg.ConcurrentJobSyncs = o.ConcurrentJobSyncs
    48  
    49  	return nil
    50  }
    51  
    52  // Validate checks validation of JobControllerOptions.
    53  func (o *JobControllerOptions) Validate() []error {
    54  	if o == nil {
    55  		return nil
    56  	}
    57  
    58  	errs := []error{}
    59  	if o.ConcurrentJobSyncs < 1 {
    60  		errs = append(errs, fmt.Errorf("concurrent-job-syncs must be greater than 0, but got %d", o.ConcurrentJobSyncs))
    61  	}
    62  	return errs
    63  }
    64  

View as plain text