namespace controller: use contextual logging

This commit is contained in:
JunYang
2022-10-29 22:34:47 +08:00
committed by 杨军10092085
parent a35650b833
commit f5bd8c86d4
7 changed files with 113 additions and 87 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package services
import (
"context"
"time"
v1 "k8s.io/api/core/v1"
@@ -49,7 +50,7 @@ func NewNamespaceController(host string) *NamespaceController {
}
// Start starts the namespace controller.
func (n *NamespaceController) Start() error {
func (n *NamespaceController) Start(ctx context.Context) error {
config := restclient.AddUserAgent(&restclient.Config{
Host: n.host,
BearerToken: framework.TestContext.BearerToken,
@@ -72,7 +73,9 @@ func (n *NamespaceController) Start() error {
}
discoverResourcesFn := client.Discovery().ServerPreferredNamespacedResources
informerFactory := informers.NewSharedInformerFactory(client, ncResyncPeriod)
nc := namespacecontroller.NewNamespaceController(
ctx,
client,
metadataClient,
discoverResourcesFn,
@@ -80,7 +83,7 @@ func (n *NamespaceController) Start() error {
ncResyncPeriod, v1.FinalizerKubernetes,
)
informerFactory.Start(n.stopCh)
go nc.Run(ncConcurrency, n.stopCh)
go nc.Run(ctx, ncConcurrency)
return nil
}