Skip to content

Commit dc10936

Browse files
committed
wip
1 parent c574854 commit dc10936

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

controllers/serviceaccount_controller.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,17 @@ func (r *GrafanaServiceAccountReconciler) removeAccount(
280280
WithServiceAccountID(status.ServiceAccountID),
281281
)
282282
if err != nil {
283-
// TODO at the moment, Grafana API doesn't return a specific error for not found service accounts.
284-
// So, we cannot distinguish between a not found service account and an error.
285-
// To fix this, we need:
286-
// 1. Grafana API to return a specific error for not found service accounts.
287-
// https://github.com/grafana/grafana/pull/106618
288-
// 2. Grafana OpenAPI client to handle this error properly.
289-
// TBD
290-
// For now, we just assume that the service account was removed successfully if the error is not nil.
291-
// But, let's still log it.
292-
293-
logf.FromContext(ctx).Error(err, "failed to delete service account",
294-
"serviceAccountID", status.ServiceAccountID,
295-
"specID", status.SpecID,
296-
)
297-
// return fmt.Errorf("deleting service account %q: %w", status.SpecID, err)
283+
// ATM, service_accounts.DeleteServiceAccountNotFound doesn't have Is, Unwrap, Unwrap.
284+
// So, we cannot rely only on errors.Is().
285+
_, ok := err.(*service_accounts.DeleteServiceAccountNotFound) // nolint:errorlint
286+
if ok || errors.Is(err, service_accounts.NewDeleteServiceAccountNotFound()) {
287+
logf.FromContext(ctx).Info("service account not found, skipping removal",
288+
"serviceAccountID", status.ServiceAccountID,
289+
"specID", status.SpecID,
290+
)
291+
return nil
292+
}
293+
return fmt.Errorf("deleting service account %q: %w", status.SpecID, err)
298294
}
299295

300296
return nil

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/grafana/grafana-operator/v5
33
go 1.24.2
44

55
// https://github.com/grafana/grafana-openapi-client-go/pull/115
6-
replace github.com/grafana/grafana-openapi-client-go => github.com/ndk/grafana-openapi-client-go v0.0.0-20250507135519-d761c7accb2b
6+
replace github.com/grafana/grafana-openapi-client-go => github.com/ndk/grafana-openapi-client-go v0.0.0-20250625114140-5abf8d2d12df
77

88
require (
99
github.com/KimMachineGun/automemlimit v0.7.3
@@ -31,7 +31,7 @@ require (
3131
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3232
github.com/go-logr/stdr v1.2.2 // indirect
3333
github.com/go-openapi/analysis v0.23.0 // indirect
34-
github.com/go-openapi/errors v0.22.0 // indirect
34+
github.com/go-openapi/errors v0.22.1 // indirect
3535
github.com/go-openapi/loads v0.22.0 // indirect
3636
github.com/go-openapi/runtime v0.28.0 // indirect
3737
github.com/go-openapi/spec v0.21.0 // indirect
@@ -67,13 +67,13 @@ require (
6767
github.com/go-logr/zapr v1.3.0 // indirect
6868
github.com/go-openapi/jsonpointer v0.21.0 // indirect
6969
github.com/go-openapi/jsonreference v0.21.0 // indirect
70-
github.com/go-openapi/swag v0.23.0 // indirect
70+
github.com/go-openapi/swag v0.23.1 // indirect
7171
github.com/gogo/protobuf v1.3.2 // indirect
7272
github.com/google/go-cmp v0.7.0 // indirect
7373
github.com/google/uuid v1.6.0 // indirect
7474
github.com/josharian/intern v1.0.0 // indirect
7575
github.com/json-iterator/go v1.1.12 // indirect
76-
github.com/mailru/easyjson v0.7.7 // indirect
76+
github.com/mailru/easyjson v0.9.0 // indirect
7777
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7878
github.com/modern-go/reflect2 v1.0.2 // indirect
7979
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
3333
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
3434
github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU=
3535
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
36-
github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w=
37-
github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE=
36+
github.com/go-openapi/errors v0.22.1 h1:kslMRRnK7NCb/CvR1q1VWuEQCEIsBGn5GgKD9e+HYhU=
37+
github.com/go-openapi/errors v0.22.1/go.mod h1:+n/5UdIqdVnLIJ6Q9Se8HNGUXYaY6CN8ImWzfi/Gzp0=
3838
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
3939
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
4040
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
@@ -47,8 +47,8 @@ github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9Z
4747
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
4848
github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c=
4949
github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4=
50-
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
51-
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
50+
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
51+
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
5252
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
5353
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
5454
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
@@ -85,8 +85,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8585
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
8686
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
8787
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
88-
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
89-
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
88+
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
89+
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
9090
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
9191
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
9292
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -96,8 +96,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
9696
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
9797
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
9898
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
99-
github.com/ndk/grafana-openapi-client-go v0.0.0-20250507135519-d761c7accb2b h1:94R+XfsVmDlYjV7NZgBLbbH59F/b88FIyRxfDiKEC/c=
100-
github.com/ndk/grafana-openapi-client-go v0.0.0-20250507135519-d761c7accb2b/go.mod h1:hiZnMmXc9KXNUlvkV2BKFsiWuIFF/fF4wGgYWEjBitI=
99+
github.com/ndk/grafana-openapi-client-go v0.0.0-20250625114140-5abf8d2d12df h1:45orEsQWqmK5BL2KYmp8PBGJqlVxgFu+nE9v28c/MRI=
100+
github.com/ndk/grafana-openapi-client-go v0.0.0-20250625114140-5abf8d2d12df/go.mod h1:AOzHLStinAJHJmcih1eEbIRImxpT6enYUsZLnnOvhbo=
101101
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
102102
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
103103
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=

0 commit comments

Comments
 (0)