Skip to content

Commit

Permalink
Merge pull request #1720 from aleksandra-malinowska/events-client
Browse files Browse the repository at this point in the history
Use separate client for events
  • Loading branch information
k8s-ci-robot authored Feb 26, 2019
2 parents 1018549 + f304722 commit 8944afd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cluster-autoscaler/context/autoscaling_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ func NewAutoscalingContext(options config.AutoscalingOptions, predicateChecker *
}

// NewAutoscalingKubeClients builds AutoscalingKubeClients out of basic client.
func NewAutoscalingKubeClients(opts config.AutoscalingOptions, kubeClient kube_client.Interface) *AutoscalingKubeClients {
func NewAutoscalingKubeClients(opts config.AutoscalingOptions, kubeClient, eventsKubeClient kube_client.Interface) *AutoscalingKubeClients {
listerRegistryStopChannel := make(chan struct{})
listerRegistry := kube_util.NewListerRegistryWithDefaultListers(kubeClient, listerRegistryStopChannel)
kubeEventRecorder := kube_util.CreateEventRecorder(kubeClient)
kubeEventRecorder := kube_util.CreateEventRecorder(eventsKubeClient)
logRecorder, err := utils.NewStatusMapRecorder(kubeClient, opts.ConfigNamespace, kubeEventRecorder, opts.WriteStatusConfigMap)
if err != nil {
klog.Error("Failed to initialize status configmap, unable to write status events")
// Get a dummy, so we can at least safely call the methods
// TODO(maciekpytel): recover from this after successful status configmap update?
logRecorder, _ = utils.NewStatusMapRecorder(kubeClient, opts.ConfigNamespace, kubeEventRecorder, false)
logRecorder, _ = utils.NewStatusMapRecorder(eventsKubeClient, opts.ConfigNamespace, kubeEventRecorder, false)
}

return &AutoscalingKubeClients{
Expand Down
3 changes: 2 additions & 1 deletion cluster-autoscaler/core/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
type AutoscalerOptions struct {
config.AutoscalingOptions
KubeClient kube_client.Interface
EventsKubeClient kube_client.Interface
AutoscalingKubeClients *context.AutoscalingKubeClients
CloudProvider cloudprovider.CloudProvider
PredicateChecker *simulator.PredicateChecker
Expand Down Expand Up @@ -78,7 +79,7 @@ func initializeDefaultOptions(opts *AutoscalerOptions) error {
opts.Processors = ca_processors.DefaultProcessors()
}
if opts.AutoscalingKubeClients == nil {
opts.AutoscalingKubeClients = context.NewAutoscalingKubeClients(opts.AutoscalingOptions, opts.KubeClient)
opts.AutoscalingKubeClients = context.NewAutoscalingKubeClients(opts.AutoscalingOptions, opts.KubeClient, opts.EventsKubeClient)
}
if opts.PredicateChecker == nil {
predicateCheckerStopChannel := make(chan struct{})
Expand Down
2 changes: 2 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func buildAutoscaler() (core.Autoscaler, error) {
// Create basic config from flags.
autoscalingOptions := createAutoscalingOptions()
kubeClient := createKubeClient(getKubeConfig())
eventsKubeClient := createKubeClient(getKubeConfig())
processors := ca_processors.DefaultProcessors()
if autoscalingOptions.CloudProviderName == "gke" {
processors.NodeGroupSetProcessor = &nodegroupset.BalancingNodeGroupSetProcessor{
Expand All @@ -283,6 +284,7 @@ func buildAutoscaler() (core.Autoscaler, error) {
opts := core.AutoscalerOptions{
AutoscalingOptions: autoscalingOptions,
KubeClient: kubeClient,
EventsKubeClient: eventsKubeClient,
Processors: processors,
}

Expand Down

0 comments on commit 8944afd

Please sign in to comment.