Skip to content

Commit e12e561

Browse files
Increase genericapiserver and webhook server timeouts (#305)
* Increase genericApi and webhook server timeouts * Update pkg/apiserver/apiserver.go Co-authored-by: Liam Fallon <35595825+liamfallon@users.noreply.github.com> --------- Co-authored-by: Liam Fallon <35595825+liamfallon@users.noreply.github.com>
1 parent ca8445a commit e12e561

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/apiserver/apiserver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ func (c completedConfig) getCoreV1Client() (*corev1client.CoreV1Client, error) {
189189

190190
// New returns a new instance of PorchServer from the given config.
191191
func (c completedConfig) New(ctx context.Context) (*PorchServer, error) {
192+
// TODO: REMOVE AFTER ASYNC IMPLEMENTATION IS READY.
193+
// Set the default request timeout just above hardcoded ctx timeout
194+
c.GenericConfig.RequestTimeout = 291 * time.Second
192195
genericServer, err := c.GenericConfig.New("porch-apiserver", genericapiserver.NewEmptyDelegate())
193196
if err != nil {
194197
return nil, err

pkg/apiserver/webhooks.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type WebhookConfig struct {
7373
Port int32
7474
CertStorageDir string
7575
CertManWebhook bool
76+
timeout int32
7677
}
7778

7879
// newWebhookConfig creates a new WebhookConfig object filled with values read from environment variables
@@ -282,7 +283,8 @@ func createValidatingWebhook(ctx context.Context, cfg *WebhookConfig, caCert []b
282283
if err != nil {
283284
return fmt.Errorf("failed to setup kubeClient: %v", err)
284285
}
285-
286+
// Set max timeout value for ValidatingWebhooks
287+
cfg.timeout = 30
286288
var (
287289
validationCfgName = "packagerev-deletion-validating-webhook"
288290
fail = admissionregistrationv1.Fail
@@ -309,6 +311,7 @@ func createValidatingWebhook(ctx context.Context, cfg *WebhookConfig, caCert []b
309311
AdmissionReviewVersions: []string{"v1", "v1beta1"},
310312
SideEffects: &none,
311313
FailurePolicy: &fail,
314+
TimeoutSeconds: &cfg.timeout,
312315
}},
313316
}
314317
switch cfg.Type {
@@ -424,9 +427,9 @@ func runWebhookServer(ctx context.Context, cfg *WebhookConfig) error {
424427
Addr: fmt.Sprintf(":%d", cfg.Port),
425428
TLSConfig: &tls.Config{
426429
GetCertificate: getCertificate,
427-
MinVersion: tls.VersionTLS12,
430+
MinVersion: tls.VersionTLS12,
428431
},
429-
ReadHeaderTimeout: 10 * time.Second,
432+
ReadHeaderTimeout: 30 * time.Second,
430433
}
431434
go func() {
432435
err = server.ListenAndServeTLS("", "")

0 commit comments

Comments
 (0)