Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit c24771c

Browse files
committed
Update CI tools versions to work with K8s v24, go 1.18
This commit will: - Update KinD K8s image to v1.24 - Add golangci config file and fix linting - Update CI workflows to enable Docker clean-up step when running locally (self-hosted runners) - Enable GithubActions workflow to pull images from local registry when in private repo - Enable docker image clean-up step in GithubActions workflow. - Adding make image step in go-build workflow.
1 parent 0eb3b72 commit c24771c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1106
-444
lines changed

.github/scripts/e2e_get_tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -o errexit
33

44
root="$(dirname "$0")/../../"
5-
VERSION="v0.11.1"
5+
VERSION="v0.14.0"
66
KIND_BINARY_URL="https://github.com/kubernetes-sigs/kind/releases/download/${VERSION}/kind-$(uname)-amd64"
77
K8_STABLE_RELEASE_URL="https://storage.googleapis.com/kubernetes-release/release/stable.txt"
88

.github/scripts/e2e_setup_cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ K8_ADDITIONS_PATH="${root}/.github/scripts/policies"
1212
TMP_DIR="${root}/tmp"
1313
CNIS_DAEMONSET_URL="https://raw.githubusercontent.com/intel/multus-cni/master/e2e/cni-install.yml"
1414
CNIS_NAME="cni-plugins"
15-
# running the latest available image my default, unless instructured to
16-
KIND_IMAGE="kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac"
15+
# running the latest available image my default, unless instructed to
16+
KIND_IMAGE="kindest/node:v1.24.0@sha256:0866296e693efe1fed79d5e6c7af8df71fc73ae45e3679af05342239cdc5bc8e"
1717
[ -n "$1" ] && KIND_IMAGE=$1
1818

1919
# private registry set-up variables

.github/workflows/end-to-end-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
goVersion:
77
required: false
88
type: string
9-
default: 1.17
9+
default: 1.18
1010
kindversion:
1111
required: false
1212
type: string
13-
default: v0.11.1
13+
default: v0.14.0
1414
imagehash:
1515
required: false
1616
type: string
17-
default: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
17+
default: kindest/node:v1.24.0@sha256:0866296e693efe1fed79d5e6c7af8df71fc73ae45e3679af05342239cdc5bc8e
1818
runson:
1919
required: false
2020
type: string

.github/workflows/go-build-and-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
goVersion:
1111
required: false
1212
type: string
13-
default: 1.17
13+
default: 1.18
1414

1515
jobs:
1616
build-test:
@@ -22,7 +22,9 @@ jobs:
2222
with:
2323
go-version: ${{ inputs.goVersion }}
2424
- name: Build
25-
run: make test
26-
- name: Test
2725
run: make build
26+
- name: Image
27+
run: make image
28+
- name: Test
29+
run: make test
2830

.github/workflows/static-analysis.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ on:
2222
goVersion:
2323
required: false
2424
type: string
25-
default: 1.17
25+
default: 1.18
2626
hadolintVersion:
2727
required: false
2828
type: string
29-
default: v2.8.0
29+
default: v2.10.0
3030
goLangCIVersion:
3131
required: false
3232
type: string
33-
default: v1.42.1
33+
default: v1.46.2
3434
goImportsVersion:
3535
required: false
3636
type: string
37-
default: v0.1.9
37+
default: v0.1.10
3838
jobs:
3939
shellcheck:
4040
name: Shellcheck
@@ -96,4 +96,5 @@ jobs:
9696
skip-go-installation: true
9797
working-directory: ${{matrix.workingdir }}
9898
# Additional linting tools can be added here
99-
args: --enable=golint --timeout=5m
99+
args: --timeout=5m -v --color='always'
100+

.github/workflows/workflow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ jobs:
3737
if: ( !contains(github.repository, '/platform-aware-scheduling') && github.event_name == 'pull_request' )
3838
with:
3939
runson: self-hosted-kind
40+
cleanup: true
4041
isLocal: "true"

