-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from unmarshall/master
Fix for Incorrect scaling down of KCM, MCM and CA due to broken TCP connection
- Loading branch information
Showing
301 changed files
with
21,257 additions
and
9,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package scaler | ||
|
||
import ( | ||
"k8s.io/client-go/rest" | ||
"net/http" | ||
) | ||
|
||
// DisableKeepAlive sets `DisableKeepAlive` to true on the transport that is use by the underline rest client | ||
// Fixes https://github.com/gardener/dependency-watchdog/issues/61 | ||
func DisableKeepAlive(config *rest.Config) error { | ||
transport, err := createTransportWithDisableKeepAlive(config) | ||
if err != nil { | ||
return err | ||
} | ||
config.Wrap(func(rt http.RoundTripper) http.RoundTripper { | ||
return transport | ||
}) | ||
return nil | ||
} | ||
|
||
func createTransportWithDisableKeepAlive(config *rest.Config) (*http.Transport, error) { | ||
tlsConfig, err := rest.TLSConfigFor(config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
transport := http.DefaultTransport.(*http.Transport).Clone() | ||
transport.DisableKeepAlives = true | ||
transport.TLSClientConfig = tlsConfig | ||
return transport, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package scaler_test | ||
|
||
import ( | ||
"github.com/gardener/dependency-watchdog/pkg/scaler" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
kubeConfig = `apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
name: test | ||
certificate-authority-date: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURvRENDQW9nQ0NRQ1NWMElyenhoaEdUQU5CZ2txaGtpRzl3MEJBUXNGQURDQmtERUxNQWtHQTFVRUJoTUMKUkVVeEdqQVlCZ05WQkFnTUVVSmhaR1Z1TFZkMWNuUjBaVzFpWlhKbk1SRXdEd1lEVlFRSERBaFhZV3hzWkc5eQpaakVQTUEwR0ExVUVDZ3dHVTBGUUlGTkZNUkV3RHdZRFZRUUxEQWhIWVhKa1pXNWxjakVQTUEwR0ExVUVBd3dHClkyRjBaWE4wTVIwd0d3WUpLb1pJaHZjTkFRa0JGZzVqWVhSbGMzUkFjMkZ3TG1OdmJUQWdGdzB5TWpBNE1ERXcKTmpRNU1qQmFHQTh6TURJeE1USXdNakEyTkRreU1Gb3dnWkF4Q3pBSkJnTlZCQVlUQWtSRk1Sb3dHQVlEVlFRSQpEQkZDWVdSbGJpMVhkWEowZEdWdFltVnlaekVSTUE4R0ExVUVCd3dJVjJGc2JHUnZjbVl4RHpBTkJnTlZCQW9NCkJsTkJVQ0JUUlRFUk1BOEdBMVVFQ3d3SVIyRnlaR1Z1WlhJeER6QU5CZ05WQkFNTUJtTmhkR1Z6ZERFZE1Cc0cKQ1NxR1NJYjNEUUVKQVJZT1kyRjBaWE4wUUhOaGNDNWpiM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LS0tCg== | ||
server: https://kube-apiserver.shoot--test--local.svc | ||
contexts: | ||
- context: | ||
cluster: shoot--test--local | ||
user: admin | ||
name: shoot--test--local | ||
users: | ||
- name: admin | ||
user: | ||
username: admin | ||
password: admin@bingo | ||
` | ||
) | ||
|
||
var _ = Describe("Checking KeepAlive setting on rest.config", func() { | ||
var config *rest.Config | ||
BeforeEach(func() { | ||
clientConfig, err := clientcmd.NewClientConfigFromBytes([]byte(kubeConfig)) | ||
Expect(err).To(BeNil()) | ||
config, err = clientConfig.ClientConfig() | ||
Expect(err).To(BeNil()) | ||
}) | ||
It("defaults to KeepAlive enabled", func() { | ||
roundTripper, err := rest.TransportFor(config) | ||
Expect(err).To(BeNil()) | ||
transport := roundTripper.(*http.Transport) | ||
Expect(transport).ToNot(BeNil()) | ||
Expect(transport.DisableKeepAlives).To(BeFalse()) | ||
}) | ||
It("can set KeepAlive to disabled", func() { | ||
err := scaler.DisableKeepAlive(config) | ||
Expect(err).To(BeNil()) | ||
roundTripper, err := rest.TransportFor(config) | ||
Expect(err).To(BeNil()) | ||
t := roundTripper.(*http.Transport) | ||
Expect(t).ToNot(BeNil()) | ||
Expect(t.DisableKeepAlives).To(BeTrue()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.