mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Clean shutdown of serving integration test
This commit is contained in:
parent
c84c27b6ac
commit
3786cfdf85
@ -222,6 +222,15 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
|||||||
c.ComponentConfig = *cfg
|
c.ComponentConfig = *cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build kubeconfig first to so that if it fails, it doesn't cause leaking
|
||||||
|
// goroutines (started from initializing secure serving - which underneath
|
||||||
|
// creates a queue which in its constructor starts a goroutine).
|
||||||
|
kubeConfig, err := createKubeConfig(c.ComponentConfig.ClientConnection, o.Master)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.KubeConfig = kubeConfig
|
||||||
|
|
||||||
if err := o.SecureServing.ApplyTo(&c.SecureServing, &c.LoopbackClientConfig); err != nil {
|
if err := o.SecureServing.ApplyTo(&c.SecureServing, &c.LoopbackClientConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -271,14 +280,8 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare kube config.
|
|
||||||
kubeConfig, err := createKubeConfig(c.ComponentConfig.ClientConnection, o.Master)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare kube clients.
|
// Prepare kube clients.
|
||||||
client, eventClient, err := createClients(kubeConfig)
|
client, eventClient, err := createClients(c.KubeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -294,16 +297,15 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
|
|||||||
schedulerName = c.ComponentConfig.Profiles[0].SchedulerName
|
schedulerName = c.ComponentConfig.Profiles[0].SchedulerName
|
||||||
}
|
}
|
||||||
coreRecorder := c.EventBroadcaster.DeprecatedNewLegacyRecorder(schedulerName)
|
coreRecorder := c.EventBroadcaster.DeprecatedNewLegacyRecorder(schedulerName)
|
||||||
leaderElectionConfig, err = makeLeaderElectionConfig(c.ComponentConfig.LeaderElection, kubeConfig, coreRecorder)
|
leaderElectionConfig, err = makeLeaderElectionConfig(c.ComponentConfig.LeaderElection, c.KubeConfig, coreRecorder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Client = client
|
c.Client = client
|
||||||
c.KubeConfig = kubeConfig
|
|
||||||
c.InformerFactory = scheduler.NewInformerFactory(client, 0)
|
c.InformerFactory = scheduler.NewInformerFactory(client, 0)
|
||||||
dynClient := dynamic.NewForConfigOrDie(kubeConfig)
|
dynClient := dynamic.NewForConfigOrDie(c.KubeConfig)
|
||||||
c.DynInformerFactory = dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynClient, 0, corev1.NamespaceAll, nil)
|
c.DynInformerFactory = dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynClient, 0, corev1.NamespaceAll, nil)
|
||||||
c.LeaderElection = leaderElectionConfig
|
c.LeaderElection = leaderElectionConfig
|
||||||
|
|
||||||
|
@ -138,6 +138,20 @@ func (o *CloudControllerManagerOptions) Flags(allControllers, disabledByDefaultC
|
|||||||
// ApplyTo fills up cloud controller manager config with options.
|
// ApplyTo fills up cloud controller manager config with options.
|
||||||
func (o *CloudControllerManagerOptions) ApplyTo(c *config.Config, userAgent string) error {
|
func (o *CloudControllerManagerOptions) ApplyTo(c *config.Config, userAgent string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
// Build kubeconfig first to so that if it fails, it doesn't cause leaking
|
||||||
|
// goroutines (started from initializing secure serving - which underneath
|
||||||
|
// creates a queue which in its constructor starts a goroutine).
|
||||||
|
c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(o.Master, o.Kubeconfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.Kubeconfig.DisableCompression = true
|
||||||
|
c.Kubeconfig.ContentConfig.AcceptContentTypes = o.Generic.ClientConnection.AcceptContentTypes
|
||||||
|
c.Kubeconfig.ContentConfig.ContentType = o.Generic.ClientConnection.ContentType
|
||||||
|
c.Kubeconfig.QPS = o.Generic.ClientConnection.QPS
|
||||||
|
c.Kubeconfig.Burst = int(o.Generic.ClientConnection.Burst)
|
||||||
|
|
||||||
if err = o.Generic.ApplyTo(&c.ComponentConfig.Generic); err != nil {
|
if err = o.Generic.ApplyTo(&c.ComponentConfig.Generic); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -159,16 +173,6 @@ func (o *CloudControllerManagerOptions) ApplyTo(c *config.Config, userAgent stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Kubeconfig, err = clientcmd.BuildConfigFromFlags(o.Master, o.Kubeconfig)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c.Kubeconfig.DisableCompression = true
|
|
||||||
c.Kubeconfig.ContentConfig.AcceptContentTypes = o.Generic.ClientConnection.AcceptContentTypes
|
|
||||||
c.Kubeconfig.ContentConfig.ContentType = o.Generic.ClientConnection.ContentType
|
|
||||||
c.Kubeconfig.QPS = o.Generic.ClientConnection.QPS
|
|
||||||
c.Kubeconfig.Burst = int(o.Generic.ClientConnection.Burst)
|
|
||||||
|
|
||||||
c.Client, err = clientset.NewForConfig(restclient.AddUserAgent(c.Kubeconfig, userAgent))
|
c.Client, err = clientset.NewForConfig(restclient.AddUserAgent(c.Kubeconfig, userAgent))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user