@@ -23,9 +23,7 @@ import (
2323 "sync/atomic"
2424 "time"
2525
26- "github.com/api7/gopkg/pkg/log"
2726 "github.com/go-logr/logr"
28- "go.uber.org/zap"
2927 networkingv1 "k8s.io/api/networking/v1"
3028 networkingv1beta1 "k8s.io/api/networking/v1beta1"
3129 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -63,6 +61,7 @@ type api7eeProvider struct {
6361 startUpSync atomic.Bool
6462
6563 client * adcclient.Client
64+ log logr.Logger
6665}
6766
6867func New (log logr.Logger , updater status.Updater , readier readiness.ReadinessManager , opts ... provider.Option ) (provider.Provider , error ) {
@@ -84,6 +83,7 @@ func New(log logr.Logger, updater status.Updater, readier readiness.ReadinessMan
8483 updater : updater ,
8584 readier : readier ,
8685 syncCh : make (chan struct {}, 1 ),
86+ log : log .WithName ("provider" ),
8787 }, nil
8888}
8989
@@ -92,7 +92,7 @@ func (d *api7eeProvider) Register(pathPrefix string, mux *http.ServeMux) {
9292}
9393
9494func (d * api7eeProvider ) Update (ctx context.Context , tctx * provider.TranslateContext , obj client.Object ) error {
95- log .Debugw ( "updating object" , zap . Any ( "object" , obj ) )
95+ d . log .V ( 1 ). Info ( "updating object" , "object" , obj )
9696 var (
9797 result * translator.TranslateResult
9898 resourceTypes []string
@@ -179,15 +179,15 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
179179 }
180180
181181 if ! d .startUpSync .Load () {
182- log .Debugw ( "startup synchronization not completed, skip sync" , zap . Any ( "object" , obj ) )
182+ d . log .V ( 1 ). Info ( "startup synchronization not completed, skip sync" , "object" , obj )
183183 return d .client .UpdateConfig (ctx , task )
184184 }
185185
186186 return d .client .Update (ctx , task )
187187}
188188
189189func (d * api7eeProvider ) Delete (ctx context.Context , obj client.Object ) error {
190- log .Debugw ( "deleting object" , zap . Any ( "object" , obj ) )
190+ d . log .V ( 1 ). Info ( "deleting object" , "object" , obj )
191191
192192 var resourceTypes []string
193193 var labels map [string ]string
@@ -229,16 +229,16 @@ func (d *api7eeProvider) Start(ctx context.Context) error {
229229 d .readier .WaitReady (ctx , 5 * time .Minute )
230230
231231 d .startUpSync .Store (true )
232- log .Info ("Performing startup synchronization" )
232+ d . log .Info ("Performing startup synchronization" )
233233 if err := d .sync (ctx ); err != nil {
234- log .Warnw ( "failed to sync for startup" , zap . Error ( err ) )
234+ d . log .Error ( err , "failed to sync for startup" )
235235 }
236236
237237 initalSyncDelay := d .InitSyncDelay
238238 if initalSyncDelay > 0 {
239239 time .AfterFunc (initalSyncDelay , func () {
240240 if err := d .sync (ctx ); err != nil {
241- log .Error (err )
241+ d . log .Error (err , "failed to sync for startup" )
242242 return
243243 }
244244 })
@@ -261,7 +261,7 @@ func (d *api7eeProvider) Start(ctx context.Context) error {
261261 }
262262 if synced {
263263 if err := d .sync (ctx ); err != nil {
264- log .Error (err )
264+ d . log .Error (err , "failed to sync for startup" )
265265 }
266266 }
267267 }
@@ -283,7 +283,7 @@ func (d *api7eeProvider) sync(ctx context.Context) error {
283283func (d * api7eeProvider ) handleADCExecutionErrors (statusesMap map [string ]types.ADCExecutionErrors ) {
284284 statusUpdateMap := d .resolveADCExecutionErrors (statusesMap )
285285 d .handleStatusUpdate (statusUpdateMap )
286- log .Debugw ( "handled ADC execution errors" , zap . Any ( "status_record" , statusesMap ), zap . Any ( "status_update" , statusUpdateMap ) )
286+ d . log .V ( 1 ). Info ( "handled ADC execution errors" , "status_record" , statusesMap , "status_update" , statusUpdateMap )
287287}
288288
289289func (d * api7eeProvider ) NeedLeaderElection () bool {
0 commit comments