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

build: update to go 1.18.9 (backport #5607) #5613

Merged
merged 11 commits into from
Jan 11, 2023
9 changes: 6 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ parameters:
reusable:

constants:
- &go_version "1.17.3"
- &go_version "1.18.9"

docker_images:
- &golang_image "golang:1.17.3"
- &circleci_golang_image "circleci/golang:1.17.3"
- &golang_image "golang:1.18.9"
- &circleci_golang_image "cimg/go:1.18.9"

vm_images:
- &ubuntu_vm_image "ubuntu-2004:202111-01"
Expand Down Expand Up @@ -156,6 +156,9 @@ commands:
command: |
curl -s --fail --location https://dl.google.com/go/go<<parameters.go_version>>.<<parameters.go_os>>-<<parameters.go_arch>>.tar.gz | tar -xz -C $HOME
echo 'export PATH=$HOME/go/bin:$PATH' >> $BASH_ENV
# if GOPATH is not set, `golang-ci` fails with an obscure message
# "ERRO Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler"
echo 'export GOPATH=$HOME/go' >> $BASH_ENV
- run:
name: "Update runc"
# See https://github.com/rancher/k3d/issues/807 (runc's default version on the instance fails k3d)
Expand Down
21 changes: 7 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
linters:
enable:
- bodyclose
- contextcheck
- gci
- gocritic
- gofmt
- gomodguard
- importas
- misspell
- unconvert
- whitespace
# mk/check.mk sets the enabled/disable linters

run:
skip-files:
Expand All @@ -27,7 +16,11 @@ linters-settings:
disabled-checks:
- singleCaseSwitch
gci:
local-prefixes: github.com/kumahq/kuma
sections:
- standard
- default
- prefix(github.com/kumahq/kuma)
lukidzi marked this conversation as resolved.
Show resolved Hide resolved
custom-order: true
importas:
alias:
- pkg: github.com/kumahq/kuma/pkg/core/resources/apis/mesh
Expand Down Expand Up @@ -62,7 +55,7 @@ issues:
exclude-rules:
- linters:
- staticcheck
text: "SA1019: package github.com/golang/protobuf/proto is deprecated" # TODO ignore deprecation of proto library. We don't want to migrate yet because go-control-plane is not ready
text: 'SA1019: "github.com/golang/protobuf' # TODO ignore deprecation of proto library. We don't want to migrate yet because go-control-plane is not ready
- linters:
- staticcheck
text: "SA1019: package github.com/golang/protobuf/jsonpb" # TODO ignore deprecation of proto library. We don't want to migrate yet because go-control-plane is not ready
Expand Down
1 change: 0 additions & 1 deletion app/kuma-cp/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/kumahq/kuma/pkg/cmd/version"
"github.com/kumahq/kuma/pkg/core"
kuma_log "github.com/kumahq/kuma/pkg/log"

// import Envoy protobuf definitions so (un)marshaling Envoy protobuf works
_ "github.com/kumahq/kuma/pkg/xds/envoy"
)
Expand Down
22 changes: 11 additions & 11 deletions app/kuma-prometheus-sd/pkg/discovery/xds/v1/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ func (c Converter) ConvertAll(assignments []*observability_v1.MonitoringAssignme
//
// // Group is a set of targets with a common label set (production, test, staging etc.).
// type Group struct {
// // Targets is a list of targets identified by a label set. Each target is
// // uniquely identifiable in the group by its address label.
// Targets []model.LabelSet
// // Labels is a set of labels that is common across all targets in the group.
// Labels model.LabelSet
// // Targets is a list of targets identified by a label set. Each target is
// // uniquely identifiable in the group by its address label.
// Targets []model.LabelSet
// // Labels is a set of labels that is common across all targets in the group.
// Labels model.LabelSet
//
// // Source is an identifier that describes a group of targets.
// Source string
// // Source is an identifier that describes a group of targets.
// Source string
// }
//
// That is why Kuma's MonitoringAssignment was designed to be close to that model.
//
// 2. However, `file_sd` uses different model for reading data from a file:
//
// struct {
// Targets []string `yaml:"targets"`
// Labels model.LabelSet `yaml:"labels"`
// Targets []string `yaml:"targets"`
// Labels model.LabelSet `yaml:"labels"`
// }
//
// Notice that Targets is just a list of addresses rather than a list of model.LabelSet.
Expand All @@ -71,8 +71,8 @@ func (c Converter) ConvertAll(assignments []*observability_v1.MonitoringAssignme
//
// 5. Therefore, we need to convert MonitoringAssignment into a model that `custom-sd` expects.
//
// In practice, it means that generated MonitoringAssignment will be mapped to a set of groups, one per target.
// In the Prometheus native SD, this will not be the case and there will be a 1-1 mapping between assignments and groups.
// In practice, it means that generated MonitoringAssignment will be mapped to a set of groups, one per target.
// In the Prometheus native SD, this will not be the case and there will be a 1-1 mapping between assignments and groups.
func (c Converter) Convert(assignment *observability_v1.MonitoringAssignment) []*targetgroup.Group {
commonLabels := convertLabels(assignment.Labels)

Expand Down
2 changes: 0 additions & 2 deletions app/kumactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import (
kuma_cmd "github.com/kumahq/kuma/pkg/cmd"
"github.com/kumahq/kuma/pkg/core"
kuma_log "github.com/kumahq/kuma/pkg/log"

// Register gateway resources.
_ "github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"

// import Envoy protobuf definitions so (un)marshaling Envoy protobuf works
_ "github.com/kumahq/kuma/pkg/xds/envoy"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ require (
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368
google.golang.org/grpc v1.44.0
Expand Down Expand Up @@ -177,7 +178,6 @@ require (
golang.org/x/mod v0.5.0 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand Down
12 changes: 11 additions & 1 deletion mk/check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ shellcheck:

.PHONY: golangci-lint
golangci-lint: ## Dev: Runs golangci-lint linter
$(GOLANGCI_LINT_DIR)/golangci-lint run --timeout=10m -v
# Starting with golangci-lint v1.47.1, the CI job runs OOM if all of these
# linters are used together. The first set is the largest that ran without
# OOM.
$(GOLANGCI_LINT_DIR)/golangci-lint run \
--disable-all \
--enable bodyclose,errcheck,gci,gocritic,gofmt,gomodguard,govet,importas,ineffassign,misspell,typecheck,unconvert,whitespace \
--timeout=10m -v
$(GOLANGCI_LINT_DIR)/golangci-lint run \
--disable-all \
--enable gosimple,staticcheck,unused \
--timeout=10m -v

.PHONY: helm-lint
helm-lint:
Expand Down
2 changes: 1 addition & 1 deletion mk/dev.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GINKGO_VERSION := v1.16.5
GOLANGCI_LINT_VERSION := v1.43.0
GOLANGCI_LINT_VERSION := v1.49.0
GOLANG_PROTOBUF_VERSION := v1.5.2
HELM_DOCS_VERSION := 1.7.0
KUSTOMIZE_VERSION := v4.4.1
Expand Down
14 changes: 7 additions & 7 deletions pkg/core/logs/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
)

// Current limitations:
// 1) Right now we only generate and place access logs for outbound listeners
// 2) We match all tags in source section of TrafficLog but only service tag on destination
// 3) Let's assume we've got following dataplanes:
// Dataplane 1 with services: kong and kong-admin
// Dataplane 2 with services: backend
// If we define rule kong->backend, it is also applied for kong-admin because there is no way to differentiate
// traffic from services that are using one dataplane.
// 1. Right now we only generate and place access logs for outbound listeners
// 2. We match all tags in source section of TrafficLog but only service tag on destination
// 3. Let's assume we've got following dataplanes:
// Dataplane 1 with services: kong and kong-admin
// Dataplane 2 with services: backend
// If we define rule kong->backend, it is also applied for kong-admin because there is no way to differentiate
// traffic from services that are using one dataplane.
type TrafficLogsMatcher struct {
ResourceManager manager.ReadOnlyResourceManager
}
Expand Down
29 changes: 16 additions & 13 deletions pkg/core/ratelimits/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,22 @@ func BuildRateLimitMap(
// most general order.
//
// Example:
// sources:
// - match:
// kuma.io/service: 'web'
// version: '1'
// - match:
// kuma.io/service: 'web-api'
//---
// sources:
// - match:
// kuma.io/service: 'web'
// - match:
// kuma.io/service: 'web-api'
// version: '1'
//
// sources:
// - match:
// kuma.io/service: 'web'
// version: '1'
// - match:
// kuma.io/service: 'web-api'
//
// ---
//
// sources:
// - match:
// kuma.io/service: 'web'
// - match:
// kuma.io/service: 'web-api'
// version: '1'
func splitPoliciesBySourceMatch(rateLimits []*core_mesh.RateLimitResource) []*core_mesh.RateLimitResource {
result := []*core_mesh.RateLimitResource{}

Expand Down
6 changes: 3 additions & 3 deletions pkg/core/resources/apis/mesh/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ const dnsLabel = `[a-z0-9]([-a-z0-9]*[a-z0-9])?`
var domainRegexp = regexp.MustCompile("^" + dnsLabel + "(\\." + dnsLabel + ")*" + "$")

// ValidateHostname validates a gateway hostname field. A hostname may be one of
// - '*'
// - '*.domain.name'
// - 'domain.name'
// - '*'
// - '*.domain.name'
// - 'domain.name'
func ValidateHostname(path validators.PathBuilder, hostname string) validators.ValidationError {
if hostname == "*" {
return validators.ValidationError{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/resources/model/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ type ResourceType string
// Technically, ResourceNameExtensions is a mapping between
// a component identifier and a component value, e.g.
//
// "k8s.kuma.io/namespace" => "my-namespace"
// "k8s.kuma.io/name" => "my-policy"
// "k8s.kuma.io/namespace" => "my-namespace"
// "k8s.kuma.io/name" => "my-policy"
//
// Component identifier must be considered a part of user-facing Kuma API.
// In other words, it is supposed to be visible to users and should not be changed lightly.
Expand Down
14 changes: 7 additions & 7 deletions pkg/envoy/accesslog/v3/format_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ var parser = formatParser{}
// ParseFormat parses a given format string.
//
// The returned object can be used for multiple purposes, i.e.
// 1. To verify that access log format string is valid
// 2. To adjust configuration of `envoy.access_loggers.http_grpc` and `envoy.tcp_grpc_access_log`
// according to the format string, e.g. to capture additional HTTP headers
// 3. To format a given HTTP or TCP log entry according to the format string
// 4. To bind `%KUMA_*%` placeholders to concrete context-dependent values
// 5. To render back into the format string, e.g.
// after `%KUMA_*%` placeholders have been bound to concrete context-dependent values
// 1. To verify that access log format string is valid
// 2. To adjust configuration of `envoy.access_loggers.http_grpc` and `envoy.tcp_grpc_access_log`
// according to the format string, e.g. to capture additional HTTP headers
// 3. To format a given HTTP or TCP log entry according to the format string
// 4. To bind `%KUMA_*%` placeholders to concrete context-dependent values
// 5. To render back into the format string, e.g.
// after `%KUMA_*%` placeholders have been bound to concrete context-dependent values
func ParseFormat(format string) (*AccessLogFormat, error) {
return parser.Parse(format)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/plugins/resources/k8s/k8s_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (

"github.com/kumahq/kuma/pkg/plugins/bootstrap/k8s"
k8s_registry "github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/pkg/registry"

// +kubebuilder:scaffold:imports
sample_v1alpha1 "github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/test/api/sample/v1alpha1"
"github.com/kumahq/kuma/pkg/test"
Expand Down
18 changes: 9 additions & 9 deletions pkg/plugins/runtime/gateway/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ func MakeGatewayListener(
//
// This process is necessary because:
//
// 1. We might have a listener with hostname A and some routes, but also
// a wildcard listener with routes for hostname A. We want all the routes
// for hostname A in the same virtual host.
// 2. Routes with hostnames that are attached to a wildcard listener
// should implicitly create virtual hosts so that we can generate a
// consistent config. For example, if a wildcard listener has a route for
// hostname A and a route for hostname B, that doesn't mean that the routes
// are for hostnames A or B. We still want the routes to match the hostname
// that they were specified with.
// 1. We might have a listener with hostname A and some routes, but also
// a wildcard listener with routes for hostname A. We want all the routes
// for hostname A in the same virtual host.
// 2. Routes with hostnames that are attached to a wildcard listener
// should implicitly create virtual hosts so that we can generate a
// consistent config. For example, if a wildcard listener has a route for
// hostname A and a route for hostname B, that doesn't mean that the routes
// are for hostnames A or B. We still want the routes to match the hostname
// that they were specified with.
func RedistributeWildcardRoutes(
hosts []GatewayHost,
) []GatewayHost {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/runtime/gateway/match/hostnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func makeHostname(name string) hostname {
// any of the given matches. All the hostnames are assumed to be fully
// qualified (e.g. "foo.example.com") or wildcards (e.g. "*.example.com).
//
// Two hostnames match if
// # Two hostnames match if
//
// 1. They are exactly equal, OR
// 2. One of them is a domain wildcard and the domain part matches.
Expand Down
1 change: 0 additions & 1 deletion pkg/test/resources/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
// import to register all types
_ "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
"github.com/kumahq/kuma/pkg/core/resources/registry"

// import to register all types
_ "github.com/kumahq/kuma/pkg/test/resources/apis/sample"
)
Expand Down
1 change: 0 additions & 1 deletion pkg/xds/bootstrap/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/kumahq/kuma/pkg/core/validators"
core_xds "github.com/kumahq/kuma/pkg/core/xds"
"github.com/kumahq/kuma/pkg/xds/bootstrap/types"

// import Envoy protobuf definitions so (un)marshaling Envoy protobuf works in tests (normally it is imported in root.go)
envoy_common "github.com/kumahq/kuma/pkg/xds/envoy"
)
Expand Down
28 changes: 14 additions & 14 deletions pkg/xds/envoy/clusters/configurers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ func HealthCheck(protocol core_mesh.Protocol, healthCheck *core_mesh.HealthCheck

// LbSubset is required for MetadataMatch in Weighted Cluster in TCP Proxy to work.
// Subset loadbalancing is used in two use cases
// 1) TrafficRoute for splitting traffic. Example: TrafficRoute that splits 10% of the traffic to version 1 of the service backend and 90% traffic to version 2 of the service backend
// 2) Multiple outbound sections with the same service
// Example:
// type: Dataplane
// networking:
// outbound:
// - port: 1234
// tags:
// kuma.io/service: backend
// - port: 1234
// tags:
// kuma.io/service: backend
// version: v1
// Only one cluster "backend" is generated for such dataplane, but with lb subset by version.
// 1. TrafficRoute for splitting traffic. Example: TrafficRoute that splits 10% of the traffic to version 1 of the service backend and 90% traffic to version 2 of the service backend
// 2. Multiple outbound sections with the same service
// Example:
// type: Dataplane
// networking:
// outbound:
// - port: 1234
// tags:
// kuma.io/service: backend
// - port: 1234
// tags:
// kuma.io/service: backend
// version: v1
// Only one cluster "backend" is generated for such dataplane, but with lb subset by version.
func LbSubset(tagSets envoy.TagKeysSlice) ClusterBuilderOptFunc {
return func(config *ClusterBuilderConfig) {
config.AddV3(&v3.LbSubsetConfigurer{
Expand Down
11 changes: 0 additions & 11 deletions pkg/xds/envoy/listeners/v3/dns_configurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ import (

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
util_proto "github.com/kumahq/kuma/pkg/util/proto"
)

/*
Envoy DNS API had a version change from 'v3alpha' to 'v3' in Envoy v1.20.0.
Since go-control-plane contains only the latest protos, we had to vendor old 'v3alpha'
protos for backward compatibility with previous versions of the Envoy.
Imported directory contains copies of dns_filter protos from
'envoyproxy/go-control-plane v0.9.9-0.20210914001841-ec3541a22836'
*/
import (
envoy_dns_v3alpha "github.com/kumahq/kuma/pkg/xds/envoy/listeners/v3/compatibility/v3alpha"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/xds/hooks/resource_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
// If you want to for example modify only inbound listeners, search for the resource origin of OriginInbound
//
// WARNING: Please, be aware that Hooks are being called also in Ingress Dataplanes
// and when method Modify is being called, the passed MeshContext
// inside xds_context.Context will be empty
//
// and when method Modify is being called, the passed MeshContext
// inside xds_context.Context will be empty
type ResourceSetHook interface {
Modify(resourceSet *core_xds.ResourceSet, ctx xds_context.Context, proxy *core_xds.Proxy) error
}
Loading