Skip to content

Commit

Permalink
fix: ignore errors on duplicate SetHeader calls
Browse files Browse the repository at this point in the history
Updating gRPC library to 1.47 version makes it more picky about the
duplicate calls to `SetHeader`. Due to the nature of proxying, we might
try to set it multiple times, so simply ignore the error (doing best
effort to set it correctly, but with multiple upstreams setting headers
from all upstreams is not possible).

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Jun 6, 2022
1 parent b076302 commit 6dfa2cc
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 131 deletions.
20 changes: 10 additions & 10 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-25T21:15:43Z by kres 424ae88-dirty.
# Generated on 2022-06-06T17:35:55Z by kres 65530e7.

codecov:
require_ci_to_pass: false
require_ci_to_pass: false

coverage:
status:
project:
default:
target: 50%
threshold: 0.5%
base: auto
if_ci_failed: success
patch: off
status:
project:
default:
target: 50%
threshold: 0.5%
base: auto
if_ci_failed: success
patch: off

comment: false
10 changes: 7 additions & 3 deletions .conform.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-25T21:16:46Z by kres 424ae88-dirty.
# Generated on 2022-06-06T17:35:55Z by kres 65530e7.

---
policies:
- type: commit
spec:
dco: true
gpg: false
gpg:
required: true
identity:
gitHubOrganization: siderolabs
spellcheck:
locale: US
maximumOfOneCommit: true
Expand All @@ -19,4 +23,4 @@ policies:
required: true
conventional:
types: ["chore","docs","perf","refactor","style","test","release"]
scopes: ["*"]
scopes: [".*"]
54 changes: 52 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-25T21:15:43Z by kres 424ae88-dirty.
# Generated on 2022-06-06T17:35:55Z by kres 65530e7.

kind: pipeline
type: kubernetes
Expand Down Expand Up @@ -122,9 +122,59 @@ steps:
depends_on:
- base

- name: release-notes
pull: always
image: autonomy/build-container:latest
commands:
- make release-notes
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- unit-tests
- coverage
- lint

