Skip to content

Replace klog with zerolog in Lighthouse Agent #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand All @@ -66,6 +67,7 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rs/zerolog v1.28.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
Expand Down Expand Up @@ -252,6 +253,7 @@ github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85n
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
Expand Down Expand Up @@ -432,6 +434,7 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
Expand Down Expand Up @@ -530,7 +533,9 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
Expand Down Expand Up @@ -821,6 +826,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
35 changes: 19 additions & 16 deletions pkg/agent/controller/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
validations "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/util/retry"
"k8s.io/klog/v2"
logf "sigs.k8s.io/controller-runtime/pkg/log"
mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)

Expand All @@ -57,6 +57,8 @@ type AgentConfig struct {
ServiceExportCounterName string
}

var logger = log.Logger{Logger: logf.Log.WithName("agent")}

//nolint:gocritic // (hugeParam) This function modifies syncerConf so we don't want to pass by pointer.
func New(spec *AgentSpecification, syncerConf broker.SyncerConfig, kubeClientSet kubernetes.Interface,
syncerMetricNames AgentConfig,
Expand Down Expand Up @@ -171,7 +173,7 @@ func (a *Controller) Start(stopCh <-chan struct{}) error {
defer utilruntime.HandleCrash()

// Start the informer factories to begin populating the informer caches
klog.Info("Starting Agent controller")
logger.Info("Starting Agent controller")

if err := a.serviceExportSyncer.Start(stopCh); err != nil {
return errors.Wrap(err, "error starting ServiceExport syncer")
Expand Down Expand Up @@ -215,15 +217,15 @@ func (a *Controller) Start(stopCh <-chan struct{}) error {
})
})

klog.Info("Agent controller started")
logger.Info("Agent controller started")

return nil
}

