Skip to content
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

chore(logs): The log format starts with a capital letter in internal/dataplane #5065

Merged
merged 4 commits into from
Nov 3, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Nothing yet.
[#5038](https:/Kong/kubernetes-ingress-controller/pull/5038)
[#5049](https:/Kong/kubernetes-ingress-controller/pull/5049)
[#5050](https:/Kong/kubernetes-ingress-controller/pull/5050)
[#5065](https:/Kong/kubernetes-ingress-controller/pull/5065)

pangruoran marked this conversation as resolved.
Show resolved Hide resolved
### Added

Expand Down
24 changes: 12 additions & 12 deletions internal/dataplane/kong_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func NewKongClient(
func (c *KongClient) initializeControllerPodReference() {
podNN, err := util.GetPodNN()
if err != nil {
c.logger.Error(err, "failed to resolve controller's pod to attach the apply configuration events to")
c.logger.Error(err, "Failed to resolve controller's pod to attach the apply configuration events to")
return
}
c.controllerPodReference = mo.Some(podNN)
Expand Down Expand Up @@ -395,17 +395,17 @@ func (c *KongClient) Update(ctx context.Context) error {
}
}

c.logger.V(util.DebugLevel).Info("parsing kubernetes objects into data-plane configuration")
c.logger.V(util.DebugLevel).Info("Parsing kubernetes objects into data-plane configuration")
pangruoran marked this conversation as resolved.
Show resolved Hide resolved
parsingResult := c.kongConfigBuilder.BuildKongConfig()
if failuresCount := len(parsingResult.TranslationFailures); failuresCount > 0 {
c.prometheusMetrics.RecordTranslationFailure()
c.prometheusMetrics.RecordTranslationBrokenResources(failuresCount)
c.recordResourceFailureEvents(parsingResult.TranslationFailures, KongConfigurationTranslationFailedEventReason)
c.logger.V(util.DebugLevel).Info("translation failures occurred when building data-plane configuration", "count", failuresCount)
c.logger.V(util.DebugLevel).Info("Translation failures occurred when building data-plane configuration", "count", failuresCount)
} else {
c.prometheusMetrics.RecordTranslationSuccess()
c.prometheusMetrics.RecordTranslationBrokenResources(0)
c.logger.V(util.DebugLevel).Info("successfully built data-plane configuration")
c.logger.V(util.DebugLevel).Info("Successfully built data-plane configuration")
}

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

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

c.logger.V(util.DebugLevel).Info("config status changed, notifying", "configStatus", configStatus)
c.logger.V(util.DebugLevel).Info("Config status changed, notifying", "configStatus", configStatus)
c.currentConfigStatus = configStatus
c.configStatusNotifier.NotifyConfigStatus(ctx, configStatus)
}
14 changes: 7 additions & 7 deletions internal/dataplane/kongstate/kongstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,20 @@ func globalKongClusterPlugins(logger logr.Logger, s store.Storer) ([]Plugin, err
pluginName := k8sPlugin.PluginName
// empty pluginName skip it
if pluginName == "" {
logger.Error(nil, "invalid KongClusterPlugin: empty plugin property",
logger.Error(nil, "Invalid KongClusterPlugin: empty plugin property",
"kongclusterplugin_name", k8sPlugin.Name)
continue
}
if _, ok := res[pluginName]; ok {
logger.Error(nil, "multiple KongPlugin with 'global' label found, cannot apply",
logger.Error(nil, "Multiple KongPlugin with 'global' label found, cannot apply",
"kongplugin_name", pluginName)
duplicates = append(duplicates, pluginName)
continue
}
if plugin, err := kongPluginFromK8SClusterPlugin(s, k8sPlugin); err == nil {
res[pluginName] = plugin
} else {
logger.Error(err, "failed to generate configuration from KongClusterPlugin",
logger.Error(err, "Failed to generate configuration from KongClusterPlugin",
"kongclusterplugin_name", k8sPlugin.Name)
}
}
Expand Down Expand Up @@ -456,14 +456,14 @@ func (ks *KongState) FillPlugins(
func (ks *KongState) FillIDs(logger logr.Logger) {
for svcIndex, svc := range ks.Services {
if err := svc.FillID(); err != nil {
logger.Error(err, "failed to fill ID for service", "service_name", *svc.Name)
logger.Error(err, "Failed to fill ID for service", "service_name", *svc.Name)
} else {
ks.Services[svcIndex] = svc
}

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

for consumerIndex, consumer := range ks.Consumers {
if err := consumer.FillID(); err != nil {
logger.Error(err, "failed to fill ID for consumer", "consumer_name", consumer.FriendlyName())
logger.Error(err, "Failed to fill ID for consumer", "consumer_name", consumer.FriendlyName())
} else {
ks.Consumers[consumerIndex] = consumer
}
}

for consumerGroupIndex, consumerGroup := range ks.ConsumerGroups {
if err := consumerGroup.FillID(); err != nil {
logger.Error(err, "failed to fill ID for consumer group", "consumer_group_name", *consumerGroup.Name)
logger.Error(err, "Failed to fill ID for consumer group", "consumer_group_name", *consumerGroup.Name)
} else {
ks.ConsumerGroups[consumerGroupIndex] = consumerGroup
}
Expand Down
12 changes: 6 additions & 6 deletions internal/dataplane/kongstate/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (r *Route) overrideMethods(logger logr.Logger, anns map[string]string) {
} else {
// if any method is invalid (not an uppercase alpha string),
// discard everything
logger.Error(nil, "invalid method", "route_name", r.Name, "method", method)
logger.Error(nil, "Invalid method", "route_name", r.Name, "method", method)
return
}
}
Expand All @@ -219,7 +219,7 @@ func (r *Route) overrideSNIs(logger logr.Logger, anns map[string]string) {
snis = append(snis, kong.String(sanitizedSNI))
} else {
// SNI is not a valid hostname
logger.Error(nil, "invalid SNI", "route_name", r.Name, "sni", sni)
logger.Error(nil, "Invalid SNI", "route_name", r.Name, "sni", sni)
return
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func (r *Route) overrideRequestBuffering(logger logr.Logger, anns map[string]str
isEnabled, err := strconv.ParseBool(strings.ToLower(annotationValue))
if err != nil {
// the value provided is not a parseable boolean, quit
logger.Error(err, "invalid request_buffering value", "kongroute", r.Name)
logger.Error(err, "Invalid request_buffering value", "kongroute", r.Name)
return
}

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

Expand Down Expand Up @@ -322,7 +322,7 @@ func (r *Route) overrideHosts(logger logr.Logger, anns map[string]string) {
hosts = appendIfMissing(hosts, sanitizedHost)
} else {
// Host Alias is not a valid hostname
logger.Error(nil, "invalid host alias", "value", hostAlias, "kongroute", r.Name)
logger.Error(nil, "Invalid host alias", "value", hostAlias, "kongroute", r.Name)
return
}
}
Expand All @@ -345,7 +345,7 @@ func (r *Route) overridePathHandling(logger logr.Logger, anns map[string]string)
}

if !validPathHandling.MatchString(val) {
logger.Error(nil, "invalid path_handling", "value", val, "kongroute", r.Name)
logger.Error(nil, "Invalid path_handling", "value", val, "kongroute", r.Name)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/dataplane/parser/backendref.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func backendRefsToKongStateBackends(
route.GetObjectKind().GroupVersionKind().String(),
route.GetNamespace(),
route.GetName())
logger.Error(nil, "object requested backendRef to target, but no ReferenceGrant permits it, skipping...",
logger.Error(nil, "Object requested backendRef to target, but no ReferenceGrant permits it, skipping...",
"object_name", objName,
"target_kind", kind,
"target_namespace", namespace,
Expand Down
4 changes: 2 additions & 2 deletions internal/dataplane/parser/ingressrules.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (ir *ingressRules) populateServices(logger logr.Logger, s store.Storer, fai
if parent, ok := ir.ServiceNameToParent[*service.Name]; ok {
service.Tags = util.GenerateTagsForObject(parent)
} else {
logger.Error(nil, "multi-service backend lacks parent info, cannot generate tags",
logger.Error(nil, "Multi-service backend lacks parent info, cannot generate tags",
"service", *service.Name)
}
} else if len(k8sServices) > 0 {
Expand All @@ -110,7 +110,7 @@ func (ir *ingressRules) populateServices(logger logr.Logger, s store.Storer, fai
// Service doesn't actually exist. attempting to generate tags for that Service would trigger a panic.
// the parser should discard this invalid route later, but this adds a placeholder value in case it doesn't.
// if you encounter an actual config where a service has these tags, something strange has happened.
logger.V(util.DebugLevel).Info("service has zero k8sServices backends, cannot generate tags for it properly",
logger.V(util.DebugLevel).Info("Service has zero k8sServices backends, cannot generate tags for it properly",
"service", *service.Name)
service.Tags = kong.StringSlice(
util.K8sNameTagPrefix+"UNKNOWN",
Expand Down
24 changes: 12 additions & 12 deletions internal/dataplane/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func shouldEnableParserExpressionRoutes(
logger.V(util.InfoLevel).Info("Gateway is running with non-expression router flavor", "flavor", routerFlavor)
return false
}
logger.V(util.InfoLevel).Info("expression routes mode enabled")
logger.V(util.InfoLevel).Info("The expression routes mode enabled")
return true
}

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

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

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

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

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

return targetsForEndpoints(endpoints)
Expand Down Expand Up @@ -765,7 +765,7 @@ func getEndpoints(

// ExternalName services
if service.Spec.Type == corev1.ServiceTypeExternalName {
logger.V(util.DebugLevel).Info("found service of type=ExternalName")
logger.V(util.DebugLevel).Info("Found service of type=ExternalName")
return []util.Endpoint{
{
Address: service.Spec.ExternalName,
Expand All @@ -774,13 +774,13 @@ func getEndpoints(
}
}

logger.V(util.DebugLevel).Info("fetching EndpointSlices")
logger.V(util.DebugLevel).Info("Fetching EndpointSlices")
endpointSlices, err := getEndpointSlices(service.Namespace, service.Name)
if err != nil {
logger.Error(err, "error fetching EndpointSlices")
logger.Error(err, "Error fetching EndpointSlices")
return []util.Endpoint{}
}
logger.V(util.DebugLevel).Info("fetched EndpointSlices", "count", len(endpointSlices))
logger.V(util.DebugLevel).Info("Fetched EndpointSlices", "count", len(endpointSlices))

// Avoid duplicated upstream servers when the service contains
// multiple port definitions sharing the same target port.
Expand Down Expand Up @@ -815,7 +815,7 @@ func getEndpoints(
}
}
}
logger.V(util.DebugLevel).Info("found endpoints", "endpoints", upstreamServers)
logger.V(util.DebugLevel).Info("Found endpoints", "endpoints", upstreamServers)
return upstreamServers
}

Expand Down
2 changes: 1 addition & 1 deletion internal/dataplane/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4526,7 +4526,7 @@ func TestNewFeatureFlags(t *testing.T) {
expectedFeatureFlags: FeatureFlags{
ExpressionRoutes: true,
},
expectInfoLog: "expression routes mode enabled",
expectInfoLog: "The expression routes mode enabled",
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/dataplane/parser/translate_grpcroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (p *Parser) ingressRulesFromGRPCRoutes() ingressRules {

if len(errs) > 0 {
for _, err := range errs {
p.logger.Error(err, "could not generate route from GRPCRoute")
p.logger.Error(err, "Could not generate route from GRPCRoute")
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (p *Parser) ingressRulesFromGRPCRouteWithPriority(
grpcRoute := splitGRPCRouteMatchWithPriority.Match.Source
// (very unlikely that) the rule index split from the source GRPCRoute is larger then length of original rules.
if len(grpcRoute.Spec.Rules) <= match.RuleIndex {
p.logger.Error(nil, "split rule index is greater than the length of rules in source GRPCRoute",
p.logger.Error(nil, "Split rule index is greater than the length of rules in source GRPCRoute",
"rule_index", match.RuleIndex,
"rule_count", len(grpcRoute.Spec.Rules))
return
Expand Down
2 changes: 1 addition & 1 deletion internal/dataplane/parser/translate_httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (p *Parser) ingressRulesFromSplitHTTPRouteMatchWithPriority(
match := httpRouteMatchWithPriority.Match
httpRoute := httpRouteMatchWithPriority.Match.Source
if match.RuleIndex >= len(httpRoute.Spec.Rules) {
p.logger.Error(nil, "split match has rule out of bound of rules in source HTTPRoute",
p.logger.Error(nil, "Split match has rule out of bound of rules in source HTTPRoute",
"rule_index", match.RuleIndex, "rule_count", len(httpRoute.Spec.Rules))
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/dataplane/parser/translate_tlsroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (p *Parser) ingressRulesFromTLSRoutes() ingressRules {
}

for _, err := range errs {
p.logger.Error(err, "could not generate route from TLSRoute")
p.logger.Error(err, "Could not generate route from TLSRoute")
}

return result
Expand Down
2 changes: 1 addition & 1 deletion internal/dataplane/parser/translate_udproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (p *Parser) ingressRulesFromUDPRoutes() ingressRules {
}

for _, err := range errs {
p.logger.Error(err, "could not generate route from UDPRoute")
p.logger.Error(err, "Could not generate route from UDPRoute")
}

return result
Expand Down
Loading