From 12c8d723946a57b9ac7618eaa206de6bbdbc6301 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Thu, 3 Nov 2022 17:26:04 +0100 Subject: [PATCH 1/6] Use golangci-lint for header checks goheader's whitespace handling seems to be less fragile than license_checker's. This also means one less job in CI. Signed-off-by: Stephen Kitt --- .github/workflows/linting.yml | 10 ---------- .golangci.yml | 24 +++++++++++++++++++++++- .licenserc.json | 30 ------------------------------ 3 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 .licenserc.json diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index aa94d31c9..c05640aa8 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -64,16 +64,6 @@ jobs: - name: Run golangci-lint run: make golangci-lint - headers: - name: License Headers - runs-on: ubuntu-latest - steps: - - name: Check out the repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - - name: Check License Headers - uses: kt3k/license_checker@d12a6d90c58e30fefed09f2c4d03ba57f4c673a8 - licenses: name: Dependency Licenses runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml index 9747c437a..070aaaab1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,23 @@ linters-settings: godot: exclude: - ^\s*\+ + goheader: + template: |- + SPDX-License-Identifier: Apache-2.0 + + Copyright Contributors to the Submariner project. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. govet: enable: - fieldalignment @@ -68,7 +85,7 @@ linters: # - godox # Let's not forbid inline TODOs, FIXMEs et al - gofmt - gofumpt - # - goheader # We do license header linting another way + - goheader - goimports # - golint # Deprecated since v1.41.0 # - gomnd # It doesn't seem useful in general to enforce constants for all numeric values @@ -171,3 +188,8 @@ issues: - gochecknoinits - goerr113 - wrapcheck + + # Ignore header linting for files copied from the Operator SDK + - path: pkg/metrics/service-monitor.go + linters: + - goheader diff --git a/.licenserc.json b/.licenserc.json deleted file mode 100644 index 6a5d7f659..000000000 --- a/.licenserc.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "**/*.{go,proto}": [ - "Licensed under the Apache License, Version 2.0 (the \"License\");", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - " http://www.apache.org/licenses/LICENSE-2.0", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an \"AS IS\" BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "ignore": [ - "vendor/" - ] - }, - { - "**/*.{go,proto}": [ - "SPDX-License-Identifier: Apache-2.0", - "Copyright Contributors to the Submariner project." - ], - "ignore": [ - "vendor/" - ] - }, - { - "LICENSE": "Apache License" - } -] From d6a56411c375a6c883b109662f59a92c82444da5 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 14 Nov 2022 16:46:29 +0100 Subject: [PATCH 2/6] Remove space between // and nolint This is enforced by newer releases of golangci-lint. Signed-off-by: Stephen Kitt --- pkg/discovery/network/flannel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/discovery/network/flannel.go b/pkg/discovery/network/flannel.go index 3423596b3..470aa8aaf 100644 --- a/pkg/discovery/network/flannel.go +++ b/pkg/discovery/network/flannel.go @@ -31,7 +31,7 @@ import ( controllerClient "sigs.k8s.io/controller-runtime/pkg/client" ) -// nolint:nilnil // Intentional as the purpose is to discover. +//nolint:nilnil // Intentional as the purpose is to discover. func discoverFlannelNetwork(client controllerClient.Client) (*ClusterNetwork, error) { daemonsets := &appsv1.DaemonSetList{} From d24d9e68ecde795428bd5a92319593f2e004cd19 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 14 Nov 2022 16:47:02 +0100 Subject: [PATCH 3/6] Disable deprecated linters varcheck, deadcode, and structcheck are deprecated since 1.49.0. Signed-off-by: Stephen Kitt --- .golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 070aaaab1..7ffd5372a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -58,7 +58,6 @@ linters: - bodyclose - contextcheck # - cyclop # This is equivalent to gocyclo - - deadcode - depguard - dogsled - dupl @@ -121,7 +120,6 @@ linters: # - scopelint # Deprecated since v1.39.0 # - sqlclosecheck # We don't use SQL - staticcheck - - structcheck - stylecheck # - tagliatelle # Inconsistent with stylecheck and not as good # - tenv # Not relevant for our Ginkgo UTs @@ -132,7 +130,6 @@ linters: - unconvert - unparam - unused - - varcheck # - varnamelen # It doesn't seem necessary to enforce a minimum variable name length - wastedassign - whitespace From 85b4c6eb72df8cdc5ee7963dba6fa2a510fb46d1 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 14 Nov 2022 17:14:23 +0100 Subject: [PATCH 4/6] Drop the leading spaces before the ASL URL This causes conflicts with gci in some cases. Signed-off-by: Stephen Kitt --- .golangci.yml | 2 +- api/v1alpha1/broker_types.go | 2 +- api/v1alpha1/groupversion_info.go | 2 +- api/v1alpha1/servicediscovery_types.go | 2 +- api/v1alpha1/submariner_types.go | 2 +- api/v1alpha1/versions.go | 2 +- api/v1alpha1/zz_generated.deepcopy.go | 2 +- controllers/apply/apply.go | 2 +- controllers/constants/constants.go | 2 +- controllers/metrics/metrics.go | 2 +- controllers/resource/client.go | 2 +- controllers/servicediscovery/cleanup.go | 2 +- controllers/servicediscovery/core_dns_port_internal_test.go | 2 +- controllers/servicediscovery/servicediscovery_controller.go | 2 +- .../servicediscovery/servicediscovery_controller_test.go | 2 +- controllers/servicediscovery/servicediscovery_suite_test.go | 2 +- controllers/submariner/broker_controller.go | 2 +- controllers/submariner/cleanup.go | 2 +- controllers/submariner/daemonsets.go | 2 +- controllers/submariner/gateway_resources.go | 2 +- controllers/submariner/globalnet_resources.go | 2 +- controllers/submariner/loadbalancer_resources.go | 2 +- controllers/submariner/metrics_proxy_resources.go | 2 +- controllers/submariner/np_syncer_resources.go | 2 +- controllers/submariner/route_agent_resources.go | 2 +- controllers/submariner/servicediscovery_resources.go | 2 +- controllers/submariner/submariner_controller.go | 2 +- controllers/submariner/submariner_controller_test.go | 2 +- controllers/submariner/submariner_metrics.go | 2 +- controllers/submariner/submariner_networkdiscovery.go | 2 +- controllers/submariner/submariner_suite_test.go | 2 +- controllers/test/driver.go | 2 +- controllers/uninstall/uninstall.go | 2 +- hack/boilerplate.go.txt | 2 +- main.go | 2 +- pkg/crd/crd_suite_test.go | 2 +- pkg/crd/updater.go | 2 +- pkg/crd/updater_test.go | 2 +- pkg/discovery/globalnet/config_map.go | 2 +- pkg/discovery/globalnet/globalnet.go | 2 +- pkg/discovery/globalnet/globalnet_suite_test.go | 2 +- pkg/discovery/globalnet/globalnet_test.go | 2 +- pkg/discovery/network/calico.go | 2 +- pkg/discovery/network/calico_test.go | 2 +- pkg/discovery/network/canal.go | 2 +- pkg/discovery/network/canal_test.go | 2 +- pkg/discovery/network/flannel.go | 2 +- pkg/discovery/network/flannel_test.go | 2 +- pkg/discovery/network/generic.go | 2 +- pkg/discovery/network/generic_test.go | 2 +- pkg/discovery/network/kindnet.go | 2 +- pkg/discovery/network/kindnet_test.go | 2 +- pkg/discovery/network/network.go | 2 +- pkg/discovery/network/network_suite_test.go | 2 +- pkg/discovery/network/openshift4.go | 2 +- pkg/discovery/network/openshift4_test.go | 2 +- pkg/discovery/network/ovnkubernetes.go | 2 +- pkg/discovery/network/ovnkubernetes_test.go | 2 +- pkg/discovery/network/pods.go | 2 +- pkg/discovery/network/pods_test.go | 2 +- pkg/discovery/network/weavenet.go | 2 +- pkg/discovery/network/weavenet_test.go | 2 +- pkg/embeddedyamls/generate.go | 2 +- pkg/embeddedyamls/generators/yamls2go.go | 4 ++-- pkg/embeddedyamls/unmarshal.go | 2 +- pkg/embeddedyamls/yamls.go | 2 +- pkg/gateway/crds.go | 2 +- pkg/images/image_parsing_test.go | 2 +- pkg/images/images.go | 2 +- pkg/lighthouse/crds.go | 2 +- pkg/names/names.go | 2 +- pkg/version/version.go | 2 +- test/e2e/cleanup/submariner.go | 2 +- test/e2e/e2e_test.go | 2 +- tools.go | 2 +- 75 files changed, 76 insertions(+), 76 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7ffd5372a..d55ccea2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,7 @@ linters-settings: you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/broker_types.go b/api/v1alpha1/broker_types.go index 6cec8bf98..ac1a8895a 100644 --- a/api/v1alpha1/broker_types.go +++ b/api/v1alpha1/broker_types.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go index 0ba08f444..95e69fa0e 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/groupversion_info.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/servicediscovery_types.go b/api/v1alpha1/servicediscovery_types.go index 7b838e223..a9ea310a9 100644 --- a/api/v1alpha1/servicediscovery_types.go +++ b/api/v1alpha1/servicediscovery_types.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/submariner_types.go b/api/v1alpha1/submariner_types.go index 48426d1ee..9196047ed 100644 --- a/api/v1alpha1/submariner_types.go +++ b/api/v1alpha1/submariner_types.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/versions.go b/api/v1alpha1/versions.go index df55a5f5f..ac23276b6 100644 --- a/api/v1alpha1/versions.go +++ b/api/v1alpha1/versions.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4f03a8d27..d9a716f10 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/apply/apply.go b/controllers/apply/apply.go index 190bd956c..c4f09b8c6 100644 --- a/controllers/apply/apply.go +++ b/controllers/apply/apply.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/constants/constants.go b/controllers/constants/constants.go index 7b5d943c4..698f42125 100644 --- a/controllers/constants/constants.go +++ b/controllers/constants/constants.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/metrics/metrics.go b/controllers/metrics/metrics.go index e36f1dd27..dc0faecc3 100644 --- a/controllers/metrics/metrics.go +++ b/controllers/metrics/metrics.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/resource/client.go b/controllers/resource/client.go index 398e7a59d..c4e6ed752 100644 --- a/controllers/resource/client.go +++ b/controllers/resource/client.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/servicediscovery/cleanup.go b/controllers/servicediscovery/cleanup.go index 9fc4d5c28..3ad186a13 100644 --- a/controllers/servicediscovery/cleanup.go +++ b/controllers/servicediscovery/cleanup.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/servicediscovery/core_dns_port_internal_test.go b/controllers/servicediscovery/core_dns_port_internal_test.go index 7037a52fd..e7c68ef35 100644 --- a/controllers/servicediscovery/core_dns_port_internal_test.go +++ b/controllers/servicediscovery/core_dns_port_internal_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/servicediscovery/servicediscovery_controller.go b/controllers/servicediscovery/servicediscovery_controller.go index d825f86ff..78a92c7b4 100644 --- a/controllers/servicediscovery/servicediscovery_controller.go +++ b/controllers/servicediscovery/servicediscovery_controller.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/servicediscovery/servicediscovery_controller_test.go b/controllers/servicediscovery/servicediscovery_controller_test.go index 86ee64f7c..17307f5a4 100644 --- a/controllers/servicediscovery/servicediscovery_controller_test.go +++ b/controllers/servicediscovery/servicediscovery_controller_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/servicediscovery/servicediscovery_suite_test.go b/controllers/servicediscovery/servicediscovery_suite_test.go index f77bc9712..14611d419 100644 --- a/controllers/servicediscovery/servicediscovery_suite_test.go +++ b/controllers/servicediscovery/servicediscovery_suite_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/broker_controller.go b/controllers/submariner/broker_controller.go index 09c5d1047..b75037676 100644 --- a/controllers/submariner/broker_controller.go +++ b/controllers/submariner/broker_controller.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/cleanup.go b/controllers/submariner/cleanup.go index b03c18eeb..1e35867cb 100644 --- a/controllers/submariner/cleanup.go +++ b/controllers/submariner/cleanup.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/daemonsets.go b/controllers/submariner/daemonsets.go index 4d9840f0a..2d7b0f461 100644 --- a/controllers/submariner/daemonsets.go +++ b/controllers/submariner/daemonsets.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/gateway_resources.go b/controllers/submariner/gateway_resources.go index 113a65ab2..11e5d99ac 100644 --- a/controllers/submariner/gateway_resources.go +++ b/controllers/submariner/gateway_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/globalnet_resources.go b/controllers/submariner/globalnet_resources.go index 5d4cef4f5..d4460b21b 100644 --- a/controllers/submariner/globalnet_resources.go +++ b/controllers/submariner/globalnet_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/loadbalancer_resources.go b/controllers/submariner/loadbalancer_resources.go index acaf2fb77..2bf845515 100644 --- a/controllers/submariner/loadbalancer_resources.go +++ b/controllers/submariner/loadbalancer_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/metrics_proxy_resources.go b/controllers/submariner/metrics_proxy_resources.go index c98d077de..5f328e806 100644 --- a/controllers/submariner/metrics_proxy_resources.go +++ b/controllers/submariner/metrics_proxy_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/np_syncer_resources.go b/controllers/submariner/np_syncer_resources.go index ad86519f8..8a20e0544 100644 --- a/controllers/submariner/np_syncer_resources.go +++ b/controllers/submariner/np_syncer_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/route_agent_resources.go b/controllers/submariner/route_agent_resources.go index 23cee06b0..e536df118 100644 --- a/controllers/submariner/route_agent_resources.go +++ b/controllers/submariner/route_agent_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/servicediscovery_resources.go b/controllers/submariner/servicediscovery_resources.go index 7e8c54004..0a5ce1279 100644 --- a/controllers/submariner/servicediscovery_resources.go +++ b/controllers/submariner/servicediscovery_resources.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/submariner_controller.go b/controllers/submariner/submariner_controller.go index 9d29939fc..3623b9251 100644 --- a/controllers/submariner/submariner_controller.go +++ b/controllers/submariner/submariner_controller.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/submariner_controller_test.go b/controllers/submariner/submariner_controller_test.go index dcd02faf6..f2ebb0728 100644 --- a/controllers/submariner/submariner_controller_test.go +++ b/controllers/submariner/submariner_controller_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/submariner_metrics.go b/controllers/submariner/submariner_metrics.go index 35169baec..7b2a5e924 100644 --- a/controllers/submariner/submariner_metrics.go +++ b/controllers/submariner/submariner_metrics.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/submariner_networkdiscovery.go b/controllers/submariner/submariner_networkdiscovery.go index 9d04a356f..4ffb46fdf 100644 --- a/controllers/submariner/submariner_networkdiscovery.go +++ b/controllers/submariner/submariner_networkdiscovery.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/submariner/submariner_suite_test.go b/controllers/submariner/submariner_suite_test.go index f3a56f7ce..9fc473898 100644 --- a/controllers/submariner/submariner_suite_test.go +++ b/controllers/submariner/submariner_suite_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/test/driver.go b/controllers/test/driver.go index 24ac0109d..dd9695cce 100644 --- a/controllers/test/driver.go +++ b/controllers/test/driver.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/controllers/uninstall/uninstall.go b/controllers/uninstall/uninstall.go index b5e39d1f6..63e3e2aee 100644 --- a/controllers/uninstall/uninstall.go +++ b/controllers/uninstall/uninstall.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index 5456d0af1..19c12d661 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/main.go b/main.go index c13745e3f..c09a049fc 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/crd/crd_suite_test.go b/pkg/crd/crd_suite_test.go index 79cbfe115..001d4baea 100644 --- a/pkg/crd/crd_suite_test.go +++ b/pkg/crd/crd_suite_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/crd/updater.go b/pkg/crd/updater.go index 46c27761d..580fd0708 100644 --- a/pkg/crd/updater.go +++ b/pkg/crd/updater.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/crd/updater_test.go b/pkg/crd/updater_test.go index 7ec69512e..e8d29a40d 100644 --- a/pkg/crd/updater_test.go +++ b/pkg/crd/updater_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/globalnet/config_map.go b/pkg/discovery/globalnet/config_map.go index cd2b81c9a..30ae31ee1 100644 --- a/pkg/discovery/globalnet/config_map.go +++ b/pkg/discovery/globalnet/config_map.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/globalnet/globalnet.go b/pkg/discovery/globalnet/globalnet.go index 94095185f..620eb8dbf 100644 --- a/pkg/discovery/globalnet/globalnet.go +++ b/pkg/discovery/globalnet/globalnet.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/globalnet/globalnet_suite_test.go b/pkg/discovery/globalnet/globalnet_suite_test.go index 73a05477b..1f21a7437 100644 --- a/pkg/discovery/globalnet/globalnet_suite_test.go +++ b/pkg/discovery/globalnet/globalnet_suite_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/globalnet/globalnet_test.go b/pkg/discovery/globalnet/globalnet_test.go index d4e690c07..36a5cd92e 100644 --- a/pkg/discovery/globalnet/globalnet_test.go +++ b/pkg/discovery/globalnet/globalnet_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/calico.go b/pkg/discovery/network/calico.go index 939ec2c8a..079be4a91 100644 --- a/pkg/discovery/network/calico.go +++ b/pkg/discovery/network/calico.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/calico_test.go b/pkg/discovery/network/calico_test.go index 618518c66..239d7b9ff 100644 --- a/pkg/discovery/network/calico_test.go +++ b/pkg/discovery/network/calico_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/canal.go b/pkg/discovery/network/canal.go index 1ed0ca26f..97c441d5f 100644 --- a/pkg/discovery/network/canal.go +++ b/pkg/discovery/network/canal.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/canal_test.go b/pkg/discovery/network/canal_test.go index ab91a8571..90ddee8af 100644 --- a/pkg/discovery/network/canal_test.go +++ b/pkg/discovery/network/canal_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/flannel.go b/pkg/discovery/network/flannel.go index 470aa8aaf..fc73b9e21 100644 --- a/pkg/discovery/network/flannel.go +++ b/pkg/discovery/network/flannel.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/flannel_test.go b/pkg/discovery/network/flannel_test.go index fa9204d87..e0c0433f8 100644 --- a/pkg/discovery/network/flannel_test.go +++ b/pkg/discovery/network/flannel_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/generic.go b/pkg/discovery/network/generic.go index ca3efd521..04df28a3e 100644 --- a/pkg/discovery/network/generic.go +++ b/pkg/discovery/network/generic.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/generic_test.go b/pkg/discovery/network/generic_test.go index 397ffc441..94a0c67c1 100644 --- a/pkg/discovery/network/generic_test.go +++ b/pkg/discovery/network/generic_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/kindnet.go b/pkg/discovery/network/kindnet.go index bf06ae9e9..6f9583503 100644 --- a/pkg/discovery/network/kindnet.go +++ b/pkg/discovery/network/kindnet.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/kindnet_test.go b/pkg/discovery/network/kindnet_test.go index cd822a895..4d67c7c66 100644 --- a/pkg/discovery/network/kindnet_test.go +++ b/pkg/discovery/network/kindnet_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/network.go b/pkg/discovery/network/network.go index ec494b9b3..c325111f8 100644 --- a/pkg/discovery/network/network.go +++ b/pkg/discovery/network/network.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/network_suite_test.go b/pkg/discovery/network/network_suite_test.go index 3ebf8db6e..387fa22aa 100644 --- a/pkg/discovery/network/network_suite_test.go +++ b/pkg/discovery/network/network_suite_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/openshift4.go b/pkg/discovery/network/openshift4.go index 168e05c2e..efca33820 100644 --- a/pkg/discovery/network/openshift4.go +++ b/pkg/discovery/network/openshift4.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/openshift4_test.go b/pkg/discovery/network/openshift4_test.go index 31f3bdc46..0fa8a62fb 100644 --- a/pkg/discovery/network/openshift4_test.go +++ b/pkg/discovery/network/openshift4_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/ovnkubernetes.go b/pkg/discovery/network/ovnkubernetes.go index 42f48932b..a266a7684 100644 --- a/pkg/discovery/network/ovnkubernetes.go +++ b/pkg/discovery/network/ovnkubernetes.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/ovnkubernetes_test.go b/pkg/discovery/network/ovnkubernetes_test.go index 0f3ad0738..ed8b2f855 100644 --- a/pkg/discovery/network/ovnkubernetes_test.go +++ b/pkg/discovery/network/ovnkubernetes_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/pods.go b/pkg/discovery/network/pods.go index 63e805e75..92f1d3526 100644 --- a/pkg/discovery/network/pods.go +++ b/pkg/discovery/network/pods.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/pods_test.go b/pkg/discovery/network/pods_test.go index 084dcbdc2..4a6d8ec16 100644 --- a/pkg/discovery/network/pods_test.go +++ b/pkg/discovery/network/pods_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/weavenet.go b/pkg/discovery/network/weavenet.go index 756840048..edb818564 100644 --- a/pkg/discovery/network/weavenet.go +++ b/pkg/discovery/network/weavenet.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/discovery/network/weavenet_test.go b/pkg/discovery/network/weavenet_test.go index 582c76c42..c49d32d70 100644 --- a/pkg/discovery/network/weavenet_test.go +++ b/pkg/discovery/network/weavenet_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/embeddedyamls/generate.go b/pkg/embeddedyamls/generate.go index 28d5484da..83eabbd9f 100644 --- a/pkg/embeddedyamls/generate.go +++ b/pkg/embeddedyamls/generate.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/embeddedyamls/generators/yamls2go.go b/pkg/embeddedyamls/generators/yamls2go.go index 55a73b53b..5f0dfbd31 100644 --- a/pkg/embeddedyamls/generators/yamls2go.go +++ b/pkg/embeddedyamls/generators/yamls2go.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -120,7 +120,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/embeddedyamls/unmarshal.go b/pkg/embeddedyamls/unmarshal.go index f36d5858c..249f152ee 100644 --- a/pkg/embeddedyamls/unmarshal.go +++ b/pkg/embeddedyamls/unmarshal.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/embeddedyamls/yamls.go b/pkg/embeddedyamls/yamls.go index fcbf9c509..e6f3282be 100644 --- a/pkg/embeddedyamls/yamls.go +++ b/pkg/embeddedyamls/yamls.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/gateway/crds.go b/pkg/gateway/crds.go index 1d1b59ad0..40faa0dcc 100644 --- a/pkg/gateway/crds.go +++ b/pkg/gateway/crds.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/images/image_parsing_test.go b/pkg/images/image_parsing_test.go index 0716f4730..8f1b7f119 100644 --- a/pkg/images/image_parsing_test.go +++ b/pkg/images/image_parsing_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/images/images.go b/pkg/images/images.go index 635018a05..55fdc9f55 100644 --- a/pkg/images/images.go +++ b/pkg/images/images.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/lighthouse/crds.go b/pkg/lighthouse/crds.go index 71d84cda5..50e829540 100644 --- a/pkg/lighthouse/crds.go +++ b/pkg/lighthouse/crds.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/names/names.go b/pkg/names/names.go index a805353f8..35f2c07ee 100644 --- a/pkg/names/names.go +++ b/pkg/names/names.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/version/version.go b/pkg/version/version.go index 213e557bf..f1afcdc01 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/test/e2e/cleanup/submariner.go b/test/e2e/cleanup/submariner.go index 43c1f8cfc..757bd0fb3 100644 --- a/test/e2e/cleanup/submariner.go +++ b/test/e2e/cleanup/submariner.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 8688e87bd..4ed87f588 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/tools.go b/tools.go index 86c0a9462..1c667d47f 100644 --- a/tools.go +++ b/tools.go @@ -10,7 +10,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, From c774e37dd98a3590b82c03857941f3c74b5502ed Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 15 Nov 2022 15:40:57 +0100 Subject: [PATCH 5/6] Ensure the reconciliation context is passed Instead of relying on context.TODO(), function using a context should consume one given as a parameter; this allows the reconciliation context to be used consistently. Signed-off-by: Stephen Kitt --- controllers/apply/apply.go | 24 +++++----- controllers/metrics/metrics.go | 7 +-- .../servicediscovery_controller.go | 23 +++++----- controllers/submariner/broker_controller.go | 8 ++-- controllers/submariner/cleanup.go | 2 +- controllers/submariner/gateway_resources.go | 8 ++-- controllers/submariner/globalnet_resources.go | 11 ++--- .../submariner/loadbalancer_resources.go | 6 ++- .../submariner/metrics_proxy_resources.go | 8 ++-- controllers/submariner/np_syncer_resources.go | 5 ++- .../submariner/route_agent_resources.go | 8 ++-- .../submariner/submariner_controller.go | 15 ++++--- .../submariner/submariner_networkdiscovery.go | 10 +++-- main.go | 6 +-- pkg/discovery/globalnet/config_map.go | 16 +++---- pkg/discovery/globalnet/globalnet.go | 15 ++++--- pkg/discovery/network/calico.go | 6 +-- pkg/discovery/network/calico_test.go | 8 ++-- pkg/discovery/network/canal.go | 6 +-- pkg/discovery/network/canal_test.go | 6 ++- pkg/discovery/network/flannel.go | 8 ++-- pkg/discovery/network/flannel_test.go | 4 +- pkg/discovery/network/generic.go | 44 +++++++++---------- pkg/discovery/network/generic_test.go | 7 +-- pkg/discovery/network/kindnet.go | 8 ++-- pkg/discovery/network/network.go | 22 +++++----- pkg/discovery/network/openshift4.go | 4 +- pkg/discovery/network/openshift4_test.go | 4 +- pkg/discovery/network/ovnkubernetes.go | 8 ++-- pkg/discovery/network/ovnkubernetes_test.go | 3 +- pkg/discovery/network/pods.go | 8 ++-- pkg/discovery/network/pods_test.go | 16 ++++--- pkg/discovery/network/weavenet.go | 8 ++-- pkg/discovery/network/weavenet_test.go | 4 +- pkg/gateway/crds.go | 14 +++--- pkg/lighthouse/crds.go | 8 ++-- pkg/metrics/service-monitor.go | 7 +-- 37 files changed, 203 insertions(+), 172 deletions(-) diff --git a/controllers/apply/apply.go b/controllers/apply/apply.go index c4f09b8c6..cdcb804bc 100644 --- a/controllers/apply/apply.go +++ b/controllers/apply/apply.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) -func DaemonSet(owner metav1.Object, daemonSet *appsv1.DaemonSet, reqLogger logr.Logger, +func DaemonSet(ctx context.Context, owner metav1.Object, daemonSet *appsv1.DaemonSet, reqLogger logr.Logger, client controllerClient.Client, scheme *runtime.Scheme, ) (*appsv1.DaemonSet, error) { var err error @@ -54,7 +54,7 @@ func DaemonSet(owner metav1.Object, daemonSet *appsv1.DaemonSet, reqLogger logr. Labels: map[string]string{}, }} - result, err := controllerutil.CreateOrUpdate(context.TODO(), client, toUpdate, func() error { + result, err := controllerutil.CreateOrUpdate(ctx, client, toUpdate, func() error { toUpdate.Spec = daemonSet.Spec copyLabels(daemonSet, toUpdate) @@ -66,11 +66,11 @@ func DaemonSet(owner metav1.Object, daemonSet *appsv1.DaemonSet, reqLogger logr. reqLogger.Info("Re-creating a DaemonSet because it has immutable fields", "DaemonSet.Namespace", daemonSet.Namespace, "DaemonSet.Name", daemonSet.Name) - if err := client.Delete(context.TODO(), toUpdate); err != nil { + if err := client.Delete(ctx, toUpdate); err != nil { return err //nolint:wrapcheck // No need to wrap here } - if err := client.Create(context.TODO(), daemonSet); err != nil { + if err := client.Create(ctx, daemonSet); err != nil { return err //nolint:wrapcheck // No need to wrap here } @@ -90,13 +90,13 @@ func DaemonSet(owner metav1.Object, daemonSet *appsv1.DaemonSet, reqLogger logr. // Update the status from the server if err == nil { - err = client.Get(context.TODO(), types.NamespacedName{Namespace: daemonSet.Namespace, Name: daemonSet.Name}, daemonSet) + err = client.Get(ctx, types.NamespacedName{Namespace: daemonSet.Namespace, Name: daemonSet.Name}, daemonSet) } return daemonSet, errors.WithMessagef(err, "error creating or updating DaemonSet %s/%s", daemonSet.Namespace, daemonSet.Name) } -func Deployment(owner metav1.Object, deployment *appsv1.Deployment, reqLogger logr.Logger, +func Deployment(ctx context.Context, owner metav1.Object, deployment *appsv1.Deployment, reqLogger logr.Logger, client controllerClient.Client, scheme *runtime.Scheme, ) (*appsv1.Deployment, error) { var err error @@ -135,13 +135,13 @@ func Deployment(owner metav1.Object, deployment *appsv1.Deployment, reqLogger lo // Update the status from the server if err == nil { - err = client.Get(context.TODO(), types.NamespacedName{Namespace: deployment.Namespace, Name: deployment.Name}, deployment) + err = client.Get(ctx, types.NamespacedName{Namespace: deployment.Namespace, Name: deployment.Name}, deployment) } return deployment, errors.WithMessagef(err, "error creating or updating Deployment %s/%s", deployment.Namespace, deployment.Name) } -func ConfigMap(owner metav1.Object, configMap *corev1.ConfigMap, reqLogger logr.Logger, +func ConfigMap(ctx context.Context, owner metav1.Object, configMap *corev1.ConfigMap, reqLogger logr.Logger, client controllerClient.Client, scheme *runtime.Scheme, ) (*corev1.ConfigMap, error) { var err error @@ -180,13 +180,13 @@ func ConfigMap(owner metav1.Object, configMap *corev1.ConfigMap, reqLogger logr. // Update the status from the server if err == nil { - err = client.Get(context.TODO(), types.NamespacedName{Namespace: configMap.Namespace, Name: configMap.Name}, configMap) + err = client.Get(ctx, types.NamespacedName{Namespace: configMap.Namespace, Name: configMap.Name}, configMap) } return configMap, errors.WithMessagef(err, "error creating or updating ConfigMap %s/%s", configMap.Namespace, configMap.Name) } -func Service(owner metav1.Object, service *corev1.Service, reqLogger logr.Logger, +func Service(ctx context.Context, owner metav1.Object, service *corev1.Service, reqLogger logr.Logger, client controllerClient.Client, scheme *runtime.Scheme, ) (*corev1.Service, error) { var err error @@ -206,7 +206,7 @@ func Service(owner metav1.Object, service *corev1.Service, reqLogger logr.Logger Annotations: map[string]string{}, }} - result, err := controllerutil.CreateOrUpdate(context.TODO(), client, toUpdate, func() error { + result, err := controllerutil.CreateOrUpdate(ctx, client, toUpdate, func() error { if toUpdate.Spec.Type == corev1.ServiceTypeClusterIP || toUpdate.Spec.Type == corev1.ServiceTypeLoadBalancer { // Make sure we don't lose the ClusterIP, see https://github.com/kubernetes/kubectl/issues/798 service.Spec.ClusterIP = toUpdate.Spec.ClusterIP @@ -244,7 +244,7 @@ func Service(owner metav1.Object, service *corev1.Service, reqLogger logr.Logger // Update the status from the server if err == nil { - err = client.Get(context.TODO(), types.NamespacedName{Namespace: service.Namespace, Name: service.Name}, service) + err = client.Get(ctx, types.NamespacedName{Namespace: service.Namespace, Name: service.Name}, service) } return service, errors.WithMessagef(err, "error creating or updating Service %s/%s", service.Namespace, service.Name) diff --git a/controllers/metrics/metrics.go b/controllers/metrics/metrics.go index dc0faecc3..63991c355 100644 --- a/controllers/metrics/metrics.go +++ b/controllers/metrics/metrics.go @@ -19,6 +19,7 @@ limitations under the License. package metrics import ( + "context" "errors" "fmt" @@ -34,10 +35,10 @@ import ( controllerClient "sigs.k8s.io/controller-runtime/pkg/client" ) -func Setup(serviceName, namespace, applicationKey, applicationName string, owner metav1.Object, port int32, +func Setup(ctx context.Context, serviceName, namespace, applicationKey, applicationName string, owner metav1.Object, port int32, client controllerClient.Client, config *rest.Config, scheme *runtime.Scheme, reqLogger logr.Logger, ) error { - metricsService, err := apply.Service(owner, newMetricsService(serviceName, namespace, applicationKey, + metricsService, err := apply.Service(ctx, owner, newMetricsService(serviceName, namespace, applicationKey, applicationName, port), reqLogger, client, scheme) if err != nil { return err //nolint:wrapcheck // No need to wrap here @@ -46,7 +47,7 @@ func Setup(serviceName, namespace, applicationKey, applicationName string, owner if config != nil { services := []*corev1.Service{metricsService} - _, err = metrics.CreateServiceMonitors(config, namespace, services) + _, err = metrics.CreateServiceMonitors(ctx, config, namespace, services) if err != nil { // If this operator is deployed to a cluster without the prometheus-operator running, it will return // ErrServiceMonitorNotPresent, which can be used to safely skip ServiceMonitor creation. diff --git a/controllers/servicediscovery/servicediscovery_controller.go b/controllers/servicediscovery/servicediscovery_controller.go index 78a92c7b4..ad8fa7a32 100644 --- a/controllers/servicediscovery/servicediscovery_controller.go +++ b/controllers/servicediscovery/servicediscovery_controller.go @@ -127,19 +127,19 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( return r.doCleanup(ctx, instance) } - err = r.ensureLightHouseAgent(instance, reqLogger) + err = r.ensureLightHouseAgent(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } lighthouseDNSConfigMap := newLighthouseDNSConfigMap(instance) - if _, err = apply.ConfigMap(instance, lighthouseDNSConfigMap, reqLogger, + if _, err = apply.ConfigMap(ctx, instance, lighthouseDNSConfigMap, reqLogger, r.ScopedClient, r.Scheme); err != nil { log.Error(err, "Error creating the lighthouseCoreDNS configMap") return reconcile.Result{}, errors.Wrap(err, "error reconciling ConfigMap") } - err = r.ensureLighthouseCoreDNSDeployment(instance, reqLogger) + err = r.ensureLighthouseCoreDNSDeployment(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } @@ -685,14 +685,15 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -func (r *Reconciler) ensureLightHouseAgent(instance *submarinerv1alpha1.ServiceDiscovery, reqLogger logr.Logger) error { +func (r *Reconciler) ensureLightHouseAgent(ctx context.Context, instance *submarinerv1alpha1.ServiceDiscovery, reqLogger logr.Logger, +) error { lightHouseAgent := newLighthouseAgent(instance, names.ServiceDiscoveryComponent) - if _, err := apply.Deployment(instance, lightHouseAgent, reqLogger, + if _, err := apply.Deployment(ctx, instance, lightHouseAgent, reqLogger, r.ScopedClient, r.Scheme); err != nil { return errors.Wrap(err, "error reconciling agent deployment") } - err := metrics.Setup(names.ServiceDiscoveryComponent, instance.Namespace, "app", names.ServiceDiscoveryComponent, + err := metrics.Setup(ctx, names.ServiceDiscoveryComponent, instance.Namespace, "app", names.ServiceDiscoveryComponent, instance, 8082, r.ScopedClient, r.RestConfig, r.Scheme, reqLogger) if err != nil { return errors.Wrap(err, "error setting up metrics") @@ -701,15 +702,17 @@ func (r *Reconciler) ensureLightHouseAgent(instance *submarinerv1alpha1.ServiceD return nil } -func (r *Reconciler) ensureLighthouseCoreDNSDeployment(instance *submarinerv1alpha1.ServiceDiscovery, reqLogger logr.Logger) error { +func (r *Reconciler) ensureLighthouseCoreDNSDeployment(ctx context.Context, instance *submarinerv1alpha1.ServiceDiscovery, + reqLogger logr.Logger, +) error { lighthouseCoreDNSDeployment := newLighthouseCoreDNSDeployment(instance) - if _, err := apply.Deployment(instance, lighthouseCoreDNSDeployment, reqLogger, + if _, err := apply.Deployment(ctx, instance, lighthouseCoreDNSDeployment, reqLogger, r.ScopedClient, r.Scheme); err != nil { log.Error(err, "Error creating the lighthouseCoreDNS deployment") return errors.Wrap(err, "error reconciling coredns deployment") } - err := metrics.Setup(names.LighthouseCoreDNSComponent, instance.Namespace, "app", names.LighthouseCoreDNSComponent, instance, + err := metrics.Setup(ctx, names.LighthouseCoreDNSComponent, instance.Namespace, "app", names.LighthouseCoreDNSComponent, instance, 9153, r.ScopedClient, r.RestConfig, r.Scheme, reqLogger) if err != nil { return errors.Wrap(err, "error setting up coredns metrics") @@ -727,7 +730,7 @@ func (r *Reconciler) ensureLighthouseCoreDNSService(ctx context.Context, instanc lighthouseCoreDNSService) if apierrors.IsNotFound(err) { lighthouseCoreDNSService = newLighthouseCoreDNSService(instance) - if _, err = apply.Service(instance, lighthouseCoreDNSService, reqLogger, + if _, err = apply.Service(ctx, instance, lighthouseCoreDNSService, reqLogger, r.ScopedClient, r.Scheme); err != nil { log.Error(err, "Error creating the lighthouseCoreDNS service") diff --git a/controllers/submariner/broker_controller.go b/controllers/submariner/broker_controller.go index b75037676..0dc05df70 100644 --- a/controllers/submariner/broker_controller.go +++ b/controllers/submariner/broker_controller.go @@ -70,24 +70,24 @@ func (r *BrokerReconciler) Reconcile(ctx context.Context, request ctrl.Request) // Broker CRDs crdUpdater := crd.UpdaterFromControllerClient(r.Client) - err = gateway.Ensure(crdUpdater) + err = gateway.Ensure(ctx, crdUpdater) if err != nil { return ctrl.Result{}, err //nolint:wrapcheck // Errors are already wrapped } // Lighthouse CRDs - _, err = lighthouse.Ensure(crdUpdater, lighthouse.BrokerCluster) + _, err = lighthouse.Ensure(ctx, crdUpdater, lighthouse.BrokerCluster) if err != nil { return ctrl.Result{}, err //nolint:wrapcheck // Errors are already wrapped } // Globalnet - err = globalnet.ValidateExistingGlobalNetworks(r.Client, request.Namespace) + err = globalnet.ValidateExistingGlobalNetworks(ctx, r.Client, request.Namespace) if err != nil { return ctrl.Result{}, err //nolint:wrapcheck // Errors are already wrapped } - err = globalnet.CreateConfigMap(r.Client, instance.Spec.GlobalnetEnabled, instance.Spec.GlobalnetCIDRRange, + err = globalnet.CreateConfigMap(ctx, r.Client, instance.Spec.GlobalnetEnabled, instance.Spec.GlobalnetCIDRRange, instance.Spec.DefaultGlobalnetClusterSize, request.Namespace) if err != nil { return ctrl.Result{}, err //nolint:wrapcheck // Errors are already wrapped diff --git a/controllers/submariner/cleanup.go b/controllers/submariner/cleanup.go index 1e35867cb..7f8c9c787 100644 --- a/controllers/submariner/cleanup.go +++ b/controllers/submariner/cleanup.go @@ -47,7 +47,7 @@ func (r *Reconciler) runComponentCleanup(ctx context.Context, instance *operator } // This has the side effect of setting the CIDRs in the Submariner instance. - clusterNetwork, err := r.discoverNetwork(instance, log) + clusterNetwork, err := r.discoverNetwork(ctx, instance, log) if err != nil { return reconcile.Result{}, err } diff --git a/controllers/submariner/gateway_resources.go b/controllers/submariner/gateway_resources.go index 11e5d99ac..88bb745a3 100644 --- a/controllers/submariner/gateway_resources.go +++ b/controllers/submariner/gateway_resources.go @@ -247,16 +247,16 @@ func newGatewayPodTemplate(cr *v1alpha1.Submariner, name string, podSelectorLabe //nolint:wrapcheck // No need to wrap errors here. func (r *Reconciler) reconcileGatewayDaemonSet( - instance *v1alpha1.Submariner, reqLogger logr.Logger, + ctx context.Context, instance *v1alpha1.Submariner, reqLogger logr.Logger, ) (*appsv1.DaemonSet, error) { - daemonSet, err := apply.DaemonSet(instance, newGatewayDaemonSet(instance, names.GatewayComponent), + daemonSet, err := apply.DaemonSet(ctx, instance, newGatewayDaemonSet(instance, names.GatewayComponent), reqLogger, r.config.ScopedClient, r.config.Scheme) if err != nil { return nil, err } - err = metrics.Setup(names.GatewayComponent, instance.Namespace, "app", names.MetricsProxyComponent, instance, gatewayMetricsServicePort, - r.config.ScopedClient, r.config.RestConfig, r.config.Scheme, reqLogger) + err = metrics.Setup(ctx, names.GatewayComponent, instance.Namespace, "app", names.MetricsProxyComponent, instance, + gatewayMetricsServicePort, r.config.ScopedClient, r.config.RestConfig, r.config.Scheme, reqLogger) return daemonSet, err } diff --git a/controllers/submariner/globalnet_resources.go b/controllers/submariner/globalnet_resources.go index d4460b21b..40b735199 100644 --- a/controllers/submariner/globalnet_resources.go +++ b/controllers/submariner/globalnet_resources.go @@ -19,6 +19,8 @@ limitations under the License. package submariner import ( + "context" + "github.com/go-logr/logr" "github.com/submariner-io/submariner-operator/api/v1alpha1" "github.com/submariner-io/submariner-operator/controllers/apply" @@ -32,16 +34,15 @@ import ( ) //nolint:wrapcheck // No need to wrap errors here. -func (r *Reconciler) reconcileGlobalnetDaemonSet(instance *v1alpha1.Submariner, reqLogger logr.Logger) (*appsv1.DaemonSet, - error, -) { - daemonSet, err := apply.DaemonSet(instance, newGlobalnetDaemonSet(instance, names.GlobalnetComponent), reqLogger, +func (r *Reconciler) reconcileGlobalnetDaemonSet(ctx context.Context, instance *v1alpha1.Submariner, reqLogger logr.Logger, +) (*appsv1.DaemonSet, error) { + daemonSet, err := apply.DaemonSet(ctx, instance, newGlobalnetDaemonSet(instance, names.GlobalnetComponent), reqLogger, r.config.ScopedClient, r.config.Scheme) if err != nil { return nil, err } - err = metrics.Setup(names.GlobalnetComponent, instance.Namespace, "app", names.MetricsProxyComponent, + err = metrics.Setup(ctx, names.GlobalnetComponent, instance.Namespace, "app", names.MetricsProxyComponent, instance, globalnetMetricsServicePort, r.config.ScopedClient, r.config.RestConfig, r.config.Scheme, reqLogger) return daemonSet, err diff --git a/controllers/submariner/loadbalancer_resources.go b/controllers/submariner/loadbalancer_resources.go index 2bf845515..8f02d61b5 100644 --- a/controllers/submariner/loadbalancer_resources.go +++ b/controllers/submariner/loadbalancer_resources.go @@ -19,6 +19,8 @@ limitations under the License. package submariner import ( + "context" + "github.com/go-logr/logr" "github.com/submariner-io/submariner-operator/api/v1alpha1" "github.com/submariner-io/submariner-operator/controllers/apply" @@ -39,9 +41,9 @@ const ( //nolint:wrapcheck // No need to wrap errors here. func (r *Reconciler) reconcileLoadBalancer( - instance *v1alpha1.Submariner, reqLogger logr.Logger, + ctx context.Context, instance *v1alpha1.Submariner, reqLogger logr.Logger, ) (*corev1.Service, error) { - return apply.Service(instance, newLoadBalancerService(instance), reqLogger, r.config.ScopedClient, r.config.Scheme) + return apply.Service(ctx, instance, newLoadBalancerService(instance), reqLogger, r.config.ScopedClient, r.config.Scheme) } func newLoadBalancerService(instance *v1alpha1.Submariner) *corev1.Service { diff --git a/controllers/submariner/metrics_proxy_resources.go b/controllers/submariner/metrics_proxy_resources.go index 5f328e806..22b633fbe 100644 --- a/controllers/submariner/metrics_proxy_resources.go +++ b/controllers/submariner/metrics_proxy_resources.go @@ -19,6 +19,7 @@ limitations under the License. package submariner import ( + "context" "fmt" "github.com/go-logr/logr" @@ -32,10 +33,9 @@ import ( ) //nolint:wrapcheck // No need to wrap errors here. -func (r *Reconciler) reconcileMetricsProxyDaemonSet(instance *v1alpha1.Submariner, reqLogger logr.Logger) (*appsv1.DaemonSet, - error, -) { - return apply.DaemonSet(instance, newMetricsProxyDaemonSet(instance), reqLogger, +func (r *Reconciler) reconcileMetricsProxyDaemonSet(ctx context.Context, instance *v1alpha1.Submariner, reqLogger logr.Logger, +) (*appsv1.DaemonSet, error) { + return apply.DaemonSet(ctx, instance, newMetricsProxyDaemonSet(instance), reqLogger, r.config.ScopedClient, r.config.Scheme) } diff --git a/controllers/submariner/np_syncer_resources.go b/controllers/submariner/np_syncer_resources.go index 8a20e0544..2002430b8 100644 --- a/controllers/submariner/np_syncer_resources.go +++ b/controllers/submariner/np_syncer_resources.go @@ -19,6 +19,7 @@ limitations under the License. package submariner import ( + "context" "strconv" "github.com/go-logr/logr" @@ -35,12 +36,12 @@ import ( ) //nolint:wrapcheck // No need to wrap errors here. -func (r *Reconciler) reconcileNetworkPluginSyncerDeployment(instance *v1alpha1.Submariner, +func (r *Reconciler) reconcileNetworkPluginSyncerDeployment(ctx context.Context, instance *v1alpha1.Submariner, clusterNetwork *network.ClusterNetwork, reqLogger logr.Logger, ) error { // Only OVNKubernetes needs networkplugin-syncer so far if needsNetworkPluginSyncer(instance) { - _, err := apply.Deployment(instance, newNetworkPluginSyncerDeployment(instance, + _, err := apply.Deployment(ctx, instance, newNetworkPluginSyncerDeployment(instance, clusterNetwork, names.NetworkPluginSyncerComponent), reqLogger, r.config.ScopedClient, r.config.Scheme) return err } diff --git a/controllers/submariner/route_agent_resources.go b/controllers/submariner/route_agent_resources.go index e536df118..fe6f50df7 100644 --- a/controllers/submariner/route_agent_resources.go +++ b/controllers/submariner/route_agent_resources.go @@ -19,6 +19,7 @@ limitations under the License. package submariner import ( + "context" "strconv" "github.com/go-logr/logr" @@ -36,10 +37,9 @@ import ( var hostPathFileOrCreate = corev1.HostPathFileOrCreate //nolint:wrapcheck // No need to wrap errors here. -func (r *Reconciler) reconcileRouteagentDaemonSet(instance *v1alpha1.Submariner, reqLogger logr.Logger) (*appsv1.DaemonSet, - error, -) { - return apply.DaemonSet(instance, newRouteAgentDaemonSet(instance, names.RouteAgentComponent), reqLogger, r.config.ScopedClient, +func (r *Reconciler) reconcileRouteagentDaemonSet(ctx context.Context, instance *v1alpha1.Submariner, reqLogger logr.Logger, +) (*appsv1.DaemonSet, error) { + return apply.DaemonSet(ctx, instance, newRouteAgentDaemonSet(instance, names.RouteAgentComponent), reqLogger, r.config.ScopedClient, r.config.Scheme) } diff --git a/controllers/submariner/submariner_controller.go b/controllers/submariner/submariner_controller.go index 3623b9251..05ffd1142 100644 --- a/controllers/submariner/submariner_controller.go +++ b/controllers/submariner/submariner_controller.go @@ -118,6 +118,7 @@ func NewReconciler(config *Config) *Reconciler { // +kubebuilder:rbac:groups=submariner.io,resources=submariners,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=submariner.io,resources=submariners/status,verbs=get;update;patch +// //nolint:gocyclo // Refactoring would yield functions with a lot of params which isn't ideal either. func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { reqLogger := log.V(2).WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name) @@ -154,25 +155,25 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( initialStatus := instance.Status.DeepCopy() - clusterNetwork, err := r.discoverNetwork(instance, reqLogger) + clusterNetwork, err := r.discoverNetwork(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } - gatewayDaemonSet, err := r.reconcileGatewayDaemonSet(instance, reqLogger) + gatewayDaemonSet, err := r.reconcileGatewayDaemonSet(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } var loadBalancer *corev1.Service if instance.Spec.LoadBalancerEnabled { - loadBalancer, err = r.reconcileLoadBalancer(instance, reqLogger) + loadBalancer, err = r.reconcileLoadBalancer(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } } - routeagentDaemonSet, err := r.reconcileRouteagentDaemonSet(instance, reqLogger) + routeagentDaemonSet, err := r.reconcileRouteagentDaemonSet(ctx, instance, reqLogger) if err != nil { return reconcile.Result{}, err } @@ -180,16 +181,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( var globalnetDaemonSet *appsv1.DaemonSet if instance.Spec.GlobalCIDR != "" { - if globalnetDaemonSet, err = r.reconcileGlobalnetDaemonSet(instance, reqLogger); err != nil { + if globalnetDaemonSet, err = r.reconcileGlobalnetDaemonSet(ctx, instance, reqLogger); err != nil { return reconcile.Result{}, err } } - if _, err = r.reconcileMetricsProxyDaemonSet(instance, reqLogger); err != nil { + if _, err = r.reconcileMetricsProxyDaemonSet(ctx, instance, reqLogger); err != nil { return reconcile.Result{}, err } - if err := r.reconcileNetworkPluginSyncerDeployment(instance, clusterNetwork, reqLogger); err != nil { + if err := r.reconcileNetworkPluginSyncerDeployment(ctx, instance, clusterNetwork, reqLogger); err != nil { return reconcile.Result{}, err } diff --git a/controllers/submariner/submariner_networkdiscovery.go b/controllers/submariner/submariner_networkdiscovery.go index 4ffb46fdf..f9ddb7b49 100644 --- a/controllers/submariner/submariner_networkdiscovery.go +++ b/controllers/submariner/submariner_networkdiscovery.go @@ -19,6 +19,7 @@ limitations under the License. package submariner import ( + "context" "fmt" "github.com/go-logr/logr" @@ -27,7 +28,7 @@ import ( "github.com/submariner-io/submariner-operator/pkg/discovery/network" ) -func (r *Reconciler) getClusterNetwork(submariner *submopv1a1.Submariner) (*network.ClusterNetwork, error) { +func (r *Reconciler) getClusterNetwork(ctx context.Context, submariner *submopv1a1.Submariner) (*network.ClusterNetwork, error) { const UnknownPlugin = "unknown" // If a previously cached discovery exists, use that @@ -35,7 +36,7 @@ func (r *Reconciler) getClusterNetwork(submariner *submopv1a1.Submariner) (*netw return r.config.ClusterNetwork, nil } - clusterNetwork, err := network.Discover(r.config.GeneralClient, submariner.Namespace) + clusterNetwork, err := network.Discover(ctx, r.config.GeneralClient, submariner.Namespace) if err != nil { log.Error(err, "Error trying to discover network") } @@ -53,8 +54,9 @@ func (r *Reconciler) getClusterNetwork(submariner *submopv1a1.Submariner) (*netw return r.config.ClusterNetwork, errors.Wrap(err, "error discovering cluster network") } -func (r *Reconciler) discoverNetwork(submariner *submopv1a1.Submariner, log logr.Logger) (*network.ClusterNetwork, error) { - clusterNetwork, err := r.getClusterNetwork(submariner) +func (r *Reconciler) discoverNetwork(ctx context.Context, submariner *submopv1a1.Submariner, log logr.Logger, +) (*network.ClusterNetwork, error) { + clusterNetwork, err := r.getClusterNetwork(ctx, submariner) submariner.Status.ClusterCIDR = getCIDR( log, "Cluster", diff --git a/main.go b/main.go index c09a049fc..974e7a065 100644 --- a/main.go +++ b/main.go @@ -125,14 +125,14 @@ func main() { log.Info("Creating the Lighthouse CRDs") - if _, err = lighthouse.Ensure(crdUpdater, lighthouse.DataCluster); err != nil { + if _, err = lighthouse.Ensure(ctx, crdUpdater, lighthouse.DataCluster); err != nil { log.Error(err, "") os.Exit(1) } log.Info("Creating the Gateway CRDs") - if err := gateway.Ensure(crdUpdater); err != nil { + if err := gateway.Ensure(ctx, crdUpdater); err != nil { log.Error(err, "") os.Exit(1) } @@ -175,7 +175,7 @@ func main() { log.Error(err, "Error obtaining a Kubernetes client") } - if err := metrics.Setup(name, namespace, "name", name, nil, metricsPort, metricsClient, cfg, scheme, log); err != nil { + if err := metrics.Setup(ctx, name, namespace, "name", name, nil, metricsPort, metricsClient, cfg, scheme, log); err != nil { log.Error(err, "Error setting up metrics services and monitors") } diff --git a/pkg/discovery/globalnet/config_map.go b/pkg/discovery/globalnet/config_map.go index 30ae31ee1..3c85c5613 100644 --- a/pkg/discovery/globalnet/config_map.go +++ b/pkg/discovery/globalnet/config_map.go @@ -46,7 +46,7 @@ type clusterInfo struct { GlobalCidr []string `json:"global_cidr"` } -func CreateConfigMap(client controllerClient.Client, globalnetEnabled bool, defaultGlobalCidrRange string, +func CreateConfigMap(ctx context.Context, client controllerClient.Client, globalnetEnabled bool, defaultGlobalCidrRange string, defaultGlobalClusterSize uint, namespace string, ) error { gnConfigMap, err := NewGlobalnetConfigMap(globalnetEnabled, defaultGlobalCidrRange, defaultGlobalClusterSize, namespace) @@ -54,7 +54,7 @@ func CreateConfigMap(client controllerClient.Client, globalnetEnabled bool, defa return errors.Wrap(err, "error creating config map") } - err = client.Create(context.TODO(), gnConfigMap) + err = client.Create(ctx, gnConfigMap) if err == nil || apierrors.IsAlreadyExists(err) { return nil } @@ -101,7 +101,7 @@ func NewGlobalnetConfigMap(globalnetEnabled bool, defaultGlobalCidrRange string, return cm, nil } -func updateConfigMap(client controllerClient.Client, configMap *corev1.ConfigMap, newCluster clusterInfo, +func updateConfigMap(ctx context.Context, client controllerClient.Client, configMap *corev1.ConfigMap, newCluster clusterInfo, ) error { var existingInfo []clusterInfo @@ -129,20 +129,20 @@ func updateConfigMap(client controllerClient.Client, configMap *corev1.ConfigMap } configMap.Data[clusterInfoKey] = string(data) - err = client.Update(context.TODO(), configMap) + err = client.Update(ctx, configMap) return errors.Wrapf(err, "error updating ConfigMap") } //nolint:wrapcheck // No need to wrap here -func GetConfigMap(client controllerClient.Client, namespace string) (*corev1.ConfigMap, error) { +func GetConfigMap(ctx context.Context, client controllerClient.Client, namespace string) (*corev1.ConfigMap, error) { cm := &corev1.ConfigMap{} - return cm, client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: globalCIDRConfigMapName}, cm) + return cm, client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: globalCIDRConfigMapName}, cm) } //nolint:wrapcheck // No need to wrap here -func DeleteConfigMap(client controllerClient.Client, namespace string) error { - return client.Delete(context.TODO(), &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{ +func DeleteConfigMap(ctx context.Context, client controllerClient.Client, namespace string) error { + return client.Delete(ctx, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{ Name: globalCIDRConfigMapName, Namespace: namespace, }}) diff --git a/pkg/discovery/globalnet/globalnet.go b/pkg/discovery/globalnet/globalnet.go index 620eb8dbf..61a01f97b 100644 --- a/pkg/discovery/globalnet/globalnet.go +++ b/pkg/discovery/globalnet/globalnet.go @@ -19,6 +19,7 @@ limitations under the License. package globalnet import ( + "context" "encoding/binary" "encoding/json" "fmt" @@ -324,8 +325,8 @@ func ValidateGlobalnetConfiguration(globalnetInfo *Info, netconfig Config, statu return globalnetCIDR, nil } -func GetGlobalNetworks(client controllerClient.Client, brokerNamespace string) (*Info, *v1.ConfigMap, error) { - configMap, err := GetConfigMap(client, brokerNamespace) +func GetGlobalNetworks(ctx context.Context, client controllerClient.Client, brokerNamespace string) (*Info, *v1.ConfigMap, error) { + configMap, err := GetConfigMap(ctx, client, brokerNamespace) if err != nil { return nil, nil, errors.Wrap(err, "error retrieving globalnet ConfigMap") } @@ -440,8 +441,8 @@ func IsValidCIDR(cidr string) error { return nil } -func ValidateExistingGlobalNetworks(client controllerClient.Client, namespace string) error { - globalnetInfo, _, err := GetGlobalNetworks(client, namespace) +func ValidateExistingGlobalNetworks(ctx context.Context, client controllerClient.Client, namespace string) error { + globalnetInfo, _, err := GetGlobalNetworks(ctx, client, namespace) if err != nil { if apierrors.IsNotFound(err) { return nil @@ -459,14 +460,14 @@ func ValidateExistingGlobalNetworks(client controllerClient.Client, namespace st return nil } -func AllocateAndUpdateGlobalCIDRConfigMap(brokerAdminClient controllerClient.Client, brokerNamespace string, +func AllocateAndUpdateGlobalCIDRConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string, netconfig *Config, status reporter.Interface, ) error { retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error { status.Start("Retrieving Globalnet information from the Broker") defer status.End() - globalnetInfo, globalnetConfigMap, err := GetGlobalNetworks(brokerAdminClient, brokerNamespace) + globalnetInfo, globalnetConfigMap, err := GetGlobalNetworks(ctx, brokerAdminClient, brokerNamespace) if err != nil { return status.Error(err, "unable to retrieve Globalnet information") } @@ -490,7 +491,7 @@ func AllocateAndUpdateGlobalCIDRConfigMap(brokerAdminClient controllerClient.Cli status.Start("Updating the Globalnet information on the Broker") - err = updateConfigMap(brokerAdminClient, globalnetConfigMap, newClusterInfo) + err = updateConfigMap(ctx, brokerAdminClient, globalnetConfigMap, newClusterInfo) if apierrors.IsConflict(err) { status.Warning("Conflict occurred updating the Globalnet ConfigMap - retrying") } else { diff --git a/pkg/discovery/network/calico.go b/pkg/discovery/network/calico.go index 079be4a91..84340e169 100644 --- a/pkg/discovery/network/calico.go +++ b/pkg/discovery/network/calico.go @@ -33,10 +33,10 @@ func init() { } //nolint:nilnil // Intentional as the purpose is to discover. -func discoverCalicoNetwork(client controllerClient.Client) (*ClusterNetwork, error) { +func discoverCalicoNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { cmList := &corev1.ConfigMapList{} - err := client.List(context.TODO(), cmList, controllerClient.InNamespace(metav1.NamespaceAll)) + err := client.List(ctx, cmList, controllerClient.InNamespace(metav1.NamespaceAll)) if err != nil { return nil, errors.Wrapf(err, "error listing ConfigMaps") } @@ -54,7 +54,7 @@ func discoverCalicoNetwork(client controllerClient.Client) (*ClusterNetwork, err return nil, nil } - clusterNetwork, err := discoverNetwork(client) + clusterNetwork, err := discoverNetwork(ctx, client) if err != nil { return nil, err } diff --git a/pkg/discovery/network/calico_test.go b/pkg/discovery/network/calico_test.go index 239d7b9ff..6c8b87cce 100644 --- a/pkg/discovery/network/calico_test.go +++ b/pkg/discovery/network/calico_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -50,7 +52,7 @@ var _ = Describe("Calico Network", func() { JustBeforeEach(func() { client := fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(initObjs...).Build() - clusterNet, err = network.Discover(client, "") + clusterNet, err = network.Discover(context.TODO(), client, "") }) When("no kube pod information is available", func() { @@ -60,7 +62,7 @@ var _ = Describe("Calico Network", func() { } client := newTestClient(initObjs...) - clusterNet, err = network.Discover(client, "") + clusterNet, err = network.Discover(context.TODO(), client, "") }) It("should return a ClusterNetwork with only service CIDRs", func() { @@ -81,7 +83,7 @@ var _ = Describe("Calico Network", func() { } client := newTestClient(initObjs...) - clusterNet, err = network.Discover(client, "") + clusterNet, err = network.Discover(context.TODO(), client, "") }) It("should return a ClusterNetwork with pod and service CIDRs", func() { Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/discovery/network/canal.go b/pkg/discovery/network/canal.go index 97c441d5f..79b9d68f6 100644 --- a/pkg/discovery/network/canal.go +++ b/pkg/discovery/network/canal.go @@ -35,7 +35,7 @@ func init() { } //nolint:nilnil // Intentional as the purpose is to discover. -func discoverCanalFlannelNetwork(client controllerClient.Client) (*ClusterNetwork, error) { +func discoverCanalFlannelNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { // TODO: this must be smarter, looking for the canal daemonset, with labels k8s-app=canal // and then the reference on the container volumes: // - configMap: @@ -44,7 +44,7 @@ func discoverCanalFlannelNetwork(client controllerClient.Client) (*ClusterNetwor // name: flannel-cfg cm := &corev1.ConfigMap{} - err := client.Get(context.TODO(), types.NamespacedName{Namespace: "kube-system", Name: "canal-config"}, cm) + err := client.Get(ctx, types.NamespacedName{Namespace: "kube-system", Name: "canal-config"}, cm) if err != nil { if apierrors.IsNotFound(err) { return nil, nil @@ -65,7 +65,7 @@ func discoverCanalFlannelNetwork(client controllerClient.Client) (*ClusterNetwor } // Try to detect the service CIDRs using the generic functions - clusterIPRange, err := findClusterIPRange(client) + clusterIPRange, err := findClusterIPRange(ctx, client) if err != nil { return nil, err } diff --git a/pkg/discovery/network/canal_test.go b/pkg/discovery/network/canal_test.go index 90ddee8af..cb4582651 100644 --- a/pkg/discovery/network/canal_test.go +++ b/pkg/discovery/network/canal_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -55,7 +57,7 @@ var _ = Describe("Canal Flannel Network", func() { func testDiscoverCanalFlannelWith(objects ...controllerClient.Object) *network.ClusterNetwork { client := newTestClient(objects...) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).NotTo(HaveOccurred()) return clusterNet @@ -63,7 +65,7 @@ func testDiscoverCanalFlannelWith(objects ...controllerClient.Object) *network.C func testDiscoverWith(objects ...controllerClient.Object) *network.ClusterNetwork { client := newTestClient(objects...) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).NotTo(HaveOccurred()) return clusterNet diff --git a/pkg/discovery/network/flannel.go b/pkg/discovery/network/flannel.go index fc73b9e21..34202e0e9 100644 --- a/pkg/discovery/network/flannel.go +++ b/pkg/discovery/network/flannel.go @@ -32,10 +32,10 @@ import ( ) //nolint:nilnil // Intentional as the purpose is to discover. -func discoverFlannelNetwork(client controllerClient.Client) (*ClusterNetwork, error) { +func discoverFlannelNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { daemonsets := &appsv1.DaemonSetList{} - err := client.List(context.TODO(), daemonsets, controllerClient.InNamespace(metav1.NamespaceSystem)) + err := client.List(ctx, daemonsets, controllerClient.InNamespace(metav1.NamespaceSystem)) if err != nil { return nil, errors.WithMessage(err, "error listing the Daemonsets for flannel discovery") } @@ -69,7 +69,7 @@ func discoverFlannelNetwork(client controllerClient.Client) (*ClusterNetwork, er // look for the configmap details using the configmap name discovered from the daemonset cm := &corev1.ConfigMap{} - err = client.Get(context.TODO(), controllerClient.ObjectKey{ + err = client.Get(ctx, controllerClient.ObjectKey{ Namespace: metav1.NamespaceSystem, Name: flannelConfigMap, }, cm) @@ -92,7 +92,7 @@ func discoverFlannelNetwork(client controllerClient.Client) (*ClusterNetwork, er } // Try to detect the service CIDRs using the generic functions - clusterIPRange, err := findClusterIPRange(client) + clusterIPRange, err := findClusterIPRange(ctx, client) if err != nil { return nil, err } diff --git a/pkg/discovery/network/flannel_test.go b/pkg/discovery/network/flannel_test.go index e0c0433f8..b523c30d3 100644 --- a/pkg/discovery/network/flannel_test.go +++ b/pkg/discovery/network/flannel_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -63,7 +65,7 @@ var _ = Describe("Flannel Network", func() { func testDiscoverFlannelWith(objects ...controllerClient.Object) *network.ClusterNetwork { client := newTestClient(objects...) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).NotTo(HaveOccurred()) return clusterNet diff --git a/pkg/discovery/network/generic.go b/pkg/discovery/network/generic.go index 04df28a3e..05199755a 100644 --- a/pkg/discovery/network/generic.go +++ b/pkg/discovery/network/generic.go @@ -33,8 +33,8 @@ import ( ) //nolint:nilnil // Intentional as the purpose is to discover. -func discoverGenericNetwork(client controllerClient.Client) (*ClusterNetwork, error) { - clusterNetwork, err := discoverNetwork(client) +func discoverGenericNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { + clusterNetwork, err := discoverNetwork(ctx, client) if err != nil { return nil, err } @@ -48,10 +48,10 @@ func discoverGenericNetwork(client controllerClient.Client) (*ClusterNetwork, er } //nolint:nilnil // Intentional as the purpose is to discover. -func discoverNetwork(client controllerClient.Client) (*ClusterNetwork, error) { +func discoverNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { clusterNetwork := &ClusterNetwork{} - podIPRange, err := findPodIPRange(client) + podIPRange, err := findPodIPRange(ctx, client) if err != nil { return nil, err } @@ -60,7 +60,7 @@ func discoverNetwork(client controllerClient.Client) (*ClusterNetwork, error) { clusterNetwork.PodCIDRs = []string{podIPRange} } - clusterIPRange, err := findClusterIPRange(client) + clusterIPRange, err := findClusterIPRange(ctx, client) if err != nil { return nil, err } @@ -76,13 +76,13 @@ func discoverNetwork(client controllerClient.Client) (*ClusterNetwork, error) { return nil, nil } -func findClusterIPRange(client controllerClient.Client) (string, error) { - clusterIPRange, err := findClusterIPRangeFromApiserver(client) +func findClusterIPRange(ctx context.Context, client controllerClient.Client) (string, error) { + clusterIPRange, err := findClusterIPRangeFromApiserver(ctx, client) if err != nil || clusterIPRange != "" { return clusterIPRange, err } - clusterIPRange, err = findClusterIPRangeFromServiceCreation(client) + clusterIPRange, err = findClusterIPRangeFromServiceCreation(ctx, client) if err != nil || clusterIPRange != "" { return clusterIPRange, err } @@ -90,11 +90,11 @@ func findClusterIPRange(client controllerClient.Client) (string, error) { return "", nil } -func findClusterIPRangeFromApiserver(client controllerClient.Client) (string, error) { - return FindPodCommandParameter(client, "component=kube-apiserver", "--service-cluster-ip-range") +func findClusterIPRangeFromApiserver(ctx context.Context, client controllerClient.Client) (string, error) { + return FindPodCommandParameter(ctx, client, "component=kube-apiserver", "--service-cluster-ip-range") } -func findClusterIPRangeFromServiceCreation(client controllerClient.Client) (string, error) { +func findClusterIPRangeFromServiceCreation(ctx context.Context, client controllerClient.Client) (string, error) { ns := os.Getenv("WATCH_NAMESPACE") // WATCH_NAMESPACE env should be set to operator's namespace, if running in operator if ns == "" { @@ -122,7 +122,7 @@ func findClusterIPRangeFromServiceCreation(client controllerClient.Client) (stri } // create service to the namespace - err := client.Create(context.TODO(), invalidSvcSpec) + err := client.Create(ctx, invalidSvcSpec) // creating invalid service didn't fail as expected if err == nil { @@ -152,18 +152,18 @@ func parseServiceCIDRFrom(msg string) (string, error) { return match[1], nil } -func findPodIPRange(client controllerClient.Client) (string, error) { - podIPRange, err := findPodIPRangeKubeController(client) +func findPodIPRange(ctx context.Context, client controllerClient.Client) (string, error) { + podIPRange, err := findPodIPRangeKubeController(ctx, client) if err != nil || podIPRange != "" { return podIPRange, err } - podIPRange, err = findPodIPRangeKubeProxy(client) + podIPRange, err = findPodIPRangeKubeProxy(ctx, client) if err != nil || podIPRange != "" { return podIPRange, err } - podIPRange, err = findPodIPRangeFromNodeSpec(client) + podIPRange, err = findPodIPRangeFromNodeSpec(ctx, client) if err != nil || podIPRange != "" { return podIPRange, err } @@ -171,18 +171,18 @@ func findPodIPRange(client controllerClient.Client) (string, error) { return "", nil } -func findPodIPRangeKubeController(client controllerClient.Client) (string, error) { - return FindPodCommandParameter(client, "component=kube-controller-manager", "--cluster-cidr") +func findPodIPRangeKubeController(ctx context.Context, client controllerClient.Client) (string, error) { + return FindPodCommandParameter(ctx, client, "component=kube-controller-manager", "--cluster-cidr") } -func findPodIPRangeKubeProxy(client controllerClient.Client) (string, error) { - return FindPodCommandParameter(client, "component=kube-proxy", "--cluster-cidr") +func findPodIPRangeKubeProxy(ctx context.Context, client controllerClient.Client) (string, error) { + return FindPodCommandParameter(ctx, client, "component=kube-proxy", "--cluster-cidr") } -func findPodIPRangeFromNodeSpec(client controllerClient.Client) (string, error) { +func findPodIPRangeFromNodeSpec(ctx context.Context, client controllerClient.Client) (string, error) { nodes := &corev1.NodeList{} - err := client.List(context.TODO(), nodes) + err := client.List(ctx, nodes) if err != nil { return "", errors.WithMessagef(err, "error listing nodes") } diff --git a/pkg/discovery/network/generic_test.go b/pkg/discovery/network/generic_test.go index 94a0c67c1..4dacc4110 100644 --- a/pkg/discovery/network/generic_test.go +++ b/pkg/discovery/network/generic_test.go @@ -19,6 +19,7 @@ limitations under the License. package network_test import ( + "context" "fmt" . "github.com/onsi/ginkgo" @@ -267,7 +268,7 @@ var _ = Describe("Generic Network", func() { When("No kube-api pod exists and invalid service creation returns no error", func() { It("Should return error and nil cluster network", func() { client := fakeClient.NewClientBuilder().WithScheme(scheme.Scheme).Build() - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).To(HaveOccurred()) Expect(clusterNet).To(BeNil()) }) @@ -279,7 +280,7 @@ var _ = Describe("Generic Network", func() { client := fake.NewReactingClient(nil).AddReactor(fake.Create, &corev1.Service{}, fake.FailingReaction(fmt.Errorf("%s", testServiceCIDR))) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).To(HaveOccurred()) Expect(clusterNet).To(BeNil()) }) @@ -308,7 +309,7 @@ var _ = Describe("Generic Network", func() { func testDiscoverGenericWith(objects ...controllerClient.Object) *network.ClusterNetwork { client := newTestClient(objects...) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).NotTo(HaveOccurred()) return clusterNet diff --git a/pkg/discovery/network/kindnet.go b/pkg/discovery/network/kindnet.go index 6f9583503..ca32672fb 100644 --- a/pkg/discovery/network/kindnet.go +++ b/pkg/discovery/network/kindnet.go @@ -19,6 +19,8 @@ limitations under the License. package network import ( + "context" + "github.com/submariner-io/submariner/pkg/cni" controllerClient "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -27,8 +29,8 @@ func init() { registerNetworkPluginDiscoveryFunction(discoverKindNetwork) } -func discoverKindNetwork(client controllerClient.Client) (*ClusterNetwork, error) { - kindNetPod, err := FindPod(client, "app=kindnet") +func discoverKindNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { + kindNetPod, err := FindPod(ctx, client, "app=kindnet") if err != nil || kindNetPod == nil { return nil, err @@ -47,7 +49,7 @@ func discoverKindNetwork(client controllerClient.Client) (*ClusterNetwork, error } } - clusterIPRange, err := findClusterIPRange(client) + clusterIPRange, err := findClusterIPRange(ctx, client) if err == nil && clusterIPRange != "" { clusterNetwork.ServiceCIDRs = []string{clusterIPRange} } diff --git a/pkg/discovery/network/network.go b/pkg/discovery/network/network.go index c325111f8..f3d343393 100644 --- a/pkg/discovery/network/network.go +++ b/pkg/discovery/network/network.go @@ -62,15 +62,15 @@ func (cn *ClusterNetwork) IsComplete() bool { return cn != nil && len(cn.ServiceCIDRs) > 0 && len(cn.PodCIDRs) > 0 } -func Discover(client controllerClient.Client, operatorNamespace string) (*ClusterNetwork, error) { - discovery, err := networkPluginsDiscovery(client) +func Discover(ctx context.Context, client controllerClient.Client, operatorNamespace string) (*ClusterNetwork, error) { + discovery, err := networkPluginsDiscovery(ctx, client) if err != nil { return nil, err } if discovery != nil { // TODO: The other branch of this if will not try to find the globalCIDRs - globalCIDR, _ := getGlobalCIDRs(client, operatorNamespace) + globalCIDR, _ := getGlobalCIDRs(ctx, client, operatorNamespace) discovery.GlobalCIDR = globalCIDR if discovery.IsComplete() { @@ -80,7 +80,7 @@ func Discover(client controllerClient.Client, operatorNamespace string) (*Cluste // If the info we got from the non-generic plugins is incomplete // try to complete with the generic discovery mechanisms if len(discovery.ServiceCIDRs) == 0 || len(discovery.PodCIDRs) == 0 { - genericNet, err := discoverGenericNetwork(client) + genericNet, err := discoverGenericNetwork(ctx, client) if err != nil { return nil, err } @@ -100,10 +100,10 @@ func Discover(client controllerClient.Client, operatorNamespace string) (*Cluste } // If nothing specific was discovered, use the generic discovery - return discoverGenericNetwork(client) + return discoverGenericNetwork(ctx, client) } -type pluginDiscoveryFn func(controllerClient.Client) (*ClusterNetwork, error) +type pluginDiscoveryFn func(context.Context, controllerClient.Client) (*ClusterNetwork, error) var discoverFunctions = []pluginDiscoveryFn{} @@ -112,15 +112,15 @@ func registerNetworkPluginDiscoveryFunction(function pluginDiscoveryFn) { } //nolint:nilnil // Intentional as the purpose is to discover. -func networkPluginsDiscovery(client controllerClient.Client) (*ClusterNetwork, error) { +func networkPluginsDiscovery(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { for _, function := range discoverFunctions { - network, err := function(client) + network, err := function(ctx, client) if err != nil || network != nil { return network, err } } - flanelNet, err := discoverFlannelNetwork(client) + flanelNet, err := discoverFlannelNetwork(ctx, client) if err != nil || flanelNet != nil { return flanelNet, err } @@ -128,14 +128,14 @@ func networkPluginsDiscovery(client controllerClient.Client) (*ClusterNetwork, e return nil, nil } -func getGlobalCIDRs(operatorClient controllerClient.Client, operatorNamespace string) (string, error) { +func getGlobalCIDRs(ctx context.Context, operatorClient controllerClient.Client, operatorNamespace string) (string, error) { if operatorClient == nil { return "", nil } existingCfg := v1alpha1.Submariner{} - err := operatorClient.Get(context.TODO(), types.NamespacedName{Namespace: operatorNamespace, Name: names.SubmarinerCrName}, &existingCfg) + err := operatorClient.Get(ctx, types.NamespacedName{Namespace: operatorNamespace, Name: names.SubmarinerCrName}, &existingCfg) if err != nil { return "", errors.Wrap(err, "error retrieving Submariner resource") } diff --git a/pkg/discovery/network/openshift4.go b/pkg/discovery/network/openshift4.go index efca33820..34dd2579e 100644 --- a/pkg/discovery/network/openshift4.go +++ b/pkg/discovery/network/openshift4.go @@ -37,7 +37,7 @@ func init() { } //nolint:nilnil // Intentional as the purpose is to discover. -func discoverOpenShift4Network(client controllerClient.Client) (*ClusterNetwork, error) { +func discoverOpenShift4Network(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { network := &unstructured.Unstructured{} network.SetGroupVersionKind(schema.GroupVersionKind{ Group: "config.openshift.io", @@ -45,7 +45,7 @@ func discoverOpenShift4Network(client controllerClient.Client) (*ClusterNetwork, Version: "v1", }) - err := client.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, network) + err := client.Get(ctx, types.NamespacedName{Name: "cluster"}, network) if err != nil { if apierrors.IsNotFound(err) || meta.IsNoMatchError(err) { return nil, nil diff --git a/pkg/discovery/network/openshift4_test.go b/pkg/discovery/network/openshift4_test.go index 0fa8a62fb..30d41054f 100644 --- a/pkg/discovery/network/openshift4_test.go +++ b/pkg/discovery/network/openshift4_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -61,7 +63,7 @@ func testOS4DiscoveryWith(json []byte) (*network.ClusterNetwork, error) { err := obj.UnmarshalJSON(json) Expect(err).NotTo(HaveOccurred()) - return network.Discover(fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(obj).Build(), "") + return network.Discover(context.TODO(), fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(obj).Build(), "") } func getNetworkJSON() []byte { diff --git a/pkg/discovery/network/ovnkubernetes.go b/pkg/discovery/network/ovnkubernetes.go index a266a7684..e424e7c05 100644 --- a/pkg/discovery/network/ovnkubernetes.go +++ b/pkg/discovery/network/ovnkubernetes.go @@ -41,14 +41,14 @@ func init() { registerNetworkPluginDiscoveryFunction(discoverOvnKubernetesNetwork) } -func discoverOvnKubernetesNetwork(client controllerClient.Client) (*ClusterNetwork, error) { - ovnDBPod, err := FindPod(client, "name=ovnkube-db") +func discoverOvnKubernetesNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { + ovnDBPod, err := FindPod(ctx, client, "name=ovnkube-db") if err != nil || ovnDBPod == nil { return nil, err } - err = client.Get(context.TODO(), types.NamespacedName{Namespace: ovnDBPod.Namespace, Name: ovnKubeService}, &corev1.Service{}) + err = client.Get(ctx, types.NamespacedName{Namespace: ovnDBPod.Namespace, Name: ovnKubeService}, &corev1.Service{}) if err != nil { return nil, fmt.Errorf("error finding %q service in %q namespace", ovnKubeService, ovnDBPod.Namespace) } @@ -76,7 +76,7 @@ func discoverOvnKubernetesNetwork(client controllerClient.Client) (*ClusterNetwo // If the cluster/service CIDRs weren't found we leave it to the generic functions to figure out later ovnConfig := &corev1.ConfigMap{} - err = client.Get(context.TODO(), types.NamespacedName{Namespace: ovnDBPod.Namespace, Name: "ovn-config"}, ovnConfig) + err = client.Get(ctx, types.NamespacedName{Namespace: ovnDBPod.Namespace, Name: "ovn-config"}, ovnConfig) if err == nil { if netCidr, ok := ovnConfig.Data["net_cidr"]; ok { clusterNetwork.PodCIDRs = []string{netCidr} diff --git a/pkg/discovery/network/ovnkubernetes_test.go b/pkg/discovery/network/ovnkubernetes_test.go index ed8b2f855..4864ef9e9 100644 --- a/pkg/discovery/network/ovnkubernetes_test.go +++ b/pkg/discovery/network/ovnkubernetes_test.go @@ -19,6 +19,7 @@ limitations under the License. package network_test import ( + "context" "fmt" . "github.com/onsi/ginkgo" @@ -82,7 +83,7 @@ var _ = Describe("OvnKubernetes Network", func() { func testOvnKubernetesDiscoveryWith(objects ...controllerClient.Object) (*network.ClusterNetwork, error) { client := newTestClient(objects...) - return network.Discover(client, "") + return network.Discover(context.TODO(), client, "") } func ovnFakeConfigMap(namespace, name string) *v1.ConfigMap { diff --git a/pkg/discovery/network/pods.go b/pkg/discovery/network/pods.go index 92f1d3526..dd82e6aaa 100644 --- a/pkg/discovery/network/pods.go +++ b/pkg/discovery/network/pods.go @@ -28,8 +28,8 @@ import ( controllerClient "sigs.k8s.io/controller-runtime/pkg/client" ) -func FindPodCommandParameter(client controllerClient.Client, labelSelector, parameter string) (string, error) { - pod, err := FindPod(client, labelSelector) +func FindPodCommandParameter(ctx context.Context, client controllerClient.Client, labelSelector, parameter string) (string, error) { + pod, err := FindPod(ctx, client, labelSelector) if err != nil || pod == nil { return "", err @@ -55,7 +55,7 @@ func FindPodCommandParameter(client controllerClient.Client, labelSelector, para } //nolint:nilnil // Intentional as the purpose is to find. -func FindPod(client controllerClient.Client, labelSelector string) (*corev1.Pod, error) { +func FindPod(ctx context.Context, client controllerClient.Client, labelSelector string) (*corev1.Pod, error) { selector, err := labels.Parse(labelSelector) if err != nil { return nil, errors.WithMessagef(err, "error parsing label selector %q", labelSelector) @@ -63,7 +63,7 @@ func FindPod(client controllerClient.Client, labelSelector string) (*corev1.Pod, pods := &corev1.PodList{} - err = client.List(context.TODO(), pods, controllerClient.InNamespace(""), controllerClient.MatchingLabelsSelector{Selector: selector}) + err = client.List(ctx, pods, controllerClient.InNamespace(""), controllerClient.MatchingLabelsSelector{Selector: selector}) if err != nil { return nil, errors.WithMessagef(err, "error listing Pods by label selector %q", labelSelector) } diff --git a/pkg/discovery/network/pods_test.go b/pkg/discovery/network/pods_test.go index 4a6d8ec16..b5b680dfa 100644 --- a/pkg/discovery/network/pods_test.go +++ b/pkg/discovery/network/pods_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -47,7 +49,7 @@ var _ = Describe("findPod", func() { When("There are no pods to be found", func() { It("Should return nil", func() { - pod, err := network.FindPod(client, "component=not-to-be-found") + pod, err := network.FindPod(context.TODO(), client, "component=not-to-be-found") Expect(err).NotTo(HaveOccurred()) Expect(pod).To(BeNil()) }) @@ -55,7 +57,7 @@ var _ = Describe("findPod", func() { When("A pod is found", func() { It("Should return the pod", func() { - pod, err := network.FindPod(client, componentLabel(testComponent1)) + pod, err := network.FindPod(context.TODO(), client, componentLabel(testComponent1)) Expect(err).NotTo(HaveOccurred()) Expect(pod.Name).To(Equal(testFirstPod)) }) @@ -63,7 +65,7 @@ var _ = Describe("findPod", func() { When("Multiple pods are found", func() { It("Should return the first pod", func() { - pod, err := network.FindPod(client, componentLabel(testComponent2)) + pod, err := network.FindPod(context.TODO(), client, componentLabel(testComponent2)) Expect(err).NotTo(HaveOccurred()) Expect(pod.Name).To(Equal(testSecondPod)) }) @@ -91,7 +93,7 @@ var _ = Describe("findPodCommandParameter", func() { When("There are no pods to be found", func() { It("Should return empty string", func() { - param, err := network.FindPodCommandParameter(client, componentLabel("not-to-be-found"), testParameter1) + param, err := network.FindPodCommandParameter(context.TODO(), client, componentLabel("not-to-be-found"), testParameter1) Expect(err).ToNot(HaveOccurred()) Expect(param).To(BeEmpty()) }) @@ -99,7 +101,7 @@ var _ = Describe("findPodCommandParameter", func() { When("A pod is found, but does not contain the parameter", func() { It("Should return an empty string", func() { - param, err := network.FindPodCommandParameter(client, componentLabel(testComponent1), "unknown-parameter") + param, err := network.FindPodCommandParameter(context.TODO(), client, componentLabel(testComponent1), "unknown-parameter") Expect(err).ToNot(HaveOccurred()) Expect(param).To(BeEmpty()) }) @@ -107,7 +109,7 @@ var _ = Describe("findPodCommandParameter", func() { When("A pod is found, and contains the parameter", func() { It("Should return the parameter value", func() { - param, err := network.FindPodCommandParameter(client, componentLabel(testComponent2), testParameter1) + param, err := network.FindPodCommandParameter(context.TODO(), client, componentLabel(testComponent2), testParameter1) Expect(err).ToNot(HaveOccurred()) Expect(param).To(Equal(testValue1)) }) @@ -115,7 +117,7 @@ var _ = Describe("findPodCommandParameter", func() { When("A pod is found, and the parameter is wrapped in a sh call", func() { It("Should return the parameter value", func() { - param, err := network.FindPodCommandParameter(client, componentLabel(testComponent3), testParameter1) + param, err := network.FindPodCommandParameter(context.TODO(), client, componentLabel(testComponent3), testParameter1) Expect(err).ToNot(HaveOccurred()) Expect(param).To(Equal(testValue1)) }) diff --git a/pkg/discovery/network/weavenet.go b/pkg/discovery/network/weavenet.go index edb818564..1b0f51284 100644 --- a/pkg/discovery/network/weavenet.go +++ b/pkg/discovery/network/weavenet.go @@ -19,6 +19,8 @@ limitations under the License. package network import ( + "context" + "github.com/submariner-io/submariner/pkg/cni" controllerClient "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -27,8 +29,8 @@ func init() { registerNetworkPluginDiscoveryFunction(discoverWeaveNetwork) } -func discoverWeaveNetwork(client controllerClient.Client) (*ClusterNetwork, error) { - weaveNetPod, err := FindPod(client, "name=weave-net") +func discoverWeaveNetwork(ctx context.Context, client controllerClient.Client) (*ClusterNetwork, error) { + weaveNetPod, err := FindPod(ctx, client, "name=weave-net") if err != nil || weaveNetPod == nil { return nil, err @@ -47,7 +49,7 @@ func discoverWeaveNetwork(client controllerClient.Client) (*ClusterNetwork, erro } } - clusterIPRange, err := findClusterIPRange(client) + clusterIPRange, err := findClusterIPRange(ctx, client) if err == nil && clusterIPRange != "" { clusterNetwork.ServiceCIDRs = []string{clusterIPRange} } diff --git a/pkg/discovery/network/weavenet_test.go b/pkg/discovery/network/weavenet_test.go index c49d32d70..106d8fbc2 100644 --- a/pkg/discovery/network/weavenet_test.go +++ b/pkg/discovery/network/weavenet_test.go @@ -19,6 +19,8 @@ limitations under the License. package network_test import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/submariner-io/submariner-operator/pkg/discovery/network" @@ -71,7 +73,7 @@ var _ = Describe("Weave Network", func() { func testDiscoverNetwork(objects ...controllerClient.Object) *network.ClusterNetwork { client := newTestClient(objects...) - clusterNet, err := network.Discover(client, "") + clusterNet, err := network.Discover(context.TODO(), client, "") Expect(err).NotTo(HaveOccurred()) return clusterNet diff --git a/pkg/gateway/crds.go b/pkg/gateway/crds.go index 40faa0dcc..da2bda8cd 100644 --- a/pkg/gateway/crds.go +++ b/pkg/gateway/crds.go @@ -29,38 +29,38 @@ import ( // Ensure ensures that the required resources are deployed on the target system. // The resources handled here are the gateway CRDs: Cluster and Endpoint. -func Ensure(crdUpdater crd.Updater) error { - _, err := crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), +func Ensure(ctx context.Context, crdUpdater crd.Updater) error { + _, err := crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_clusters_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the Cluster CRD") } - _, err = crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_endpoints_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the Endpoint CRD") } - _, err = crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_gateways_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the Gateway CRD") } - _, err = crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_clusterglobalegressips_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the ClusterGlobalEgressIP CRD") } - _, err = crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_globalegressips_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the GlobalEgressIP CRD") } - _, err = crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_globalingressips_yaml) if err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "error provisioning the GlobalIngressIP CRD") diff --git a/pkg/lighthouse/crds.go b/pkg/lighthouse/crds.go index 50e829540..2b934e36b 100644 --- a/pkg/lighthouse/crds.go +++ b/pkg/lighthouse/crds.go @@ -33,8 +33,8 @@ const ( // Ensure ensures that the required resources are deployed on the target system // The resources handled here are the lighthouse CRDs: ServiceImport, ServiceExport and ServiceDiscovery. -func Ensure(crdUpdater crd.Updater, isBroker bool) (bool, error) { - installedMCSSI, err := crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), +func Ensure(ctx context.Context, crdUpdater crd.Updater, isBroker bool) (bool, error) { + installedMCSSI, err := crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_mcsapi_crds_multicluster_x_k8s_io_serviceimports_yaml) if err != nil { return installedMCSSI, errors.Wrap(err, "error creating the MCS ServiceImport CRD") @@ -45,13 +45,13 @@ func Ensure(crdUpdater crd.Updater, isBroker bool) (bool, error) { return installedMCSSI, nil } - installedMCSSE, err := crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + installedMCSSE, err := crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_mcsapi_crds_multicluster_x_k8s_io_serviceexports_yaml) if err != nil { return installedMCSSI || installedMCSSE, errors.Wrap(err, "error creating the MCS ServiceExport CRD") } - installedSD, err := crdUpdater.CreateOrUpdateFromEmbedded(context.TODO(), + installedSD, err := crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_crds_submariner_io_servicediscoveries_yaml) if err != nil { return installedMCSSI || installedMCSSE || installedSD, errors.Wrap(err, "error creating the ServiceDiscovery CRD") diff --git a/pkg/metrics/service-monitor.go b/pkg/metrics/service-monitor.go index 3da21da08..bdf7fc708 100644 --- a/pkg/metrics/service-monitor.go +++ b/pkg/metrics/service-monitor.go @@ -44,7 +44,8 @@ type ServiceMonitorUpdater func(*monitoringv1.ServiceMonitor) error // CreateServiceMonitors creates ServiceMonitors objects based on an array of Service objects. // If CR ServiceMonitor is not registered in the Cluster it will not attempt at creating resources. -func CreateServiceMonitors(config *rest.Config, ns string, services []*v1.Service) ([]*monitoringv1.ServiceMonitor, error) { +func CreateServiceMonitors(ctx context.Context, config *rest.Config, ns string, services []*v1.Service, +) ([]*monitoringv1.ServiceMonitor, error) { // check if we can even create ServiceMonitors exists, err := hasServiceMonitor(config) if err != nil { @@ -63,7 +64,7 @@ func CreateServiceMonitors(config *rest.Config, ns string, services []*v1.Servic return nil, errors.Wrap(err, "error getting kube client") } - if _, err := cs.CoreV1().Namespaces().Get(context.TODO(), openshiftMonitoringNS, metav1.GetOptions{}); err == nil { + if _, err := cs.CoreV1().Namespaces().Get(ctx, openshiftMonitoringNS, metav1.GetOptions{}); err == nil { ns = openshiftMonitoringNS } else if !apierrors.IsNotFound(err) { log.Error(err, "Error checking for the OpenShift monitoring namespace") @@ -79,7 +80,7 @@ func CreateServiceMonitors(config *rest.Config, ns string, services []*v1.Servic sm := GenerateServiceMonitor(ns, s) - smc, err := mclient.ServiceMonitors(ns).Create(context.TODO(), sm, metav1.CreateOptions{}) + smc, err := mclient.ServiceMonitors(ns).Create(ctx, sm, metav1.CreateOptions{}) if err != nil { return nil, errors.Wrap(err, "error creating ServiceMonitor") } From 21b9ba7bd0e1cebdb25cb0eaf11647d884df4e6f Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 15 Nov 2022 15:44:01 +0100 Subject: [PATCH 6/6] Apply Go 1.19-compliant gofumpt Signed-off-by: Stephen Kitt --- api/v1alpha1/groupversion_info.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go index 95e69fa0e..93dfb57d6 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/groupversion_info.go @@ -16,9 +16,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the v1alpha1 API group //+kubebuilder:object:generate=true //+groupName=submariner.io + +// Package v1alpha1 contains API Schema definitions for the v1alpha1 API group package v1alpha1 import (