Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logr with zap throughout #4688

Merged
merged 27 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e8a5acd
feat(logs) use logr throughout
rainest Sep 20, 2023
305e3d7
chore(logs) remove or fix TODOs, add CHANGELOG
rainest Sep 22, 2023
e626ba6
chore(logs) appease linter
rainest Sep 22, 2023
e20d4f8
pr: review comments
rainest Sep 26, 2023
e6f0c63
feat(logs) remove debug-log-reduce-redundancy flag
rainest Sep 26, 2023
dde949c
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Sep 28, 2023
1710097
chore(tests) remove log redundancy from integration
rainest Sep 28, 2023
734102b
chore(*) remove explicit error levels
rainest Sep 28, 2023
43125b1
chore(logs) restore level key
rainest Sep 29, 2023
572c2f4
chore(logs) add dedicated warning field
rainest Sep 29, 2023
0d20809
chore(logs) remove old flag from tests
rainest Sep 29, 2023
2073801
feat(logs) squash log levels
rainest Sep 29, 2023
9967db5
fix(tests) update test after merge
rainest Sep 29, 2023
d449a33
chore: golangci-lint config for github.com/sirupsen/logrus and use za…
pmalek Sep 29, 2023
7c432ca
Merge remote-tracking branch 'origin/main' into HEAD
rainest Sep 29, 2023
d906216
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 2, 2023
9222373
pr: RFC3339 over ISO8601 with millisecond
rainest Oct 9, 2023
11e2514
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 10, 2023
e868bae
chore: make generate
rainest Oct 10, 2023
2791706
pr: warn into errors
rainest Oct 10, 2023
b7acbf6
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 10, 2023
779530e
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 10, 2023
e65ebb4
pr: massage expected log level more
rainest Oct 10, 2023
0e1ec60
pr: print object type in store
rainest Oct 11, 2023
52982c8
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 11, 2023
aaec6d5
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 12, 2023
a7f449d
Merge remote-tracking branch 'origin/main' into feat/zap-revamp
rainest Oct 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ linters-settings:
- k8s.io/utils/pointer:
recommendations:
- github.com/samber/lo
- github.com/sirupsen/logrus:
recommendations:
- go.uber.org/zap
- github.com/bombsimon/logrusr/v4:
recommendations:
- github.com/go-logr/zapr
- github.com/go-logr/logr
tenv:
all: true
loggercheck:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Adding a new version? You'll need three changes:
[#4749](https://github.com/Kong/kubernetes-ingress-controller/pull/4749)
- Removed Knative support.
[#4748](https://github.com/Kong/kubernetes-ingress-controller/pull/4748)
- Removed support for the `debug-log-reduce-redundancy` CLI flag.
[#4688](https://github.com/Kong/kubernetes-ingress-controller/pull/4688)
- The "text" logging format has changed. "json" should be used for
machine-parseable logs.
[#4688](https://github.com/Kong/kubernetes-ingress-controller/pull/4688)
rainest marked this conversation as resolved.
Show resolved Hide resolved
- The "warn", "fatal", and "panic" log levels are no longer available. "error"
is now the highest log level. "warn" logs are now logged at "error" level.
[#4688](https://github.com/Kong/kubernetes-ingress-controller/pull/4688)
- Removed support for deprecated `KongIngress` fields: `Proxy` and `Route`. Respective
`Service` or `Ingress` annotations should be used instead. See [KIC Annotations reference].
[#4760](https://github.com/Kong/kubernetes-ingress-controller/pull/4760)
Expand Down
2 changes: 1 addition & 1 deletion docs/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
| `--konnect-tls-client-key-file` | `string` | Konnect TLS client key file path. | |
| `--kubeconfig` | `string` | Path to the kubeconfig file. | |
| `--log-format` | `string` | Format of logs of the controller. Allowed values are text and json. | `text` |
| `--log-level` | `string` | Level of logging for the controller. Allowed values are trace, debug, info, warn, error, fatal and panic. | `info` |
| `--log-level` | `string` | Level of logging for the controller. Allowed values are trace, debug, info, and error. | `info` |
| `--metrics-bind-address` | `string` | The address the metric endpoint binds to. | `:10255` |
| `--profiling` | `bool` | Enable profiling via web interface host:10256/debug/pprof/. | `false` |
| `--proxy-sync-seconds` | `float32` | Define the rate (in seconds) in which configuration updates will be applied to the Kong Admin API. | `3` |
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/avast/retry-go/v4 v4.5.0
github.com/blang/semver/v4 v4.0.0
github.com/bombsimon/logrusr/v4 v4.0.0
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.4
github.com/goccy/go-json v0.10.2
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
Expand All @@ -44,10 +44,10 @@ require (
github.com/samber/lo v1.38.1
github.com/samber/mo v1.11.0
github.com/sethvargo/go-password v0.2.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
google.golang.org/api v0.146.0
k8s.io/api v0.28.2
k8s.io/apiextensions-apiserver v0.28.2
Expand All @@ -71,7 +71,7 @@ require (
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/puzpuzpuz/xsync/v2 v2.4.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
go.uber.org/zap v1.26.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/net v0.17.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
Expand Down
16 changes: 14 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/avast/retry-go/v4 v4.5.0 h1:QoRAZZ90cj5oni2Lsgl2GW8mNTnUCnmpx/iKpwVisHg=
github.com/avast/retry-go/v4 v4.5.0/go.mod h1:7hLEXp0oku2Nir2xBAsg0PTphp9z71bN5Aq1fboC3+I=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/bombsimon/logrusr/v3 v3.1.0 h1:zORbLM943D+hDMGgyjMhSAz/iDz86ZV72qaak/CA0zQ=
github.com/bombsimon/logrusr/v3 v3.1.0/go.mod h1:PksPPgSFEL2I52pla2glgCyyd2OqOHAnFF5E+g8Ixco=
github.com/bombsimon/logrusr/v4 v4.0.0 h1:Pm0InGphX0wMhPqC02t31onlq9OVyJ98eP/Vh63t1Oo=
github.com/bombsimon/logrusr/v4 v4.0.0/go.mod h1:pjfHC5e59CvjTBIU3V3sGhFWFAnsnhOR03TRc6im0l8=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -418,17 +417,22 @@ github.com/yudai/pp v2.0.2-0.20150410014804-be8315415630+incompatible h1:TmF93o7
github.com/yudai/pp v2.0.2-0.20150410014804-be8315415630+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY=
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand All @@ -444,8 +448,10 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqR
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
Expand All @@ -463,6 +469,7 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
Expand All @@ -476,6 +483,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
Expand All @@ -494,6 +502,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down Expand Up @@ -532,6 +542,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
Expand Down Expand Up @@ -577,6 +588,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
13 changes: 7 additions & 6 deletions hack/cleanup/gke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import (

container "cloud.google.com/go/container/apiv1"
"cloud.google.com/go/container/apiv1/containerpb"
"github.com/go-logr/logr"
"google.golang.org/api/option"

"github.com/kong/kubernetes-ingress-controller/v2/test/e2e"
)

const timeUntilClusterOrphaned = time.Hour

func cleanupGKEClusters(ctx context.Context) error {
func cleanupGKEClusters(ctx context.Context, log logr.Logger) error {
var creds map[string]string
if err := json.Unmarshal([]byte(gkeCreds), &creds); err != nil {
return fmt.Errorf("invalid credentials: %w", err)
Expand All @@ -29,7 +30,7 @@ func cleanupGKEClusters(ctx context.Context) error {
}
defer mgrc.Close()

clusterNames, err := findOrphanedClusters(ctx, mgrc)
clusterNames, err := findOrphanedClusters(ctx, log, mgrc)
if err != nil {
return fmt.Errorf("could not find orphaned clusters: %w", err)
}
Expand All @@ -41,7 +42,7 @@ func cleanupGKEClusters(ctx context.Context) error {

var errs []error
for _, clusterName := range clusterNames {
log.Infof("cleaning up cluster %s\n", clusterName)
log.Info("cleaning up cluster", "name", clusterName)
err := deleteCluster(ctx, mgrc, gkeProject, gkeLocation, clusterName)
if err != nil {
errs = append(errs, err)
Expand Down Expand Up @@ -69,7 +70,7 @@ func deleteCluster(ctx context.Context, mgrc *container.ClusterManagerClient, pr
return nil
}

func findOrphanedClusters(ctx context.Context, mgrc *container.ClusterManagerClient) ([]string, error) {
func findOrphanedClusters(ctx context.Context, log logr.Logger, mgrc *container.ClusterManagerClient) ([]string, error) {
clusterListReq := containerpb.ListClustersRequest{
Parent: fmt.Sprintf("projects/%s/locations/%s", gkeProject, gkeLocation),
}
Expand All @@ -81,7 +82,7 @@ func findOrphanedClusters(ctx context.Context, mgrc *container.ClusterManagerCli
var orphanedClusterNames []string
for _, cluster := range clusterListResp.Clusters {
if !e2e.IsGKETestCluster(cluster) {
log.Infof("non test cluster %s found and skipped (built at %s)\n", cluster.Name, cluster.GetCreateTime())
log.Info("non test cluster found and skipped", "name", cluster.Name, "built_at", cluster.GetCreateTime())
continue
}

Expand All @@ -94,7 +95,7 @@ func findOrphanedClusters(ctx context.Context, mgrc *container.ClusterManagerCli
if time.Now().UTC().After(orphanTime) {
orphanedClusterNames = append(orphanedClusterNames, cluster.Name)
} else {
log.Infof("cluster %s skipped (built in the last %s)\n", cluster.Name, timeUntilClusterOrphaned)
log.Info("cluster skipped", "name", cluster.Name, "build_in_last", timeUntilClusterOrphaned)
}
}

Expand Down
Loading