Skip to content

Commit 0932591

Browse files
czeslavopangruoran
andauthored
chore(logs): The log format starts with a capital letter in internal/dataplane (#5065) (#5083)
(cherry picked from commit 6e1bbc9) Co-authored-by: Ran Z <84066190+pangruoran@users.noreply.github.com>
1 parent 6949f07 commit 0932591

19 files changed

+61
-60
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Nothing yet.
225225
[#5038](https://github.com/Kong/kubernetes-ingress-controller/pull/5038)
226226
[#5049](https://github.com/Kong/kubernetes-ingress-controller/pull/5049)
227227
[#5050](https://github.com/Kong/kubernetes-ingress-controller/pull/5050)
228+
[#5065](https://github.com/Kong/kubernetes-ingress-controller/pull/5065)
228229

229230
### Added
230231

internal/dataplane/kong_client.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func NewKongClient(
182182
func (c *KongClient) initializeControllerPodReference() {
183183
podNN, err := util.GetPodNN()
184184
if err != nil {
185-
c.logger.Error(err, "failed to resolve controller's pod to attach the apply configuration events to")
185+
c.logger.Error(err, "Failed to resolve controller's pod to attach the apply configuration events to")
186186
return
187187
}
188188
c.controllerPodReference = mo.Some(podNN)
@@ -395,17 +395,17 @@ func (c *KongClient) Update(ctx context.Context) error {
395395
}
396396
}
397397

398-
c.logger.V(util.DebugLevel).Info("parsing kubernetes objects into data-plane configuration")
398+
c.logger.V(util.DebugLevel).Info("Parsing kubernetes objects into data-plane configuration")
399399
parsingResult := c.kongConfigBuilder.BuildKongConfig()
400400
if failuresCount := len(parsingResult.TranslationFailures); failuresCount > 0 {
401401
c.prometheusMetrics.RecordTranslationFailure()
402402
c.prometheusMetrics.RecordTranslationBrokenResources(failuresCount)
403403
c.recordResourceFailureEvents(parsingResult.TranslationFailures, KongConfigurationTranslationFailedEventReason)
404-
c.logger.V(util.DebugLevel).Info("translation failures occurred when building data-plane configuration", "count", failuresCount)
404+
c.logger.V(util.DebugLevel).Info("Translation failures occurred when building data-plane configuration", "count", failuresCount)
405405
} else {
406406
c.prometheusMetrics.RecordTranslationSuccess()
407407
c.prometheusMetrics.RecordTranslationBrokenResources(0)
408-
c.logger.V(util.DebugLevel).Info("successfully built data-plane configuration")
408+
c.logger.V(util.DebugLevel).Info("Successfully built data-plane configuration")
409409
}
410410

411411
shas, gatewaysSyncErr := c.sendOutToGatewayClients(ctx, parsingResult.KongState, c.kongConfig)
@@ -428,7 +428,7 @@ func (c *KongClient) Update(ctx context.Context) error {
428428
if fallbackSyncErr != nil {
429429
return errors.Join(gatewaysSyncErr, fallbackSyncErr)
430430
}
431-
c.logger.V(util.DebugLevel).Info("due to errors in the current config, the last valid config has been pushed to Gateways")
431+
c.logger.V(util.DebugLevel).Info("Due to errors in the current config, the last valid config has been pushed to Gateways")
432432
}
433433
return gatewaysSyncErr
434434
}
@@ -438,11 +438,11 @@ func (c *KongClient) Update(ctx context.Context) error {
438438
// if the configuration SHAs that have just been pushed are different than
439439
// what's been previously pushed.
440440
if !slices.Equal(shas, c.SHAs) {
441-
c.logger.V(util.DebugLevel).Info("triggering report for configured Kubernetes objects", "count",
441+
c.logger.V(util.DebugLevel).Info("Triggering report for configured Kubernetes objects", "count",
442442
len(parsingResult.ConfiguredKubernetesObjects))
443443
c.triggerKubernetesObjectReport(parsingResult.ConfiguredKubernetesObjects, parsingResult.TranslationFailures)
444444
} else {
445-
c.logger.V(util.DebugLevel).Info("no configuration change; resource status update not necessary, skipping")
445+
c.logger.V(util.DebugLevel).Info("No configuration change; resource status update not necessary, skipping")
446446
}
447447
}
448448
return nil
@@ -558,7 +558,7 @@ func (c *KongClient) sendToClient(
558558

559559
if err != nil {
560560
if expired, ok := timedCtx.Deadline(); ok && time.Now().After(expired) {
561-
logger.Error(nil, "exceeded Kong API timeout, consider increasing --proxy-timeout-seconds")
561+
logger.Error(nil, "Exceeded Kong API timeout, consider increasing --proxy-timeout-seconds")
562562
}
563563
return "", fmt.Errorf("performing update for %s failed: %w", client.AdminAPIClient().BaseRootURL(), err)
564564
}
@@ -620,9 +620,9 @@ func prepareSendDiagnosticFn(
620620
// later on but we're OK with this limitation of said API.
621621
select {
622622
case diagnosticConfig.Configs <- util.ConfigDump{Failed: failed, Config: *config}:
623-
logger.V(util.DebugLevel).Info("shipping config to diagnostic server")
623+
logger.V(util.DebugLevel).Info("Shipping config to diagnostic server")
624624
default:
625-
logger.Error(nil, "config diagnostic buffer full, dropping diagnostic config")
625+
logger.Error(nil, "Config diagnostic buffer full, dropping diagnostic config")
626626
}
627627
}
628628
}
@@ -720,11 +720,11 @@ func (c *KongClient) recordApplyConfigurationEvents(err error, rootURL string) {
720720
func (c *KongClient) updateConfigStatus(ctx context.Context, configStatus clients.ConfigStatus) {
721721
if c.currentConfigStatus == configStatus {
722722
// No change in config status, nothing to do.
723-
c.logger.V(util.DebugLevel).Info("no change in config status, not notifying")
723+
c.logger.V(util.DebugLevel).Info("No change in config status, not notifying")
724724
return
725725
}
726726

727-
c.logger.V(util.DebugLevel).Info("config status changed, notifying", "configStatus", configStatus)
727+
c.logger.V(util.DebugLevel).Info("Config status changed, notifying", "configStatus", configStatus)
728728
c.currentConfigStatus = configStatus
729729
c.configStatusNotifier.NotifyConfigStatus(ctx, configStatus)
730730
}

internal/dataplane/kongstate/kongstate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,20 +414,20 @@ func globalKongClusterPlugins(logger logr.Logger, s store.Storer) ([]Plugin, err
414414
pluginName := k8sPlugin.PluginName
415415
// empty pluginName skip it
416416
if pluginName == "" {
417-
logger.Error(nil, "invalid KongClusterPlugin: empty plugin property",
417+
logger.Error(nil, "Invalid KongClusterPlugin: empty plugin property",
418418
"kongclusterplugin_name", k8sPlugin.Name)
419419
continue
420420
}
421421
if _, ok := res[pluginName]; ok {
422-
logger.Error(nil, "multiple KongPlugin with 'global' label found, cannot apply",
422+
logger.Error(nil, "Multiple KongPlugin with 'global' label found, cannot apply",
423423
"kongplugin_name", pluginName)
424424
duplicates = append(duplicates, pluginName)
425425
continue
426426
}
427427
if plugin, err := kongPluginFromK8SClusterPlugin(s, k8sPlugin); err == nil {
428428
res[pluginName] = plugin
429429
} else {
430-
logger.Error(err, "failed to generate configuration from KongClusterPlugin",
430+
logger.Error(err, "Failed to generate configuration from KongClusterPlugin",
431431
"kongclusterplugin_name", k8sPlugin.Name)
432432
}
433433
}
@@ -456,14 +456,14 @@ func (ks *KongState) FillPlugins(
456456
func (ks *KongState) FillIDs(logger logr.Logger) {
457457
for svcIndex, svc := range ks.Services {
458458
if err := svc.FillID(); err != nil {
459-
logger.Error(err, "failed to fill ID for service", "service_name", *svc.Name)
459+
logger.Error(err, "Failed to fill ID for service", "service_name", *svc.Name)
460460
} else {
461461
ks.Services[svcIndex] = svc
462462
}
463463

464464
for routeIndex, route := range svc.Routes {
465465
if err := route.FillID(); err != nil {
466-
logger.Error(err, "failed to fill ID for route", "route_name", *route.Name)
466+
logger.Error(err, "Failed to fill ID for route", "route_name", *route.Name)
467467
} else {
468468
ks.Services[svcIndex].Routes[routeIndex] = route
469469
}
@@ -472,15 +472,15 @@ func (ks *KongState) FillIDs(logger logr.Logger) {
472472

473473
for consumerIndex, consumer := range ks.Consumers {
474474
if err := consumer.FillID(); err != nil {
475-
logger.Error(err, "failed to fill ID for consumer", "consumer_name", consumer.FriendlyName())
475+
logger.Error(err, "Failed to fill ID for consumer", "consumer_name", consumer.FriendlyName())
476476
} else {
477477
ks.Consumers[consumerIndex] = consumer
478478
}
479479
}
480480

481481
for consumerGroupIndex, consumerGroup := range ks.ConsumerGroups {
482482
if err := consumerGroup.FillID(); err != nil {
483-
logger.Error(err, "failed to fill ID for consumer group", "consumer_group_name", *consumerGroup.Name)
483+
logger.Error(err, "Failed to fill ID for consumer group", "consumer_group_name", *consumerGroup.Name)
484484
} else {
485485
ks.ConsumerGroups[consumerGroupIndex] = consumerGroup
486486
}

internal/dataplane/kongstate/route.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (r *Route) overrideMethods(logger logr.Logger, anns map[string]string) {
195195
} else {
196196
// if any method is invalid (not an uppercase alpha string),
197197
// discard everything
198-
logger.Error(nil, "invalid method", "route_name", r.Name, "method", method)
198+
logger.Error(nil, "Invalid method", "route_name", r.Name, "method", method)
199199
return
200200
}
201201
}
@@ -219,7 +219,7 @@ func (r *Route) overrideSNIs(logger logr.Logger, anns map[string]string) {
219219
snis = append(snis, kong.String(sanitizedSNI))
220220
} else {
221221
// SNI is not a valid hostname
222-
logger.Error(nil, "invalid SNI", "route_name", r.Name, "sni", sni)
222+
logger.Error(nil, "Invalid SNI", "route_name", r.Name, "sni", sni)
223223
return
224224
}
225225
}
@@ -268,7 +268,7 @@ func (r *Route) overrideRequestBuffering(logger logr.Logger, anns map[string]str
268268
isEnabled, err := strconv.ParseBool(strings.ToLower(annotationValue))
269269
if err != nil {
270270
// the value provided is not a parseable boolean, quit
271-
logger.Error(err, "invalid request_buffering value", "kongroute", r.Name)
271+
logger.Error(err, "Invalid request_buffering value", "kongroute", r.Name)
272272
return
273273
}
274274

@@ -286,7 +286,7 @@ func (r *Route) overrideResponseBuffering(logger logr.Logger, anns map[string]st
286286
isEnabled, err := strconv.ParseBool(strings.ToLower(annotationValue))
287287
if err != nil {
288288
// the value provided is not a parseable boolean, quit
289-
logger.Error(err, "invalid response_buffering values", "kongroute", r.Name)
289+
logger.Error(err, "Invalid response_buffering values", "kongroute", r.Name)
290290
return
291291
}
292292

@@ -322,7 +322,7 @@ func (r *Route) overrideHosts(logger logr.Logger, anns map[string]string) {
322322
hosts = appendIfMissing(hosts, sanitizedHost)
323323
} else {
324324
// Host Alias is not a valid hostname
325-
logger.Error(nil, "invalid host alias", "value", hostAlias, "kongroute", r.Name)
325+
logger.Error(nil, "Invalid host alias", "value", hostAlias, "kongroute", r.Name)
326326
return
327327
}
328328
}
@@ -345,7 +345,7 @@ func (r *Route) overridePathHandling(logger logr.Logger, anns map[string]string)
345345
}
346346

347347
if !validPathHandling.MatchString(val) {
348-
logger.Error(nil, "invalid path_handling", "value", val, "kongroute", r.Name)
348+
logger.Error(nil, "Invalid path_handling", "value", val, "kongroute", r.Name)
349349
return
350350
}
351351

internal/dataplane/parser/backendref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func backendRefsToKongStateBackends(
6060
route.GetObjectKind().GroupVersionKind().String(),
6161
route.GetNamespace(),
6262
route.GetName())
63-
logger.Error(nil, "object requested backendRef to target, but no ReferenceGrant permits it, skipping...",
63+
logger.Error(nil, "Object requested backendRef to target, but no ReferenceGrant permits it, skipping...",
6464
"object_name", objName,
6565
"target_kind", kind,
6666
"target_namespace", namespace,

internal/dataplane/parser/ingressrules.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (ir *ingressRules) populateServices(logger logr.Logger, s store.Storer, fai
100100
if parent, ok := ir.ServiceNameToParent[*service.Name]; ok {
101101
service.Tags = util.GenerateTagsForObject(parent)
102102
} else {
103-
logger.Error(nil, "multi-service backend lacks parent info, cannot generate tags",
103+
logger.Error(nil, "Multi-service backend lacks parent info, cannot generate tags",
104104
"service", *service.Name)
105105
}
106106
} else if len(k8sServices) > 0 {
@@ -110,7 +110,7 @@ func (ir *ingressRules) populateServices(logger logr.Logger, s store.Storer, fai
110110
// Service doesn't actually exist. attempting to generate tags for that Service would trigger a panic.
111111
// the parser should discard this invalid route later, but this adds a placeholder value in case it doesn't.
112112
// if you encounter an actual config where a service has these tags, something strange has happened.
113-
logger.V(util.DebugLevel).Info("service has zero k8sServices backends, cannot generate tags for it properly",
113+
logger.V(util.DebugLevel).Info("Service has zero k8sServices backends, cannot generate tags for it properly",
114114
"service", *service.Name)
115115
service.Tags = kong.StringSlice(
116116
util.K8sNameTagPrefix+"UNKNOWN",

internal/dataplane/parser/parser.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func shouldEnableParserExpressionRoutes(
8686
logger.V(util.InfoLevel).Info("Gateway is running with non-expression router flavor", "flavor", routerFlavor)
8787
return false
8888
}
89-
logger.V(util.InfoLevel).Info("expression routes mode enabled")
89+
logger.V(util.InfoLevel).Info("The expression routes mode enabled")
9090
return true
9191
}
9292

@@ -377,7 +377,7 @@ func (p *Parser) getUpstreams(serviceMap map[string]kongstate.Service) ([]kongst
377377
newTargets := getServiceEndpoints(p.logger, p.storer, k8sService, port)
378378

379379
if len(newTargets) == 0 {
380-
p.logger.V(util.InfoLevel).Info("no targets could be found for kubernetes service",
380+
p.logger.V(util.InfoLevel).Info("No targets could be found for kubernetes service",
381381
"namespace", k8sService.Namespace, "name", k8sService.Name, "kong_service", *service.Name)
382382
}
383383

@@ -413,7 +413,7 @@ func (p *Parser) getUpstreams(serviceMap map[string]kongstate.Service) ([]kongst
413413

414414
// warn if an upstream was created with 0 targets
415415
if len(targets) == 0 {
416-
p.logger.V(util.InfoLevel).Info("no targets found to create upstream", "service_name", *service.Name)
416+
p.logger.V(util.InfoLevel).Info("No targets found to create upstream", "service_name", *service.Name)
417417
}
418418

419419
// define the upstream including all the newly populated targets
@@ -478,7 +478,7 @@ func (p *Parser) getGatewayCerts() []certWrapper {
478478
for _, listener := range gateway.Spec.Listeners {
479479
status, ok := statuses[listener.Name]
480480
if !ok {
481-
logger.V(util.DebugLevel).Info("listener missing status information",
481+
logger.V(util.DebugLevel).Info("Listener missing status information",
482482
"gateway", gateway.Name,
483483
"listener", listener.Name,
484484
"listener_protocol", listener.Protocol,
@@ -655,7 +655,7 @@ func mergeCerts(logger logr.Logger, certLists ...[]certWrapper) []kongstate.Cert
655655
// what binds the SNI to a given Secret. Knowing the Secret ID isn't of great use beyond knowing
656656
// what cert will be served. however, the secretToSNIs input to getCerts does not provide this info
657657
// https://github.com/Kong/kubernetes-ingress-controller/issues/2605
658-
logger.Error(nil, "same SNI requested for multiple certs, can only serve one cert",
658+
logger.Error(nil, "Same SNI requested for multiple certs, can only serve one cert",
659659
"served_secret_cert", seen,
660660
"requested_secret_cert", *current.cert.ID,
661661
"sni", sni)
@@ -695,7 +695,7 @@ func getServiceEndpoints(
695695
var isSvcUpstream bool
696696
ingressClassParameters, err := getIngressClassParametersOrDefault(s)
697697
if err != nil {
698-
logger.V(util.DebugLevel).Info("unable to retrieve IngressClassParameters", "error", err)
698+
logger.V(util.DebugLevel).Info("Unable to retrieve IngressClassParameters", "error", err)
699699
} else {
700700
isSvcUpstream = ingressClassParameters.ServiceUpstream
701701
}
@@ -707,7 +707,7 @@ func getServiceEndpoints(
707707
endpoints = append(endpoints, newEndpoints...)
708708
}
709709
if len(endpoints) == 0 {
710-
logger.V(util.DebugLevel).Info("no active endpoints")
710+
logger.V(util.DebugLevel).Info("No active endpoints")
711711
}
712712

713713
return targetsForEndpoints(endpoints)
@@ -765,7 +765,7 @@ func getEndpoints(
765765

766766
// ExternalName services
767767
if service.Spec.Type == corev1.ServiceTypeExternalName {
768-
logger.V(util.DebugLevel).Info("found service of type=ExternalName")
768+
logger.V(util.DebugLevel).Info("Found service of type=ExternalName")
769769
return []util.Endpoint{
770770
{
771771
Address: service.Spec.ExternalName,
@@ -774,13 +774,13 @@ func getEndpoints(
774774
}
775775
}
776776

777-
logger.V(util.DebugLevel).Info("fetching EndpointSlices")
777+
logger.V(util.DebugLevel).Info("Fetching EndpointSlices")
778778
endpointSlices, err := getEndpointSlices(service.Namespace, service.Name)
779779
if err != nil {
780-
logger.Error(err, "error fetching EndpointSlices")
780+
logger.Error(err, "Error fetching EndpointSlices")
781781
return []util.Endpoint{}
782782
}
783-
logger.V(util.DebugLevel).Info("fetched EndpointSlices", "count", len(endpointSlices))
783+
logger.V(util.DebugLevel).Info("Fetched EndpointSlices", "count", len(endpointSlices))
784784

785785
// Avoid duplicated upstream servers when the service contains
786786
// multiple port definitions sharing the same target port.
@@ -815,7 +815,7 @@ func getEndpoints(
815815
}
816816
}
817817
}
818-
logger.V(util.DebugLevel).Info("found endpoints", "endpoints", upstreamServers)
818+
logger.V(util.DebugLevel).Info("Found endpoints", "endpoints", upstreamServers)
819819
return upstreamServers
820820
}
821821

internal/dataplane/parser/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4526,7 +4526,7 @@ func TestNewFeatureFlags(t *testing.T) {
45264526
expectedFeatureFlags: FeatureFlags{
45274527
ExpressionRoutes: true,
45284528
},
4529-
expectInfoLog: "expression routes mode enabled",
4529+
expectInfoLog: "The expression routes mode enabled",
45304530
},
45314531
}
45324532

internal/dataplane/parser/translate_grpcroute.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (p *Parser) ingressRulesFromGRPCRoutes() ingressRules {
4242

4343
if len(errs) > 0 {
4444
for _, err := range errs {
45-
p.logger.Error(err, "could not generate route from GRPCRoute")
45+
p.logger.Error(err, "Could not generate route from GRPCRoute")
4646
}
4747
}
4848

@@ -124,7 +124,7 @@ func (p *Parser) ingressRulesFromGRPCRouteWithPriority(
124124
grpcRoute := splitGRPCRouteMatchWithPriority.Match.Source
125125
// (very unlikely that) the rule index split from the source GRPCRoute is larger then length of original rules.
126126
if len(grpcRoute.Spec.Rules) <= match.RuleIndex {
127-
p.logger.Error(nil, "split rule index is greater than the length of rules in source GRPCRoute",
127+
p.logger.Error(nil, "Split rule index is greater than the length of rules in source GRPCRoute",
128128
"rule_index", match.RuleIndex,
129129
"rule_count", len(grpcRoute.Spec.Rules))
130130
return

internal/dataplane/parser/translate_httproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func (p *Parser) ingressRulesFromSplitHTTPRouteMatchWithPriority(
411411
match := httpRouteMatchWithPriority.Match
412412
httpRoute := httpRouteMatchWithPriority.Match.Source
413413
if match.RuleIndex >= len(httpRoute.Spec.Rules) {
414-
p.logger.Error(nil, "split match has rule out of bound of rules in source HTTPRoute",
414+
p.logger.Error(nil, "Split match has rule out of bound of rules in source HTTPRoute",
415415
"rule_index", match.RuleIndex, "rule_count", len(httpRoute.Spec.Rules))
416416
return nil
417417
}

0 commit comments

Comments
 (0)