Skip to content

Commit 9aec234

Browse files
committed
fix: custom kubeconfigs
1 parent 4f710e3 commit 9aec234

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

go.mod

-7
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,9 @@ require (
117117
github.com/asecurityteam/rolling v2.0.4+incompatible // indirect
118118
github.com/aws/aws-sdk-go-v2/config v1.27.36 // indirect
119119
github.com/aws/aws-sdk-go-v2/credentials v1.17.34 // indirect
120-
github.com/bahlo/generic-list-go v0.2.0 // indirect
121120
github.com/beorn7/perks v1.0.1 // indirect
122121
github.com/blang/semver/v4 v4.0.0 // indirect
123122
github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect
124-
github.com/buger/jsonparser v1.1.1 // indirect
125123
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
126124
github.com/cert-manager/cert-manager v1.16.1 // indirect
127125
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -165,7 +163,6 @@ require (
165163
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
166164
github.com/henvic/httpretty v0.1.3 // indirect
167165
github.com/hirochachacha/go-smb2 v1.1.0 // indirect
168-
github.com/invopop/jsonschema v0.12.0 // indirect
169166
github.com/itchyny/gojq v0.12.17 // indirect
170167
github.com/itchyny/timefmt-go v0.1.6 // indirect
171168
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
@@ -218,12 +215,8 @@ require (
218215
github.com/vadimi/go-http-ntlm v1.0.3 // indirect
219216
github.com/vadimi/go-http-ntlm/v2 v2.4.1 // indirect
220217
github.com/vadimi/go-ntlm v1.2.1 // indirect
221-
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
222218
github.com/x448/float16 v0.8.4 // indirect
223219
github.com/xanzy/ssh-agent v0.3.3 // indirect
224-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
225-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
226-
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
227220
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
228221
github.com/yuin/gopher-lua v1.1.1 // indirect
229222
github.com/yusufpapurcu/wmi v1.2.4 // indirect

go.sum

-14
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ github.com/aws/aws-sdk-go-v2/service/support v1.24.3 h1:Bbesu6YZvEYACyydELMwUTYY
386386
github.com/aws/aws-sdk-go-v2/service/support v1.24.3/go.mod h1:NvXUhACskXZ2tiXzECpC/97xKzyY7/Wcc1ug5rla7kY=
387387
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
388388
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
389-
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
390-
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
391389
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
392390
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
393391
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -401,8 +399,6 @@ github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0
401399
github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
402400
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
403401
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
404-
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
405-
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
406402
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
407403
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
408404
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
@@ -736,8 +732,6 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
736732
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
737733
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
738734
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
739-
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
740-
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
741735
github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg=
742736
github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY=
743737
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q=
@@ -1110,18 +1104,10 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
11101104
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
11111105
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
11121106
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
1113-
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
1114-
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
11151107
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
11161108
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
11171109
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
11181110
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
1119-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
1120-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
1121-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
1122-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
1123-
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
1124-
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
11251111
github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4=
11261112
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
11271113
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=

scrapers/incremental.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,6 @@ func ConsumeKubernetesWatchJobFunc(sc api.ScrapeContext, config v1.Kubernetes, q
132132

133133
cc := api.NewScrapeContext(ctx.Context).WithScrapeConfig(sc.ScrapeConfig()).WithJobHistory(ctx.History).AsIncrementalScrape()
134134
cc.Context = cc.Context.WithoutName().WithName(fmt.Sprintf("watch[%s/%s]", cc.GetNamespace(), cc.GetName()))
135-
if config.Kubeconfig != nil {
136-
c, err := cc.WithKubeconfig(*config.Kubeconfig)
137-
if err != nil {
138-
ctx.History.AddErrorf("failed to apply custom kubeconfig: %v", err)
139-
return
140-
}
141-
cc.Context = *c
142-
}
143135

144136
backoff := retry.WithMaxRetries(3, retry.NewExponential(time.Second))
145137
err := retry.Do(ctx, backoff, func(_ctx gocontext.Context) error {
@@ -148,6 +140,12 @@ func ConsumeKubernetesWatchJobFunc(sc api.ScrapeContext, config v1.Kubernetes, q
148140
return retry.RetryableError(err)
149141
}
150142

143+
percent := float64(len(objs)) / float64(len(eventInvolvedObjs))
144+
if percent < 0.5 {
145+
// smells like a bug
146+
ctx.Logger.V(3).Infof("requested %d involved objects but fetched only %d", len(eventInvolvedObjs), len(objs))
147+
}
148+
151149
// we put these involved objects back into the queue
152150
for _, obj := range objs {
153151
queue.Enqueue(kubernetes.NewQueueItem(obj, kubernetes.QueueItemOperationReEnqueue))

scrapers/kubernetes/informers.go

-9
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ func WatchResources(ctx api.ScrapeContext, config v1.Kubernetes) (*collections.Q
5454
priorityQueue = loaded.(*collections.Queue[*QueueItem])
5555
}
5656

57-
if config.Kubeconfig != nil {
58-
var err error
59-
c, err := ctx.WithKubeconfig(*config.Kubeconfig)
60-
if err != nil {
61-
return nil, fmt.Errorf("failed to apply kube config: %w", err)
62-
}
63-
ctx.Context = *c
64-
}
65-
6657
for _, watchResource := range lo.Uniq(config.Watch) {
6758
if err := globalSharedInformerManager.Register(ctx, watchResource, priorityQueue); err != nil {
6859
return nil, fmt.Errorf("failed to register informer: %w", err)

0 commit comments

Comments
 (0)