From 763ffbf0f2bbc7c5818004fe7a9465f9950267fd Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 8 Oct 2023 21:26:09 +0800 Subject: [PATCH] ci: optimize make generate and update to go 1.19 Signed-off-by: Joseph --- docker/koord-descheduler.dockerfile | 2 +- docker/koord-manager.dockerfile | 2 +- docker/koord-runtimeproxy.dockerfile | 2 +- docker/koord-scheduler.dockerfile | 2 +- docker/koordlet.dockerfile | 2 +- go.mod | 2 +- hack/update-codegen.sh | 64 ++++++++++++------- .../clientset/versioned/fake/register.go | 14 ++-- .../clientset/versioned/scheme/register.go | 14 ++-- pkg/descheduler/utils/sorter/helper.go | 7 +- pkg/koordlet/util/cold_page.go | 2 +- pkg/koordlet/util/cold_page_test.go | 2 +- .../util/system/resctrl_linux_test.go | 8 +-- pkg/util/sloconfig/validator.go | 2 +- pkg/util/sloconfig/validator_test.go | 2 +- .../cm/plugins/sloconfig/checkers_test.go | 2 +- .../sloconfig/cpu_burst_checker_test.go | 2 +- .../sloconfig/resource_qos_checker_test.go | 2 +- .../resource_threshold_checker_test.go | 2 +- .../sloconfig/slo_config_plugin_test.go | 2 +- .../sloconfig/system_config_checker_test.go | 2 +- .../cm/validating/validating_handler_test.go | 2 +- .../node/plugins/sloconfig/slo_plugin_test.go | 2 +- .../validating/validating_handler_test.go | 2 +- .../util/writer/atomic/atomic_writer.go | 14 ++-- test/e2e/framework/config/config.go | 36 +++++------ test/e2e/framework/log.go | 8 +-- test/e2e/framework/log_test.go | 7 +- test/e2e/framework/test_context.go | 36 +++++------ test/e2e/framework/util.go | 24 ++++--- test/e2e/generated/bindata.go | 12 ++-- 31 files changed, 157 insertions(+), 125 deletions(-) diff --git a/docker/koord-descheduler.dockerfile b/docker/koord-descheduler.dockerfile index 36b26fb04..fd3cb32b5 100644 --- a/docker/koord-descheduler.dockerfile +++ b/docker/koord-descheduler.dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as builder +FROM golang:1.19 as builder WORKDIR /go/src/github.com/koordinator-sh/koordinator COPY go.mod go.mod diff --git a/docker/koord-manager.dockerfile b/docker/koord-manager.dockerfile index 1db4d784f..964cf8cb2 100644 --- a/docker/koord-manager.dockerfile +++ b/docker/koord-manager.dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as builder +FROM golang:1.19 as builder WORKDIR /go/src/github.com/koordinator-sh/koordinator COPY go.mod go.mod diff --git a/docker/koord-runtimeproxy.dockerfile b/docker/koord-runtimeproxy.dockerfile index 0fe79b583..c337f033c 100644 --- a/docker/koord-runtimeproxy.dockerfile +++ b/docker/koord-runtimeproxy.dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as builder +FROM golang:1.19 as builder WORKDIR /go/src/github.com/koordinator-sh/koordinator COPY go.mod go.mod diff --git a/docker/koord-scheduler.dockerfile b/docker/koord-scheduler.dockerfile index ce6d36507..c3ffacf02 100644 --- a/docker/koord-scheduler.dockerfile +++ b/docker/koord-scheduler.dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as builder +FROM golang:1.19 as builder WORKDIR /go/src/github.com/koordinator-sh/koordinator COPY go.mod go.mod diff --git a/docker/koordlet.dockerfile b/docker/koordlet.dockerfile index 7146f5a3f..6cd454a0e 100644 --- a/docker/koordlet.dockerfile +++ b/docker/koordlet.dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as builder +FROM golang:1.19 as builder WORKDIR /go/src/github.com/koordinator-sh/koordinator COPY go.mod go.mod diff --git a/go.mod b/go.mod index 49cf9304f..90f4d6b87 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/koordinator-sh/koordinator -go 1.18 +go 1.19 require ( github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82 diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index d3ad71b25..b0d63a79c 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -28,6 +28,13 @@ export GOPATH SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. ROOT_PKG=github.com/koordinator-sh/koordinator +if [ ! -d "${SCRIPT_ROOT}/vendor" ]; then + go mod vendor +fi + +GO111MODULE="off" +export GO111MODULE + # code-generator does work with go.mod but makes assumptions about # the project living in `$GOPATH/src`. To work around this and support # any location; create a temporary directory, use this as an output @@ -45,29 +52,40 @@ echo ">> Temporary output directory ${TEMP_DIR}" # --output-base because this script should also be able to run inside the vendor dir of # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir # instead of the $GOPATH directly. For normal projects this can be dropped. -$SCRIPT_ROOT/hack/generate-groups.sh "client,informer,lister" \ - github.com/koordinator-sh/koordinator/pkg/client github.com/koordinator-sh/koordinator/apis \ - "config:v1alpha1 slo:v1alpha1 scheduling:v1alpha1 quota:v1alpha1" \ - --output-base "${TEMP_DIR}" \ - --go-header-file hack/boilerplate/boilerplate.go.txt - -${SCRIPT_ROOT}/hack/generate-internal-groups.sh \ - "deepcopy,conversion,defaulter" \ - github.com/koordinator-sh/koordinator/pkg/scheduler/apis/generated \ - github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ - github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ - "config:v1beta2" \ - --output-base "${TEMP_DIR}" \ - --go-header-file hack/boilerplate/boilerplate.go.txt - -${SCRIPT_ROOT}/hack/generate-internal-groups.sh \ - "deepcopy,conversion,defaulter" \ - github.com/koordinator-sh/koordinator/pkg/descheduler/apis/generated \ - github.com/koordinator-sh/koordinator/pkg/descheduler/apis \ - github.com/koordinator-sh/koordinator/pkg/descheduler/apis \ - "config:v1alpha2" \ - --output-base "${TEMP_DIR}" \ - --go-header-file hack/boilerplate/boilerplate.go.txt + +crdGenerators=("client" "informer" "lister") + +for generator in "${crdGenerators[@]}"; do + $SCRIPT_ROOT/hack/generate-groups.sh "${generator}" \ + github.com/koordinator-sh/koordinator/pkg/client github.com/koordinator-sh/koordinator/apis \ + "config:v1alpha1 slo:v1alpha1 scheduling:v1alpha1 quota:v1alpha1" \ + --output-base "${TEMP_DIR}" \ + --go-header-file hack/boilerplate/boilerplate.go.txt & +done + +configGenerators=("deepcopy" "conversion" "defaulter") + +for generator in "${configGenerators[@]}"; do + ${SCRIPT_ROOT}/hack/generate-internal-groups.sh \ + "${generator}" \ + github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ + github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ + github.com/koordinator-sh/koordinator/pkg/scheduler/apis \ + "config:v1beta2" \ + --output-base "${TEMP_DIR}" \ + --go-header-file hack/boilerplate/boilerplate.go.txt & + + ${SCRIPT_ROOT}/hack/generate-internal-groups.sh \ + "${generator}" \ + github.com/koordinator-sh/koordinator/pkg/descheduler/apis \ + github.com/koordinator-sh/koordinator/pkg/descheduler/apis \ + github.com/koordinator-sh/koordinator/pkg/descheduler/apis \ + "config:v1alpha2" \ + --output-base "${TEMP_DIR}" \ + --go-header-file hack/boilerplate/boilerplate.go.txt & +done + +wait # Copy everything back. cp -a "${TEMP_DIR}/${ROOT_PKG}/." "${SCRIPT_ROOT}/" diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 856389a42..db61b7846 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index d9ff69ce3..38e96211b 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/descheduler/utils/sorter/helper.go b/pkg/descheduler/utils/sorter/helper.go index 75a79e647..b34b3605f 100644 --- a/pkg/descheduler/utils/sorter/helper.go +++ b/pkg/descheduler/utils/sorter/helper.go @@ -24,10 +24,9 @@ import ( // CompareFn compares p1 and p2 and returns: // -// -1 if p1 < p2 -// 0 if p1 == p2 -// +1 if p1 > p2 -// +// -1 if p1 < p2 +// 0 if p1 == p2 +// +1 if p1 > p2 type CompareFn func(p1, p2 *corev1.Pod) int // MultiSorter implements the Sort interface diff --git a/pkg/koordlet/util/cold_page.go b/pkg/koordlet/util/cold_page.go index 6c1854821..3f0f7f2a3 100644 --- a/pkg/koordlet/util/cold_page.go +++ b/pkg/koordlet/util/cold_page.go @@ -5,7 +5,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/koordlet/util/cold_page_test.go b/pkg/koordlet/util/cold_page_test.go index fcd07c547..264cca1c6 100644 --- a/pkg/koordlet/util/cold_page_test.go +++ b/pkg/koordlet/util/cold_page_test.go @@ -5,7 +5,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/koordlet/util/system/resctrl_linux_test.go b/pkg/koordlet/util/system/resctrl_linux_test.go index fca02d298..6294f5587 100644 --- a/pkg/koordlet/util/system/resctrl_linux_test.go +++ b/pkg/koordlet/util/system/resctrl_linux_test.go @@ -36,14 +36,14 @@ func Test_isResctrlAvailableByCpuInfo(t *testing.T) { tests := []args{ { - name: "testResctrlEnable", - cpuInfoContents: "flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities", + name: "testResctrlEnable", + cpuInfoContents: "flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities", expectIsCatFlagSet: true, expectIsMbaFlagSet: true, }, { - name: "testResctrlUnable", - cpuInfoContents: "flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ibrs_enhanced tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm arch_capabilities", + name: "testResctrlUnable", + cpuInfoContents: "flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ibrs_enhanced tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm arch_capabilities", expectIsCatFlagSet: false, expectIsMbaFlagSet: false, }, diff --git a/pkg/util/sloconfig/validator.go b/pkg/util/sloconfig/validator.go index 3083acf76..e35ba0299 100644 --- a/pkg/util/sloconfig/validator.go +++ b/pkg/util/sloconfig/validator.go @@ -5,7 +5,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/util/sloconfig/validator_test.go b/pkg/util/sloconfig/validator_test.go index 1a30e8fb5..e38ce8f29 100644 --- a/pkg/util/sloconfig/validator_test.go +++ b/pkg/util/sloconfig/validator_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/checkers_test.go b/pkg/webhook/cm/plugins/sloconfig/checkers_test.go index 5b97ca659..0d7772799 100644 --- a/pkg/webhook/cm/plugins/sloconfig/checkers_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/checkers_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/cpu_burst_checker_test.go b/pkg/webhook/cm/plugins/sloconfig/cpu_burst_checker_test.go index faf23063e..613372d86 100644 --- a/pkg/webhook/cm/plugins/sloconfig/cpu_burst_checker_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/cpu_burst_checker_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/resource_qos_checker_test.go b/pkg/webhook/cm/plugins/sloconfig/resource_qos_checker_test.go index 6daaffe18..69b0ad3d1 100644 --- a/pkg/webhook/cm/plugins/sloconfig/resource_qos_checker_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/resource_qos_checker_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/resource_threshold_checker_test.go b/pkg/webhook/cm/plugins/sloconfig/resource_threshold_checker_test.go index 6d0a2aab0..4a4e64a41 100644 --- a/pkg/webhook/cm/plugins/sloconfig/resource_threshold_checker_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/resource_threshold_checker_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/slo_config_plugin_test.go b/pkg/webhook/cm/plugins/sloconfig/slo_config_plugin_test.go index 910b26e78..7b5f69ab4 100644 --- a/pkg/webhook/cm/plugins/sloconfig/slo_config_plugin_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/slo_config_plugin_test.go @@ -5,7 +5,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/webhook/cm/plugins/sloconfig/system_config_checker_test.go b/pkg/webhook/cm/plugins/sloconfig/system_config_checker_test.go index 382f81b59..62c277c14 100644 --- a/pkg/webhook/cm/plugins/sloconfig/system_config_checker_test.go +++ b/pkg/webhook/cm/plugins/sloconfig/system_config_checker_test.go @@ -5,7 +5,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/webhook/cm/validating/validating_handler_test.go b/pkg/webhook/cm/validating/validating_handler_test.go index 04d6398df..efaed9581 100644 --- a/pkg/webhook/cm/validating/validating_handler_test.go +++ b/pkg/webhook/cm/validating/validating_handler_test.go @@ -5,7 +5,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/webhook/node/plugins/sloconfig/slo_plugin_test.go b/pkg/webhook/node/plugins/sloconfig/slo_plugin_test.go index 135ae3446..eacedc920 100644 --- a/pkg/webhook/node/plugins/sloconfig/slo_plugin_test.go +++ b/pkg/webhook/node/plugins/sloconfig/slo_plugin_test.go @@ -5,7 +5,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/webhook/node/validating/validating_handler_test.go b/pkg/webhook/node/validating/validating_handler_test.go index 1ef02b81f..3000839a0 100644 --- a/pkg/webhook/node/validating/validating_handler_test.go +++ b/pkg/webhook/node/validating/validating_handler_test.go @@ -5,7 +5,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/webhook/util/writer/atomic/atomic_writer.go b/pkg/webhook/util/writer/atomic/atomic_writer.go index 73928f186..e3add17d8 100644 --- a/pkg/webhook/util/writer/atomic/atomic_writer.go +++ b/pkg/webhook/util/writer/atomic/atomic_writer.go @@ -85,15 +85,18 @@ const ( // The Write algorithm is: // // 1. The payload is validated; if the payload is invalid, the function returns -// 2. The current timestamped directory is detected by reading the data directory +// 2. The current timestamped directory is detected by reading the data directory // symlink +// // 3. The old version of the volume is walked to determine whether any // portion of the payload was deleted and is still present on disk. +// // 4. The data in the current timestamped directory is compared to the projected // data to determine if an update is required. -// 5. A new timestamped dir is created +// 5. A new timestamped dir is created +// // 6. The payload is written to the new timestamped directory -// 7. Symlinks and directory for new user-visible files are created (if needed). +// 7. Symlinks and directory for new user-visible files are created (if needed). // For example, consider the files: // /podName // /user/labels @@ -107,9 +110,10 @@ const ( // The data directory itself is a link to a timestamped directory with // the real data: // /..data -> ..2016_02_01_15_04_05.12345678/ -// 8. A symlink to the new timestamped directory ..data_tmp is created that will +// 8. A symlink to the new timestamped directory ..data_tmp is created that will // become the new data directory -// 9. The new data directory symlink is renamed to the data directory; rename is atomic +// 9. The new data directory symlink is renamed to the data directory; rename is atomic +// // 10. Old paths are removed from the user-visible portion of the target directory // 11. The previous timestamped directory is removed, if it exists func (w *Writer) Write(payload map[string]FileProjection) error { diff --git a/test/e2e/framework/config/config.go b/test/e2e/framework/config/config.go index 841d67d06..907690e94 100644 --- a/test/e2e/framework/config/config.go +++ b/test/e2e/framework/config/config.go @@ -23,13 +23,13 @@ limitations under the License. // The command line flags all get stored in a private flag set. The // developer of the E2E test suite decides how they are exposed. Options // include: -// - exposing as normal flags in the actual command line: -// CopyFlags(Flags, flag.CommandLine) -// - populate via test/e2e/framework/viperconfig: -// viperconfig.ViperizeFlags("my-config.yaml", "", Flags) -// - a combination of both: -// CopyFlags(Flags, flag.CommandLine) -// viperconfig.ViperizeFlags("my-config.yaml", "", flag.CommandLine) +// - exposing as normal flags in the actual command line: +// CopyFlags(Flags, flag.CommandLine) +// - populate via test/e2e/framework/viperconfig: +// viperconfig.ViperizeFlags("my-config.yaml", "", Flags) +// - a combination of both: +// CopyFlags(Flags, flag.CommandLine) +// viperconfig.ViperizeFlags("my-config.yaml", "", flag.CommandLine) // // Instead of defining flags one-by-one, test developers annotate a // structure with tags and then call a single function. This is the @@ -39,16 +39,16 @@ limitations under the License. // // For example, a file storage/csi.go might define: // -// var scaling struct { -// NumNodes int `default:"1" description:"number of nodes to run on"` -// Master string -// } -// _ = config.AddOptions(&scaling, "storage.csi.scaling") +// var scaling struct { +// NumNodes int `default:"1" description:"number of nodes to run on"` +// Master string +// } +// _ = config.AddOptions(&scaling, "storage.csi.scaling") // // This defines the following command line flags: // -// -storage.csi.scaling.numNodes= - number of nodes to run on (default: 1) -// -storage.csi.scaling.master= +// -storage.csi.scaling.numNodes= - number of nodes to run on (default: 1) +// -storage.csi.scaling.master= // // All fields in the structure must be exported and have one of the following // types (same as in the `flag` package): @@ -64,10 +64,10 @@ limitations under the License. // // Each basic entry may have a tag with these optional keys: // -// usage: additional explanation of the option -// default: the default value, in the same format as it would -// be given on the command line and true/false for -// a boolean +// usage: additional explanation of the option +// default: the default value, in the same format as it would +// be given on the command line and true/false for +// a boolean // // The names of the final configuration options are a combination of an // optional common prefix for all options in the structure and the diff --git a/test/e2e/framework/log.go b/test/e2e/framework/log.go index 7033ee62c..0d7f6a8cf 100644 --- a/test/e2e/framework/log.go +++ b/test/e2e/framework/log.go @@ -72,10 +72,10 @@ var codeFilterRE = regexp.MustCompile(`/github.com/onsi/ginkgo/`) // entries coming from Ginkgo. // // This is a modified copy of PruneStack in https://github.com/onsi/ginkgo/blob/f90f37d87fa6b1dd9625e2b1e83c23ffae3de228/internal/codelocation/code_location.go#L25: -// - simplified API and thus renamed (calls debug.Stack() instead of taking a parameter) -// - source code filtering updated to be specific to Kubernetes -// - optimized to use bytes and in-place slice filtering from -// https://github.com/golang/go/wiki/SliceTricks#filter-in-place +// - simplified API and thus renamed (calls debug.Stack() instead of taking a parameter) +// - source code filtering updated to be specific to Kubernetes +// - optimized to use bytes and in-place slice filtering from +// https://github.com/golang/go/wiki/SliceTricks#filter-in-place func PrunedStack(skip int) []byte { fullStackTrace := debug.Stack() stack := bytes.Split(fullStackTrace, []byte("\n")) diff --git a/test/e2e/framework/log_test.go b/test/e2e/framework/log_test.go index 25b41fa99..d084efb20 100644 --- a/test/e2e/framework/log_test.go +++ b/test/e2e/framework/log_test.go @@ -183,10 +183,15 @@ var functionArgs = regexp.MustCompile(`([[:alpha:]]+)\(.*\)`) // testFailureOutput matches TestFailureOutput() and its source followed by additional stack entries: // // github.com/koordinator-sh/koordinator/test/e2e/framework_test.TestFailureOutput(0xc000558800) +// // /nvme/gopath/src/github.com/koordinator-sh/koordinator/test/e2e/framework/log/log_test.go:73 +0x1c9 +// // testing.tRunner(0xc000558800, 0x1af2848) -// /nvme/gopath/go/src/testing/testing.go:865 +0xc0 +// +// /nvme/gopath/go/src/testing/testing.go:865 +0xc0 +// // created by testing.(*T).Run +// // /nvme/gopath/go/src/testing/testing.go:916 +0x35a var testFailureOutput = regexp.MustCompile(`(?m)^github.com/koordinator-sh/koordinator/test/e2e/framework_test\.TestFailureOutput\(.*\n\t.*(\n.*\n\t.*)*`) diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 4d5cce4cb..6fc4b5696 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -53,24 +53,24 @@ const ( // into the code which uses the settings. // // The recommendation for those settings is: -// - They are stored in their own context structure or local -// variables. -// - The standard `flag` package is used to register them. -// The flag name should follow the pattern ..... -// where the prefix is unlikely to conflict with other tests or -// standard packages and each part is in lower camel case. For -// example, test/e2e/storage/csi/context.go could define -// storage.csi.numIterations. -// - framework/config can be used to simplify the registration of -// multiple options with a single function call: -// var storageCSI { -// NumIterations `default:"1" usage:"number of iterations"` -// } -// _ config.AddOptions(&storageCSI, "storage.csi") -// - The direct use Viper in tests is possible, but discouraged because -// it only works in test suites which use Viper (which is not -// required) and the supported options cannot be -// discovered by a test suite user. +// - They are stored in their own context structure or local +// variables. +// - The standard `flag` package is used to register them. +// The flag name should follow the pattern ..... +// where the prefix is unlikely to conflict with other tests or +// standard packages and each part is in lower camel case. For +// example, test/e2e/storage/csi/context.go could define +// storage.csi.numIterations. +// - framework/config can be used to simplify the registration of +// multiple options with a single function call: +// var storageCSI { +// NumIterations `default:"1" usage:"number of iterations"` +// } +// _ config.AddOptions(&storageCSI, "storage.csi") +// - The direct use Viper in tests is possible, but discouraged because +// it only works in test suites which use Viper (which is not +// required) and the supported options cannot be +// discovered by a test suite user. // // Test suite authors can use framework/viper to make all command line // parameters also configurable via a configuration file. diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 38268f548..f44a398bf 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -1345,18 +1345,22 @@ func taintExists(taints []v1.Taint, taintToFind *v1.Taint) bool { // WatchEventSequenceVerifier ... // manages a watch for a given resource, ensures that events take place in a given order, retries the test on failure -// testContext cancelation signal across API boundries, e.g: context.TODO() -// dc sets up a client to the API -// resourceType specify the type of resource -// namespace select a namespace -// resourceName the name of the given resource -// listOptions options used to find the resource, recommended to use listOptions.labelSelector -// expectedWatchEvents array of events which are expected to occur -// scenario the test itself -// retryCleanup a function to run which ensures that there are no dangling resources upon test failure +// +// testContext cancelation signal across API boundries, e.g: context.TODO() +// dc sets up a client to the API +// resourceType specify the type of resource +// namespace select a namespace +// resourceName the name of the given resource +// listOptions options used to find the resource, recommended to use listOptions.labelSelector +// expectedWatchEvents array of events which are expected to occur +// scenario the test itself +// retryCleanup a function to run which ensures that there are no dangling resources upon test failure +// // this tooling relies on the test to return the events as they occur // the entire scenario must be run to ensure that the desired watch events arrive in order (allowing for interweaving of watch events) -// if an expected watch event is missing we elect to clean up and run the entire scenario again +// +// if an expected watch event is missing we elect to clean up and run the entire scenario again +// // we try the scenario three times to allow the sequencing to fail a couple of times func WatchEventSequenceVerifier(ctx context.Context, dc dynamic.Interface, resourceType schema.GroupVersionResource, namespace string, resourceName string, listOptions metav1.ListOptions, expectedWatchEvents []watch.Event, scenario func(*watchtools.RetryWatcher) []watch.Event, retryCleanup func() error) { listWatcher := &cache.ListWatch{ diff --git a/test/e2e/generated/bindata.go b/test/e2e/generated/bindata.go index abd23f2d9..33934f512 100644 --- a/test/e2e/generated/bindata.go +++ b/test/e2e/generated/bindata.go @@ -8604,11 +8604,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error