Skip to content

Commit

Permalink
bump envtest, golangci-lint, and kind (#6088)
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
  • Loading branch information
everettraven committed Oct 17, 2022
1 parent a5e0e28 commit 7e77408
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export IMAGE_VERSION = v1.24.0
export SIMPLE_VERSION = $(shell (test "$(shell git describe --tags)" = "$(shell git describe --tags --abbrev=0)" && echo $(shell git describe --tags)) || echo $(shell git describe --tags --abbrev=0)+git)
export GIT_VERSION = $(shell git describe --dirty --tags --always)
export GIT_COMMIT = $(shell git rev-parse HEAD)
export K8S_VERSION = 1.24.2
export K8S_VERSION = 1.25.0

# Build settings
export TOOLS_DIR = tools/bin
Expand Down Expand Up @@ -57,7 +57,7 @@ fix: ## Fixup files in the repo.

.PHONY: setup-lint
setup-lint: ## Setup the lint
$(SCRIPTS_DIR)/fetch golangci-lint 1.46.2
$(SCRIPTS_DIR)/fetch golangci-lint 1.50.0

.PHONY: lint
lint: setup-lint ## Run the lint check
Expand Down Expand Up @@ -175,12 +175,12 @@ cluster-create::

.PHONY: dev-install
dev-install::
$(SCRIPTS_DIR)/fetch kind 0.14.0
$(SCRIPTS_DIR)/fetch kind 0.16.0
$(SCRIPTS_DIR)/fetch kubectl $(K8S_VERSION) # Install kubectl AFTER envtest because envtest includes its own kubectl binary

.PHONY: test-e2e-teardown
test-e2e-teardown:
$(SCRIPTS_DIR)/fetch kind 0.14.0
$(SCRIPTS_DIR)/fetch kind 0.16.0
$(TOOLS_DIR)/kind delete cluster --name $(KIND_CLUSTER)
rm -f $(KUBECONFIG)

Expand Down
18 changes: 18 additions & 0 deletions changelog/fragments/envtest-bump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
(ansible/v1): updates the base ansible base operator event api, api server,
and proxy to now have a 5 second timeout when reading the request headers.
This is to prevent the possibility of a [Slowloris attack](https://www.cloudflare.com/learning/ddos/ddos-attack-tools/slowloris/).
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "change"
# Is this a breaking change?
breaking: false
6 changes: 4 additions & 2 deletions internal/ansible/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"net/http"
"time"

logf "sigs.k8s.io/controller-runtime/pkg/log"
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
Expand All @@ -38,8 +39,9 @@ func Run(options Options) error {
mux.HandleFunc("/metrics", metricsHandler)

server := http.Server{
Addr: fmt.Sprintf("%s:%d", options.Address, options.Port),
Handler: mux,
Addr: fmt.Sprintf("%s:%d", options.Address, options.Port),
Handler: mux,
ReadHeaderTimeout: 5 * time.Second,
}
log.Info("Starting to serve metrics listener", "Address", server.Addr)
return server.ListenAndServe()
Expand Down
3 changes: 2 additions & 1 deletion internal/ansible/proxy/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ func (s *server) ListenUnix(path string) (net.Listener, error) {
// ServeOnListener starts the server using given listener, loops forever.
func (s *server) ServeOnListener(l net.Listener) error {
server := http.Server{
Handler: s.Handler,
Handler: s.Handler,
ReadHeaderTimeout: 5 * time.Second,
}
return server.Serve(l)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ansible/runner/eventapi/eventapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func New(ident string, errChan chan<- error) (*EventReceiver, error) {

mux := http.NewServeMux()
mux.HandleFunc(rec.URLPath, rec.handleEvents)
srv := http.Server{Handler: mux}
srv := http.Server{Handler: mux, ReadHeaderTimeout: 5 * time.Second}
rec.server = &srv

go func() {
Expand Down

0 comments on commit 7e77408

Please sign in to comment.