- name: release
pull: always
image: plugins/github-release
settings:
api_key:
from_secret: github_token
checksum:
- sha256
- sha512
draft: true
files:
- _out/*
note: _out/RELEASE_NOTES.md
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- release-notes

services:
- name: docker
image: docker:19.03-dind
image: docker:20.10-dind
entrypoint:
- dockerd
commands:
Expand Down
43 changes: 28 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-25T21:15:43Z by kres 424ae88-dirty.

# Generated on 2022-06-06T17:35:55Z by kres 65530e7.

# options for analysis running
run:
Expand All @@ -22,7 +21,6 @@ output:
uniq-by-line: true
path-prefix: ""


# all available settings of specific linters
linters-settings:
dogsled:
Expand All @@ -41,6 +39,13 @@ linters-settings:
local-prefixes: github.com/talos-systems/grpc-proxy
gocognit:
min-complexity: 30
ireturn:
allow:
- anon
- error
- empty
- stdlib
- github.com\/talos-systems\/kres\/internal\/dag.Node
nestif:
min-complexity: 5
goconst:
Expand Down Expand Up @@ -91,7 +96,7 @@ linters-settings:
require-explanation: false
require-specific: true
rowserrcheck: {}
testpackage:
testpackage: {}
unparam:
check-exported: false
unused:
Expand All @@ -116,23 +121,33 @@ linters-settings:

linters:
enable-all: true
disable-all: false
fast: false
disable:
- exhaustruct
- exhaustivestruct
- forbidigo
- funlen
- gas
- typecheck
- gochecknoglobals
- gochecknoinits
- funlen
- godox
- gomnd
- goerr113
- gomnd
- gomoddirectives
- nestif
- wrapcheck
- paralleltest
- exhaustivestruct
- forbidigo
disable-all: false
fast: false

- promlinter
- tagliatelle
- thelper
- typecheck
- varnamelen
- wrapcheck
# abandoned linters for which golangci shows the warning that the repo is archived by the owner
- interfacer
- maligned
- golint
- scopelint

issues:
exclude: []
Expand All @@ -141,10 +156,8 @@ issues:
exclude-case-sensitive: false
max-issues-per-linter: 10
max-same-issues: 3

new: false

severity:
default-severity: error

case-sensitive: false
56 changes: 24 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-25T21:36:57Z by kres 424ae88-dirty.
# Generated on 2022-06-06T17:35:55Z by kres 65530e7.

ARG TOOLCHAIN

# cleaned up specs and compiled versions
FROM scratch AS generate

# runs markdownlint
FROM node:14.8.0-alpine AS lint-markdown
RUN npm i -g markdownlint-cli@0.23.2
RUN npm i sentences-per-line@0.2.1
FROM node:18.2.0-alpine AS lint-markdown
WORKDIR /src
RUN npm i -g markdownlint-cli@0.31.1
RUN npm i sentences-per-line@0.2.1
COPY .markdownlint.json .
COPY ./README.md ./README.md
RUN markdownlint --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules /node_modules/sentences-per-line/index.js .

# collects proto specs
FROM scratch AS proto-specs
ADD testservice/api/test.proto /testservice/
RUN markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js .

# base toolchain image
FROM ${TOOLCHAIN} AS toolchain
Expand All @@ -28,18 +27,17 @@ FROM toolchain AS tools
ENV GO111MODULE on
ENV CGO_ENABLED 0
ENV GOPATH /go
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.38.0
ARG GOLANGCILINT_VERSION
RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/${GOLANGCILINT_VERSION}/install.sh | bash -s -- -b /bin ${GOLANGCILINT_VERSION}
ARG GOFUMPT_VERSION
RUN cd $(mktemp -d) \
&& go mod init tmp \
&& go get mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumports /bin/gofumports
ARG PROTOBUF_GO_VERSION
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOBUF_GO_VERSION}
RUN mv /go/bin/protoc-gen-go /bin
ARG GRPC_GO_VERSION
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GRPC_GO_VERSION}
RUN mv /go/bin/protoc-gen-go-grpc /bin
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumpt /bin/gofumpt
ARG GOIMPORTS_VERSION
RUN go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
&& mv /go/bin/goimports /bin/goimports
ARG DEEPCOPY_VERSION
RUN go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
&& mv /go/bin/deep-copy /bin/deep-copy

# tools and sources
FROM tools AS base
Expand All @@ -52,15 +50,13 @@ COPY ./proxy ./proxy
COPY ./testservice ./testservice
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null

# runs protobuf compiler
FROM tools AS proto-compile
COPY --from=proto-specs / /
RUN protoc -I/testservice --go_out=paths=source_relative:/testservice --go-grpc_out=paths=source_relative:/testservice /testservice/test.proto

# runs gofumpt
FROM base AS lint-gofumpt
RUN find . -name '*.pb.go' | xargs -r rm
RUN FILES="$(gofumports -l -local github.com/talos-systems/grpc-proxy .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumports -w -local github.com/talos-systems/grpc-proxy .':\n${FILES}"; exit 1)
RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumpt -w .':\n${FILES}"; exit 1)

# runs goimports
FROM base AS lint-goimports
RUN FILES="$(goimports -l -local github.com/talos-systems/grpc-proxy .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'goimports -w -local github.com/talos-systems/grpc-proxy .':\n${FILES}"; exit 1)

# runs golangci-lint
FROM base AS lint-golangci-lint
Expand All @@ -76,11 +72,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g
# runs unit-tests
FROM base AS unit-tests-run
ARG TESTPKGS
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -count 1 ${TESTPKGS}

# cleaned up specs and compiled versions
FROM scratch AS generate
COPY --from=proto-compile /testservice/ /testservice/
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}

FROM scratch AS unit-tests
COPY --from=unit-tests-run /src/coverage.txt /coverage.txt
Expand Down

0 comments on commit 6dfa2cc

Please sign in to comment.