.golangci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
run:
2+
tests: true
3+
max-issues-per-linter: 0
4+
max-same-issues: 0
5+
6+
linters:
7+
enable-all: true
8+
disable:
9+
- paralleltest
10+
- gomoddirectives
11+
- exhaustivestruct
12+
- exhaustruct
13+
- nonamedreturns
14+
- varnamelen
15+
- gofumpt
16+
- godox
17+
- gci
18+
- gocognit
19+
- unparam
20+
- cyclop
21+
- forcetypeassert
22+
- exhaustive
23+
- testpackage
24+
- thelper
25+
- ireturn
26+
- containedctx
27+
- maintidx
28+
- typecheck
29+
- gochecknoglobals
30+
31+
linters-settings:
32+
gofmt:
33+
simplify: true
34+
gofumpt:
35+
lang-version: "1.17"
36+
golint:
37+
min-confidence: 0.9
38+
govet:
39+
check-shadowing: true
40+
# enable:
41+
# - "fieldalignment"
42+
gocyclo:
43+
min-complexity: 18
44+
gocognit:
45+
min-complexity: 31
46+
funlen:
47+
lines: 70
48+
cyclop:
49+
max-complexity: 12
50+
lll:
51+
line-length: 160
52+
nestif:
53+
min-complexity: 7
54+
55+
issues:
56+
exclude-rules:
57+
- path: _test\.go
58+
linters:
59+
# Until the testing package allows pinning variables disable scopelint
60+
# for tests. See https://github.com/kyoh86/scopelint/issues/4.
61+
- scopelint
62+
- funlen
63+
- goimports
64+
- gofmt
65+

extender/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package extender
22

