Skip to content

Commit 67aaad5

Browse files
committed
update go version, modules, rand package and slog package
1 parent cae0d3f commit 67aaad5

File tree

11 files changed

+87
-117
lines changed

11 files changed

+87
-117
lines changed

.github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Setup Go
3030
uses: actions/setup-go@v2
3131
with:
32-
go-version: "1.20"
32+
go-version: "1.24.1"
3333

3434
- name: Test
3535
run: go test -v ./...

AUTHORS

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
# some cases, their employer may be the copyright holder. To see the full list
55
# of contributors, see the revision history in source control.
66

7-
Yamato Sugawara <[email protected]>
87
Shuichi Ohkubo <[email protected]>

cmd/db-controller/main.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020
"io"
21+
"log/slog"
2122
"net/http"
2223
"os"
2324
"os/signal"
@@ -35,14 +36,9 @@ import (
3536
"github.com/sakura-internet/distributed-mariadb-controller/pkg/controller"
3637
"github.com/sakura-internet/distributed-mariadb-controller/pkg/nftables"
3738
"github.com/vishvananda/netlink"
38-
39-
"golang.org/x/exp/rand"
40-
"golang.org/x/exp/slog"
4139
)
4240

4341
func main() {
44-
rand.Seed(uint64(time.Now().UnixNano()))
45-
4642
if err := parseAllFlags(os.Args[1:]); err != nil {
4743
panic(err)
4844
}
@@ -255,7 +251,7 @@ func tryToGetTheExclusiveLockWithoutBlocking(path string) (*os.File, error) {
255251

256252
// setupGlobalLogger setups a slog.Logger and sets it as the global logger of the slog packages.
257253
func setupGlobalLogger(w io.Writer, level string) *slog.Logger {
258-
opts := slog.HandlerOptions{
254+
opts := &slog.HandlerOptions{
259255
AddSource: true,
260256
}
261257

@@ -270,7 +266,7 @@ func setupGlobalLogger(w io.Writer, level string) *slog.Logger {
270266
opts.Level = slog.LevelError
271267
}
272268

273-
return slog.New(opts.NewTextHandler(w))
269+
return slog.New(slog.NewTextHandler(w, opts))
274270
}
275271

276272
// readDBReplicaPassword reads the contents from db replica password file.

go.mod

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
module github.com/sakura-internet/distributed-mariadb-controller
22

3-
go 1.20
3+
go 1.24.1
44

55
require (
6-
github.com/labstack/echo/v4 v4.10.2
7-
github.com/labstack/gommon v0.4.0
8-
github.com/prometheus/client_golang v1.15.1
9-
github.com/stretchr/testify v1.8.1
10-
github.com/vishvananda/netlink v1.1.0
11-
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
6+
github.com/labstack/echo/v4 v4.13.3
7+
github.com/labstack/gommon v0.4.2
8+
github.com/prometheus/client_golang v1.21.1
9+
github.com/stretchr/testify v1.10.0
10+
github.com/vishvananda/netlink v1.3.0
1211
)
1312

1413
require (
1514
github.com/beorn7/perks v1.0.1 // indirect
16-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
15+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1716
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
19-
github.com/golang/protobuf v1.5.3 // indirect
17+
github.com/klauspost/compress v1.17.11 // indirect
2018
github.com/kr/text v0.2.0 // indirect
2119
github.com/mattn/go-colorable v0.1.13 // indirect
22-
github.com/mattn/go-isatty v0.0.17 // indirect
23-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
20+
github.com/mattn/go-isatty v0.0.20 // indirect
21+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
2422
github.com/pmezard/go-difflib v1.0.0 // indirect
25-
github.com/prometheus/client_model v0.3.0 // indirect
26-
github.com/prometheus/common v0.42.0 // indirect
27-
github.com/prometheus/procfs v0.9.0 // indirect
28-
github.com/rogpeppe/go-internal v1.10.0 // indirect
23+
github.com/prometheus/client_model v0.6.1 // indirect
24+
github.com/prometheus/common v0.62.0 // indirect
25+
github.com/prometheus/procfs v0.15.1 // indirect
2926
github.com/valyala/bytebufferpool v1.0.0 // indirect
3027
github.com/valyala/fasttemplate v1.2.2 // indirect
31-
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
32-
golang.org/x/crypto v0.6.0 // indirect
33-
golang.org/x/net v0.7.0 // indirect
34-
golang.org/x/sys v0.6.0 // indirect
35-
golang.org/x/text v0.7.0 // indirect
36-
golang.org/x/time v0.3.0 // indirect
37-
google.golang.org/protobuf v1.30.0 // indirect
28+
github.com/vishvananda/netns v0.0.4 // indirect
29+
golang.org/x/crypto v0.31.0 // indirect
30+
golang.org/x/net v0.33.0 // indirect
31+
golang.org/x/sys v0.28.0 // indirect
32+
golang.org/x/text v0.21.0 // indirect
33+
golang.org/x/time v0.8.0 // indirect
34+
google.golang.org/protobuf v1.36.1 // indirect
3835
gopkg.in/yaml.v3 v3.0.1 // indirect
3936
)

go.sum

+46-66
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,71 @@
11
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
22
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
3-
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
4-
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
3+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
4+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
55
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
6-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
76
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
87
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9-
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
10-
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
11-
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
12-
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
13-
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
14-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
15-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
16-
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
17-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
8+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
9+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
10+
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
11+
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
1812
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
13+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1914
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2015
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
21-
github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M=
22-
github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k=
23-
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
24-
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
25-
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
16+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
17+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
18+
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
19+
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
20+
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
21+
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
2622
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
2723
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
28-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
2924
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
30-
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
31-
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
32-
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
33-
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
25+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
26+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
27+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
28+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
3429
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3530
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
36-
github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI=
37-
github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
38-
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
39-
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
40-
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
41-
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
42-
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
43-
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
31+
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
32+
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
33+
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
34+
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
35+
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
36+
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
37+
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
38+
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
4439
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
4540
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
46-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
47-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
48-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
49-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
50-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
51-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
52-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
53-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
41+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
42+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
5443
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
5544
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
56-
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
5745
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
5846
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
59-
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
60-
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
61-
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
62-
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
63-
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
64-
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
65-
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
66-
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
67-
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
68-
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
69-
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
70-
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
71-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
72-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
73-
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
47+
github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk=
48+
github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
49+
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
50+
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
51+
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
52+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
53+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
54+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
7455
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
75-
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
56+
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7657
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
77-
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
78-
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
79-
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
80-
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
81-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
82-
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
83-
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
84-
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
85-
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
58+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
59+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
60+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
61+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
62+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
63+
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
64+
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
65+
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
66+
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
8667
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8768
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
88-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
89-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
69+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
9070
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
9171
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pkg/controller/controller.go

+11-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package controller
1717
import (
1818
"context"
1919
"fmt"
20+
"log/slog"
2021
"math/rand"
2122
"net"
2223
"sync"
@@ -27,7 +28,6 @@ import (
2728
"github.com/sakura-internet/distributed-mariadb-controller/pkg/mariadb"
2829
"github.com/sakura-internet/distributed-mariadb-controller/pkg/nftables"
2930
"github.com/sakura-internet/distributed-mariadb-controller/pkg/systemd"
30-
"golang.org/x/exp/slog"
3131
)
3232

3333
// State specifies the controller state.
@@ -175,7 +175,7 @@ controllerLoop:
175175
time.Sleep(time.Second * time.Duration(rand.Intn(2)+1))
176176

177177
if err := c.preDecideNextStateHandler(); err != nil {
178-
c.logger.Error("preDecideNextStateHandler", err, "state", c.GetState())
178+
c.logger.Error("preDecideNextStateHandler", "error", err, "state", string(c.GetState()))
179179
// we urgently transition to fault state
180180
c.forceTransitionToFault()
181181
continue
@@ -185,7 +185,7 @@ controllerLoop:
185185
c.logger.Debug("controller decided next state", "next state", nextState)
186186

187187
if err := c.onStateHandler(nextState); err != nil {
188-
c.logger.Error("onStateHandler", err, "next state", nextState)
188+
c.logger.Error("onStateHandler", "error", err, "next state", nextState)
189189
}
190190
}
191191
}
@@ -227,7 +227,7 @@ func (c *Controller) decideNextState() State {
227227
func (c *Controller) onExit() error {
228228
c.setState(StateFault)
229229
if err := c.triggerRunOnStateChangesToFault(); err != nil {
230-
c.logger.Info("failed to TriggerRunOnStateChanges while going to fault. Ignore errors.", err)
230+
c.logger.Info("failed to TriggerRunOnStateChanges while going to fault. Ignore errors.", "error", err)
231231
}
232232

233233
return nil
@@ -241,7 +241,7 @@ func (c *Controller) onStateHandler(nextState State) error {
241241

242242
if c.keepStateInPrevTransition() {
243243
if err := c.triggerRunOnStateKeeps(); err != nil {
244-
c.logger.Error("failed to triggerRunOnStateKeeps. transition to fault state and exit", err, "state", string(c.GetState()))
244+
c.logger.Error("failed to triggerRunOnStateKeeps. transition to fault state and exit", "error", err, "state", string(c.GetState()))
245245
c.forceTransitionToFault()
246246
panic("urgently exit")
247247
}
@@ -251,7 +251,7 @@ func (c *Controller) onStateHandler(nextState State) error {
251251

252252
if err := c.triggerRunOnStateChanges(); err != nil {
253253
// we urgently transition to fault state
254-
c.logger.Error("failed to TriggerRunOnStateChanges. transition to fault state.", err, "state", string(c.GetState()))
254+
c.logger.Error("failed to TriggerRunOnStateChanges. transition to fault state.", "error", err, "state", string(c.GetState()))
255255
c.forceTransitionToFault()
256256
}
257257

@@ -268,11 +268,9 @@ func (c *Controller) preDecideNextStateHandler() error {
268268

269269
c.currentNeighbors = c.extractNeighborAddresses(prefixes)
270270
// to avoiding unnecessary calculation, we checks the logger's level.
271-
if c.logger.Enabled(slog.LevelInfo) {
272-
if prevNeighbors.different(c.currentNeighbors) {
273-
addrs := c.currentNeighbors.neighborAddresses()
274-
c.logger.Info("neighbor set is updated", "addresses", addrs)
275-
}
271+
if prevNeighbors.different(c.currentNeighbors) {
272+
addrs := c.currentNeighbors.neighborAddresses()
273+
c.logger.Info("neighbor set is updated", "addresses", addrs)
276274
}
277275

278276
c.currentMariaDBHealth = c.checkMariaDBHealth()
@@ -359,7 +357,7 @@ func (c *Controller) forceTransitionToFault() {
359357

360358
c.setState(StateFault)
361359
if err := c.triggerRunOnStateChanges(); err != nil {
362-
c.logger.Info("failed to TriggerRunOnStateChanges while going to fault. Ignore errors.", err)
360+
c.logger.Info("failed to TriggerRunOnStateChanges while going to fault. Ignore errors.", "error", err)
363361
}
364362
}
365363

@@ -438,7 +436,7 @@ func (c *Controller) collectStateCommunityRoutePrefixes() (map[State][]net.IP, e
438436
// but the net/netip package doesn't have the way to parse CIDR notation.
439437
addr, _, err := net.ParseCIDR(routePrefix)
440438
if err != nil {
441-
c.logger.Error("failed to parse route prefix", err)
439+
c.logger.Error("failed to parse route prefix", "error", err)
442440
}
443441

444442
routes[state] = append(routes[state], addr)

0 commit comments

Comments
 (0)