Skip to content

Commit

Permalink
Fix hangs when no https server is available
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jan 17, 2024
1 parent b4864f5 commit 8d032bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/prometheus/client_model v0.4.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/wzshiming/cmux v0.3.2
github.com/wzshiming/cmux v0.3.3
github.com/wzshiming/ctc v1.2.3
github.com/wzshiming/easycel v0.5.0
go.etcd.io/etcd/client/v3 v3.5.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vladimirvivien/gexe v0.2.0 h1:nbdAQ6vbZ+ZNsolCgSVb9Fno60kzSuvtzVh6Ytqi/xY=
github.com/vladimirvivien/gexe v0.2.0/go.mod h1:LHQL00w/7gDUKIak24n801ABp8C+ni6eBht9vGVst8w=
github.com/wzshiming/cmux v0.3.2 h1:lBEWbfbRqUDdXB6Mro/g35kvCuUEmAgIdpGEuER3bis=
github.com/wzshiming/cmux v0.3.2/go.mod h1:lPhqJN2E3frzkxrPdjesxL09z7nTcuZ6i8Is+2G/Xw4=
github.com/wzshiming/cmux v0.3.3 h1:WlcKUwSN4vpClnHiyX9I4RtZ4xJeAqfrf4ltxSWuPoQ=
github.com/wzshiming/cmux v0.3.3/go.mod h1:lPhqJN2E3frzkxrPdjesxL09z7nTcuZ6i8Is+2G/Xw4=
github.com/wzshiming/ctc v1.2.3 h1:q+hW3IQNsjIlOFBTGZZZeIXTElFM4grF4spW/errh/c=
github.com/wzshiming/ctc v1.2.3/go.mod h1:2tVAtIY7SUyraSk0JxvwmONNPFL4ARavPuEsg5+KA28=
github.com/wzshiming/easycel v0.5.0 h1:pnMBpOuEfr9EYLNpKD52NfpAhUrOQ3uAHFQT7bF76ZM=
Expand Down
17 changes: 17 additions & 0 deletions pkg/kwok/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
"net/http/httptest"
"time"

"github.com/emicklei/go-restful/v3"
Expand Down Expand Up @@ -422,6 +423,22 @@ func (s *Server) Run(ctx context.Context, address string, certFile, privateKeyFi
errCh <- fmt.Errorf("serve https: %w", err)
}
}()
} else {
logger.Info("Starting test HTTPS server",
"address", address,
)
svc := httptest.Server{
Listener: tlsListener,
Config: &http.Server{
ReadHeaderTimeout: 5 * time.Second,
BaseContext: func(_ net.Listener) context.Context {
return ctx
},
Addr: address,
Handler: s.restfulCont,
},
}
svc.StartTLS()
}

go func() {
Expand Down

0 comments on commit 8d032bf

Please sign in to comment.