33
import (
4+
"fmt"
45
"log"
56

67
"k8s.io/client-go/kubernetes"
@@ -13,14 +14,17 @@ func GetKubeClient(kubeConfig string) (kubernetes.Interface, *rest.Config, error
1314
clientConfig, err := rest.InClusterConfig()
1415
if err != nil {
1516
log.Print("not in cluster - trying file-based configuration")
17+
1618
clientConfig, err = clientcmd.BuildConfigFromFlags("", kubeConfig)
1719
if err != nil {
18-
return nil, nil, err
20+
return nil, nil, fmt.Errorf("failed to get clientconfig: %w", err)
1921
}
2022
}
23+
2124
kubeClient, err := kubernetes.NewForConfig(clientConfig)
2225
if err != nil {
23-
return nil, nil, err
26+
return nil, nil, fmt.Errorf("failed to get kubeclient: %w", err)
2427
}
28+
2529
return kubeClient, clientConfig, nil
2630
}

extender/scheduler.go

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ import (
1111
"k8s.io/klog/v2"
1212
)
1313

14+
const (
15+
l2 = 2
16+
readTimeout = 5
17+
writeTimeout = 10
18+
maxHeader = 1000
19+
)
20+
1421
// postOnly check if the method type is POST.
1522
func postOnly(next http.HandlerFunc) http.HandlerFunc {
1623
return func(w http.ResponseWriter, r *http.Request) {
1724
if r.Method != http.MethodPost {
1825
w.WriteHeader(http.StatusMethodNotAllowed)
19-
klog.V(2).InfoS("method Type not POST", "component", "extender")
26+
klog.V(l2).InfoS("method Type not POST", "component", "extender")
27+
2028
return
2129
}
2230

@@ -29,7 +37,8 @@ func contentLength(next http.HandlerFunc) http.HandlerFunc {
2937
return func(w http.ResponseWriter, r *http.Request) {
3038
if r.ContentLength > 1*1000*1000*1000 {
3139
w.WriteHeader(http.StatusInternalServerError)
32-
klog.V(2).InfoS("request size too large", "component", "extender")
40+
klog.V(l2).InfoS("request size too large", "component", "extender")
41+
3342
return
3443
}
3544

@@ -43,7 +52,8 @@ func requestContentType(next http.HandlerFunc) http.HandlerFunc {
4352
requestContentType := r.Header.Get("Content-Type")
4453
if requestContentType != "application/json" {
4554
w.WriteHeader(http.StatusNotFound)
46-
klog.V(2).InfoS("request content type not application/json", "component", "extender")
55+
klog.V(l2).InfoS("request content type not application/json", "component", "extender")
56+
4757
return
4858
}
4959

@@ -76,7 +86,7 @@ func handlerWithMiddleware(handle http.HandlerFunc) http.HandlerFunc {
7686

7787
// error handler deals with requests sent to an invalid endpoint and returns a 404.
7888
func errorHandler(w http.ResponseWriter, r *http.Request) {
79-
klog.V(2).InfoS("Requested resource: '"+r.URL.Path+"' not found", "component", "extender")
89+
klog.V(l2).InfoS("Requested resource: '"+r.URL.Path+"' not found", "component", "extender")
8090
w.Header().Add("Content-Type", "application/json")
8191
w.WriteHeader(http.StatusNotFound)
8292
}
@@ -89,29 +99,34 @@ func (m Server) StartServer(port string, certFile string, keyFile string, caFile
8999
mx.HandleFunc("/scheduler/prioritize", handlerWithMiddleware(m.Prioritize))
90100
mx.HandleFunc("/scheduler/filter", handlerWithMiddleware(m.Filter))
91101
mx.HandleFunc("/scheduler/bind", handlerWithMiddleware(m.Bind))
102+
92103
var err error
104+
93105
if unsafe {
94-
klog.V(2).InfoS("Extender Listening on HTTP "+port, "component", "extender")
106+
klog.V(l2).InfoS("Extender Listening on HTTP "+port, "component", "extender")
107+
95108
err = http.ListenAndServe(":"+port, mx)
96109
if err != nil {
97-
klog.V(2).InfoS("Listening on HTTP failed: "+err.Error(), "component", "extender")
110+
klog.V(l2).InfoS("Listening on HTTP failed: "+err.Error(), "component", "extender")
98111
}
99112
} else {
100113
srv := configureSecureServer(port, caFile)
101114
srv.Handler = mx
102-
klog.V(2).InfoS("Extender Listening on HTTPS "+port, "component", "extender")
115+
klog.V(l2).InfoS("Extender Listening on HTTPS "+port, "component", "extender")
103116

104117
klog.Fatal(srv.ListenAndServeTLS(certFile, keyFile))
105118
}
106-
klog.V(2).InfoS("Scheduler extender server failed to start "+err.Error(), "component", "extender")
119+
120+
klog.V(l2).InfoS("Scheduler extender server failed to start "+err.Error(), "component", "extender")
107121
}
108122

109123
// Configuration values including algorithms etc for the TAS scheduling endpoint.
110124
func configureSecureServer(port string, caFile string) *http.Server {
111125
caCert, err := ioutil.ReadFile(caFile)
112126
if err != nil {
113-
klog.V(2).InfoS("caCert read failed: "+err.Error(), "component", "extender")
127+
klog.V(l2).InfoS("caCert read failed: "+err.Error(), "component", "extender")
114128
}
129+
115130
caCertPool := x509.NewCertPool()
116131
caCertPool.AppendCertsFromPEM(caCert)
117132

@@ -133,11 +148,12 @@ func configureSecureServer(port string, caFile string) *http.Server {
133148
srv := &http.Server{
134149
Addr: ":" + port,
135150
Handler: nil,
136-
ReadHeaderTimeout: 5 * time.Second,
137-
WriteTimeout: 10 * time.Second,
138-
MaxHeaderBytes: 1000,
151+
ReadHeaderTimeout: readTimeout * time.Second,
152+
WriteTimeout: writeTimeout * time.Second,
153+
MaxHeaderBytes: maxHeader,
139154
TLSConfig: cfg,
140155
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
141156
}
157+
142158
return srv
143159
}

extender/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ type FailedNodesMap map[string]string
3939
// Args represents the arguments needed by the extender to Filter/Prioritize
4040
// nodes for a pod.
4141
type Args struct {
42-
// Pod being scheduled
43-
Pod v1.Pod
4442
// List of candidate nodes where the pod can be scheduled; to be populated
4543
// only if ExtenderConfig.NodeCacheCapable == false
4644
Nodes *v1.NodeList
4745
// List of candidate node names where the pod can be scheduled; to be
4846
// populated only if ExtenderConfig.NodeCacheCapable == true
4947
NodeNames *[]string
48+
// Pod being scheduled
49+
Pod v1.Pod
5050
}
5151

5252
// FilterResult stores the result from extender to be sent as response.

0 commit comments

Comments
 (0)