func (a *Controller) serviceImportLister(transform func(si *mcsv1a1.ServiceImport) runtime.Object) []runtime.Object {
siList, err := a.serviceImportSyncer.ListLocalResources(&mcsv1a1.ServiceImport{})
if err != nil {
klog.Errorf("Error listing serviceImports: %v", err)
logger.Error(err, "Error listing serviceImports")
return nil
}

Expand All @@ -241,7 +243,7 @@ func (a *Controller) serviceImportLister(transform func(si *mcsv1a1.ServiceImpor
func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
svcExport := obj.(*mcsv1a1.ServiceExport)

klog.V(log.DEBUG).Infof("ServiceExport %s/%s %sd", svcExport.Namespace, svcExport.Name, op)
logger.V(log.DEBUG).Infof("ServiceExport %s/%s %sd", svcExport.Namespace, svcExport.Name, op)

if op == syncer.Delete {
return a.newServiceImport(svcExport.Name, svcExport.Namespace), false
Expand All @@ -252,13 +254,13 @@ func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeue
// some other error. Log and requeue
a.updateExportedServiceStatus(svcExport.Name, svcExport.Namespace, mcsv1a1.ServiceExportValid, corev1.ConditionUnknown,
"ServiceRetrievalFailed", fmt.Sprintf("Error retrieving the Service: %v", err))
klog.Errorf("Error retrieving Service (%s/%s): %v", svcExport.Namespace, svcExport.Name, err)
logger.Errorf(err, "Error retrieving Service %s/%s", svcExport.Namespace, svcExport.Name)

return nil, true
}

if !found {
klog.V(log.DEBUG).Infof("Service to be exported (%s/%s) doesn't exist", svcExport.Namespace, svcExport.Name)
logger.V(log.DEBUG).Infof("Service to be exported (%s/%s) doesn't exist", svcExport.Namespace, svcExport.Name)
a.updateExportedServiceStatus(svcExport.Name, svcExport.Namespace, mcsv1a1.ServiceExportValid, corev1.ConditionFalse,
serviceUnavailable, "Service to be exported doesn't exist")

Expand All @@ -272,14 +274,14 @@ func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeue
if !ok {
a.updateExportedServiceStatus(svcExport.Name, svcExport.Namespace, mcsv1a1.ServiceExportValid, corev1.ConditionFalse,
invalidServiceType, fmt.Sprintf("Service of type %v not supported", svc.Spec.Type))
klog.Errorf("Service type %q not supported for Service (%s/%s)", svc.Spec.Type, svcExport.Namespace, svcExport.Name)
logger.Errorf(nil, "Service type %q not supported for Service (%s/%s)", svc.Spec.Type, svcExport.Namespace, svcExport.Name)

err = a.serviceImportSyncer.GetLocalFederator().Delete(a.newServiceImport(svcExport.Name, svcExport.Namespace))
if err == nil || apierrors.IsNotFound(err) {
return nil, false
}

klog.Errorf("Error deleting ServiceImport for Service (%s/%s)", svcExport.Namespace, svcExport.Name)
logger.Errorf(nil, "Error deleting ServiceImport for Service (%s/%s)", svcExport.Namespace, svcExport.Name)

return nil, true
}
Expand All @@ -304,7 +306,8 @@ func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeue
if a.globalnetEnabled {
ip, reason, msg := a.getGlobalIP(svc)
if ip == "" {
klog.V(log.DEBUG).Infof("Service to be exported (%s/%s) doesn't have a global IP yet", svcExport.Namespace, svcExport.Name)
logger.V(log.DEBUG).Infof("Service to be exported (%s/%s) doesn't have a global IP yet",
svcExport.Namespace, svcExport.Name)
// Globalnet enabled but service doesn't have globalIp yet, Update the status and requeue
a.updateExportedServiceStatus(svcExport.Name, svcExport.Namespace, mcsv1a1.ServiceExportValid,
corev1.ConditionFalse, reason, msg)
Expand All @@ -326,7 +329,7 @@ func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeue

a.updateExportedServiceStatus(svcExport.Name, svcExport.Namespace, mcsv1a1.ServiceExportValid, corev1.ConditionTrue, "", "")

klog.V(log.DEBUG).Infof("Returning ServiceImport: %#v", serviceImport)
logger.V(log.DEBUG).Infof("Returning ServiceImport : %#v", serviceImport)

return serviceImport, false
}
Expand Down Expand Up @@ -407,7 +410,7 @@ func (a *Controller) serviceToRemoteServiceImport(obj runtime.Object, numRequeue
obj, found, err := a.serviceExportSyncer.GetResource(svc.Name, svc.Namespace)
if err != nil {
// some other error. Log and requeue
klog.Errorf("Error retrieving ServiceExport for Service (%s/%s): %v", svc.Namespace, svc.Name, err)
logger.Errorf(err, "Error retrieving ServiceExport for Service (%s/%s)", svc.Namespace, svc.Name)
return nil, true
}

Expand All @@ -434,13 +437,13 @@ func (a *Controller) serviceToRemoteServiceImport(obj runtime.Object, numRequeue
func (a *Controller) updateExportedServiceStatus(name, namespace string, condType mcsv1a1.ServiceExportConditionType,
status corev1.ConditionStatus, reason, msg string,
) {
klog.V(log.DEBUG).Infof("updateExportedServiceStatus for (%s/%s) - Type: %q, Status: %q, Reason: %q, Message: %q",
logger.V(log.DEBUG).Infof("updateExportedServiceStatus for (%s/%s) - Type: %q, Status: %q, Reason: %q, Message: %q",
namespace, name, condType, status, reason, msg)

retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
toUpdate, err := a.getServiceExport(name, namespace)
if apierrors.IsNotFound(err) {
klog.Infof("ServiceExport (%s/%s) not found - unable to update status", namespace, name)
logger.Infof("ServiceExport (%s/%s) not found - unable to update status", namespace, name)
return nil
} else if err != nil {
return err
Expand All @@ -459,7 +462,7 @@ func (a *Controller) updateExportedServiceStatus(name, namespace string, condTyp
if prevCond == nil {
toUpdate.Status.Conditions = append(toUpdate.Status.Conditions, newCondition)
} else if serviceExportConditionEqual(prevCond, &newCondition) {
klog.V(log.TRACE).Infof("Last ServiceExportCondition for (%s/%s) is equal - not updating status: %#v",
logger.V(log.TRACE).Infof("Last ServiceExportCondition for (%s/%s) is equal - not updating status: %#v",
namespace, name, toUpdate.Status.Conditions[0])
return nil
} else {
Expand All @@ -477,7 +480,7 @@ func (a *Controller) updateExportedServiceStatus(name, namespace string, condTyp
})

if retryErr != nil {
klog.Errorf("Error updating status for ServiceExport (%s/%s): %+v", namespace, name, retryErr)
logger.Errorf(retryErr, "Error updating status for ServiceExport (%s/%s)", namespace, name)
}
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/agent/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"crypto/rand"
"encoding/json"
"errors"
"flag"
"fmt"
"math/big"
"reflect"
Expand All @@ -33,6 +34,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/fake"
"github.com/submariner-io/admiral/pkg/log/kzerolog"
"github.com/submariner-io/admiral/pkg/syncer/broker"
"github.com/submariner-io/admiral/pkg/syncer/test"
"github.com/submariner-io/lighthouse/coredns/constants"
Expand All @@ -51,7 +53,6 @@ import (
fakeKubeClient "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)

Expand All @@ -72,7 +73,12 @@ var (
)

func init() {
klog.InitFlags(nil)
// set logging verbosity of agent in unit test to DEBUG
flags := flag.NewFlagSet("kzerolog", flag.ExitOnError)
kzerolog.AddFlags(flags)
// nolint:errcheck // Ignore errors; CommandLine is set for ExitOnError.
flags.Parse([]string{"-v=2"})
kzerolog.InitK8sLogging()

err := mcsv1a1.AddToScheme(scheme.Scheme)
if err != nil {
Expand Down
19 changes: 9 additions & 10 deletions pkg/agent/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/klog/v2"
utilnet "k8s.io/utils/net"
mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)
Expand All @@ -46,7 +45,7 @@ func startEndpointController(localClient dynamic.Interface, restMapper meta.REST
serviceImport *mcsv1a1.ServiceImport, serviceImportNameSpace, serviceName, clusterID string,
globalIngressIPCache *globalIngressIPCache,
) (*EndpointController, error) {
klog.V(log.DEBUG).Infof("Starting Endpoints controller for service %s/%s", serviceImportNameSpace, serviceName)
logger.V(log.DEBUG).Infof("Starting Endpoints controller for service %s/%s", serviceImportNameSpace, serviceName)

globalIngressIPGVR, _ := schema.ParseResourceArg("globalingressips.v1.submariner.io")

Expand Down Expand Up @@ -112,7 +111,7 @@ func (e *EndpointController) cleanup() {
})

if err != nil && !apierrors.IsNotFound(err) {
klog.Errorf("Error deleting the EndpointSlices associated with serviceImport %q: %v", e.serviceImportName, err)
logger.Errorf(err, "Error deleting the EndpointSlices associated with ServiceImport %q", e.serviceImportName)
}

// Lighthouse-proprietary labels
Expand All @@ -125,7 +124,7 @@ func (e *EndpointController) cleanup() {
})

if err != nil && !apierrors.IsNotFound(err) {
klog.Errorf("Error deleting the EndpointSlices associated with serviceImport %q: %v", e.serviceImportName, err)
logger.Errorf(err, "Error deleting the EndpointSlices associated with ServiceImport %q", e.serviceImportName)
}
}

Expand All @@ -135,7 +134,7 @@ func (e *EndpointController) endpointsToEndpointSlice(obj runtime.Object, numReq
endpointSliceName := endPoints.Name + "-" + e.clusterID

if op == syncer.Delete {
klog.V(log.DEBUG).Infof("Endpoints %s/%s deleted", endPoints.Namespace, endPoints.Name)
logger.V(log.DEBUG).Infof("Endpoints %s/%s deleted", endPoints.Namespace, endPoints.Name)

return &discovery.EndpointSlice{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -146,9 +145,9 @@ func (e *EndpointController) endpointsToEndpointSlice(obj runtime.Object, numReq
}

if op == syncer.Create {
klog.V(log.DEBUG).Infof("Endpoints %s/%s created", endPoints.Namespace, endPoints.Name)
logger.V(log.DEBUG).Infof("Endpoints %s/%s created", endPoints.Namespace, endPoints.Name)
} else {
klog.V(log.TRACE).Infof("Endpoints %s/%s updated", endPoints.Namespace, endPoints.Name)
logger.V(log.TRACE).Infof("Endpoints %s/%s updated", endPoints.Namespace, endPoints.Name)
}

return e.endpointSliceFromEndpoints(endPoints, op)
Expand Down Expand Up @@ -200,9 +199,9 @@ func (e *EndpointController) endpointSliceFromEndpoints(endpoints *corev1.Endpoi
}

if op == syncer.Create {
klog.V(log.DEBUG).Infof("Returning EndpointSlice: %#v", endpointSlice)
logger.V(log.DEBUG).Infof("Returning EndpointSlice: %#v", endpointSlice)
} else {
klog.V(log.TRACE).Infof("Returning EndpointSlice: %#v", endpointSlice)
logger.V(log.TRACE).Infof("Returning EndpointSlice: %#v", endpointSlice)
}

return endpointSlice, false
Expand Down Expand Up @@ -283,7 +282,7 @@ func (e *EndpointController) getIP(address *corev1.EndpointAddress) string {
}

if ip == "" {
klog.Infof("GlobalIP for EndpointAddress %q is not allocated yet", address.TargetRef.Name)
logger.Infof("GlobalIP for EndpointAddress %q is not allocated yet", address.TargetRef.Name)
}

return ip
Expand Down
3 changes: 1 addition & 2 deletions pkg/agent/controller/globalingressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package controller

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/klog/v2"
)

const (
Expand Down Expand Up @@ -49,7 +48,7 @@ func parseIngressIP(obj *unstructured.Unstructured) *IngressIP {

gip.target, found, err = unstructured.NestedString(obj.Object, "spec", "target")
if !found || err != nil {
klog.Errorf("target field not found in spec %#v", obj.Object)
logger.Errorf(nil, "target field not found in spec %#v", obj.Object)
return nil
}

Expand Down
9 changes: 4 additions & 5 deletions pkg/agent/controller/serviceimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)

Expand Down Expand Up @@ -88,7 +87,7 @@ func (c *ServiceImportController) start(stopCh <-chan struct{}) error {
return true
})

klog.Infof("ServiceImport Controller stopped")
logger.Info("ServiceImport Controller stopped")
}()

if err := c.serviceImportSyncer.Start(stopCh); err != nil {
Expand All @@ -100,7 +99,7 @@ func (c *ServiceImportController) start(stopCh <-chan struct{}) error {

func (c *ServiceImportController) serviceImportCreatedOrUpdated(serviceImport *mcsv1a1.ServiceImport, key string) bool {
if _, found := c.endpointControllers.Load(key); found {
klog.V(log.DEBUG).Infof("The endpoint controller is already running for %q", key)
logger.V(log.DEBUG).Infof("The endpoint controller is already running for %q", key)
return false
}

Expand All @@ -115,7 +114,7 @@ func (c *ServiceImportController) serviceImportCreatedOrUpdated(serviceImport *m
endpointController, err := startEndpointController(c.localClient, c.restMapper, c.scheme,
serviceImport, serviceNameSpace, serviceName, c.clusterID, c.globalIngressIPCache)
if err != nil {
klog.Errorf(err.Error())
logger.Error(err, "Failed to start endpoint controller")
return true
}

Expand All @@ -141,7 +140,7 @@ func (c *ServiceImportController) serviceImportToEndpointController(obj runtime.
serviceImport := obj.(*mcsv1a1.ServiceImport)
key, _ := cache.MetaNamespaceKeyFunc(serviceImport)

klog.V(log.DEBUG).Infof("ServiceImport %q %sd", key, op)
logger.V(log.DEBUG).Infof("ServiceImport %s %sd", key, op)

if op == syncer.Create || op == syncer.Update {
return nil, c.serviceImportCreatedOrUpdated(serviceImport, key)
Expand Down
Loading