Skip to content

Commit

Permalink
Merge pull request kubernetes#6862 from karsten42/master
Browse files Browse the repository at this point in the history
Show requests/responses made towards Hetzner cloud for high log levels
  • Loading branch information
k8s-ci-robot authored May 27, 2024
2 parents cf606a1 + aa5d773 commit 62ca17c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ cd cluster-autoscaler/cloudprovider/hetzner
UPSTREAM_REF=v2.0.0 hack/update-vendor.sh
git add hcloud-go/
```

## Debugging

To enable debug logging, set the log level of the autoscaler to at least level 5 via cli flag: `--v=5`
The logs will include all requests and responses made towards the Hetzner API including headers and body.
29 changes: 29 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/hetzner_debug_writer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hetzner

import (
"k8s.io/klog/v2"
)

// debugWriter is a writer that logs to klog at level 5.
type debugWriter struct{}

func (d debugWriter) Write(p []byte) (n int, err error) {
klog.V(5).Info(string(p))
return len(p), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func newManager() (*hetznerManager, error) {
hcloud.WithHTTPClient(httpClient),
hcloud.WithApplication("cluster-autoscaler", version.ClusterAutoscalerVersion),
hcloud.WithPollBackoffFunc(hcloud.ExponentialBackoff(2, 500*time.Millisecond)),
hcloud.WithDebugWriter(&debugWriter{}),
)

ctx := context.Background()
Expand Down

0 comments on commit 62ca17c

Please sign in to comment.