Skip to content

Commit 9f37eec

Browse files
committed
Merge branch 'master' into redact-log
2 parents 3dcb8de + 85c75b1 commit 9f37eec

488 files changed

Lines changed: 20234 additions & 14582 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/upload-test-logs/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
sudo tar -czvf ./logs.tar.gz ./logs
2626
2727
- name: Upload logs
28-
uses: actions/upload-artifact@v4
28+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2929
if: always()
3030
with:
3131
name: ${{ inputs.log-name || 'test-logs' }}

‎.github/workflows/check_and_build.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ jobs:
5454
architecture: nextgen
5555
steps:
5656
- name: Check out code into the Go module directory
57-
uses: actions/checkout@v3
57+
uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0
5858

5959
- name: Setup Go environment
60-
uses: actions/setup-go@v6
60+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
6161
with:
6262
go-version-file: 'go.mod'
6363

6464
- name: Cache Tools
6565
id: cache-tools
66-
uses: actions/cache@v3
66+
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
6767
with:
6868
path: tools/bin
6969
key: macos-latest-ticdc-tools-${{ hashFiles('tools/check/go.mod', 'tools/check/go.sum') }}

‎.github/workflows/check_next_gen_grafana.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- name: Check out code
34-
uses: actions/checkout@v4
34+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
3535

3636
- name: Check Next Gen Grafana
3737
run: make check-next-gen-grafana

‎.github/workflows/integration_test_mysql.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
name: E2E Test Group
3737
steps:
3838
- name: Check out code
39-
uses: actions/checkout@v2
39+
uses: actions/checkout@0717577d45739eb3c851188b29f50ed6c0b2194e # v2.8.0
4040

4141
- name: Setup Go environment
42-
uses: actions/setup-go@v6
42+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
4343
with:
4444
go-version-file: 'go.mod'
4545

‎.github/workflows/pr_build_and_test.yaml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Check out code
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
3939
with:
4040
fetch-depth: 0
4141

4242
- name: Setup Go environment
4343
id: setup-go
44-
uses: actions/setup-go@v6
44+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
4545
with:
4646
go-version-file: 'go.mod'
4747
# Cached explicitly below with a per-job key, see "Cache Go".
@@ -104,10 +104,10 @@ jobs:
104104
name: ${{ matrix.task.name }}
105105
steps:
106106
- name: Check out code
107-
uses: actions/checkout@v4
107+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
108108

109109
- name: Setup Go environment
110-
uses: actions/setup-go@v6
110+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
111111
with:
112112
go-version-file: 'go.mod'
113113
# Cached explicitly below with a per-task key, see "Cache Go".
@@ -153,10 +153,10 @@ jobs:
153153
name: ${{ matrix.task.name }}
154154
steps:
155155
- name: Check out code
156-
uses: actions/checkout@v4
156+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
157157

158158
- name: Setup Go environment
159-
uses: actions/setup-go@v6
159+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
160160
with:
161161
go-version-file: 'go.mod'
162162
# Cached explicitly below with a per-task key, see "Cache Go".

‎.github/workflows/release.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- name: Checkout
37-
uses: actions/checkout@v4
37+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
3838
with:
3939
fetch-depth: 1
4040
- name: Publish Release

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Read these only when relevant to the task:
3636

3737
## Project Structure & Module Organization
3838

39-
- `cmd/`: buildable binaries (e.g. `cmd/cdc`, `cmd/kafka-consumer`).
39+
- `cmd/`: buildable binaries (e.g. `cmd/cdc`, `cmd/consumer`).
4040
- `downstreamadapter/`: downstream adapters and sinks (e.g. `downstreamadapter/sink/kafka`).
4141
- `pkg/`: shared libraries (config, codec, sink implementations, errors, utilities).
4242
- `server/`, `coordinator/`, `maintainer/`, `logservice/`: runtime components and orchestration.

‎Makefile‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.PHONY: clean fmt check check-static local-static-check tidy \
44
check-go-version \
55
generate-protobuf generate_mock \
6-
cdc kafka_consumer storage_consumer pulsar_consumer filter_helper kafka_auth_server \
6+
cdc consumer filter_helper kafka_auth_server \
77
prepare_test_binaries \
88
unit_test_in_verify_ci integration_test_build integration_test_build_fast integration_test_mysql integration_test_kafka integration_test_storage integration_test_pulsar \
99
generate-next-gen-grafana check-next-gen-grafana
@@ -47,7 +47,6 @@ CURRENT_GO_MINOR := $(shell printf '%s\n' '$(CURRENT_GO_VERSION)' | sed -E 's/^(
4747
# ref: https://github.com/cloudfoundry/gosigar/issues/58#issuecomment-1150925711
4848
# ref: https://github.com/pingcap/tidb/pull/39526#issuecomment-1407952955
4949
OS := "$(shell go env GOOS)"
50-
IS_ALPINE := $(shell if [ -f /etc/os-release ]; then grep -qi Alpine /etc/os-release && echo 1; else echo 0; fi)
5150
ifeq (${OS}, "linux")
5251
CGO := 0
5352
else ifeq (${OS}, "darwin")
@@ -111,12 +110,7 @@ LDFLAGS += -X "$(TIFLOW_CDC_PKG)/pkg/version.GitHash=$(GITHASH)"
111110
LDFLAGS += -X "$(TIFLOW_CDC_PKG)/pkg/version.GitBranch=$(GITBRANCH)"
112111
LDFLAGS += -X "$(TIFLOW_CDC_PKG)/pkg/version.BuildTS=$(BUILDTS)"
113112

114-
CONSUMER_BUILD_FLAG=
115-
ifeq ("${IS_ALPINE}", "1")
116-
CONSUMER_BUILD_FLAG = -tags musl
117-
endif
118113
GOBUILD := $(GOEXPERIMENT) CGO_ENABLED=$(CGO) $(GO) build $(BUILD_FLAG) -trimpath $(GOVENDORFLAG)
119-
CONSUMER_GOBUILD := $(GOEXPERIMENT) CGO_ENABLED=1 $(GO) build $(CONSUMER_BUILD_FLAG) -trimpath $(GOVENDORFLAG)
120114

121115
PACKAGE_LIST := go list ./... | grep -vE 'vendor|proto|ticdc/tests|integration|testing_utils|pb|pbmock|ticdc/bin'
122116
PACKAGES := $$($(PACKAGE_LIST))
@@ -177,14 +171,8 @@ build-cdc-with-failpoint: ## Build cdc with failpoint enabled.
177171
cdc: check-go-version
178172
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc ./cmd/cdc
179173

180-
kafka_consumer:
181-
$(CONSUMER_GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc_kafka_consumer ./cmd/kafka-consumer
182-
183-
storage_consumer:
184-
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc_storage_consumer ./cmd/storage-consumer
185-
186-
pulsar_consumer:
187-
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc_pulsar_consumer ./cmd/pulsar-consumer
174+
consumer: check-go-version
175+
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc_consumer ./cmd/consumer
188176

189177
oauth2_server:
190178
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/oauth2-server ./cmd/oauth2-server/main.go
@@ -225,7 +213,7 @@ check_third_party_binary:
225213
kafka_auth_server:
226214
$(GOBUILD) -o bin/kafka_auth_server ./tests/integration_tests/changefeed_update_config/kafka_auth_server
227215

228-
integration_test_build: check_failpoint_ctl storage_consumer kafka_consumer pulsar_consumer oauth2_server kafka_auth_server
216+
integration_test_build: check_failpoint_ctl consumer oauth2_server kafka_auth_server
229217
$(FAILPOINT_ENABLE)
230218
$(GOTEST) -ldflags '$(LDFLAGS)' -c -cover -covermode=atomic \
231219
-coverpkg=github.com/pingcap/ticdc/... \
@@ -235,7 +223,7 @@ integration_test_build: check_failpoint_ctl storage_consumer kafka_consumer puls
235223
|| { $(FAILPOINT_DISABLE); exit 1; }
236224
$(FAILPOINT_DISABLE)
237225

238-
integration_test_build_fast: kafka_auth_server
226+
integration_test_build_fast: consumer oauth2_server kafka_auth_server
239227
$(FAILPOINT_ENABLE)
240228
$(GOTEST) -ldflags '$(LDFLAGS)' -c -cover -covermode=atomic \
241229
-coverpkg=github.com/pingcap/ticdc/... \

‎api/middleware/authenticate_middleware.go‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ func AuthenticateMiddleware(server server.Server) gin.HandlerFunc {
4242
}
4343
}
4444

45+
// AuthenticateNodeMiddleware authenticates a node-level request. In next-gen
46+
// mode, the keyspace query parameter identifies the TiDB authentication realm.
47+
func AuthenticateNodeMiddleware(server server.Server) gin.HandlerFunc {
48+
return func(ctx *gin.Context) {
49+
security := config.GetGlobalServerConfig().Security
50+
if security != nil && security.ClientUserRequired {
51+
// Reject a request without credentials before the keyspace lookup,
52+
// otherwise a missing keyspace parameter turns its 401 into a 400.
53+
if _, _, ok := ctx.Request.BasicAuth(); !ok {
54+
if !AuthenticateRequest(ctx, server) {
55+
return
56+
}
57+
}
58+
if _, ok := ctx.Get(ctxKeyspaceKey); !ok && !loadKeyspaceFromQuery(ctx) {
59+
return
60+
}
61+
}
62+
if !AuthenticateRequest(ctx, server) {
63+
return
64+
}
65+
ctx.Next()
66+
}
67+
}
68+
4569
// AuthenticateRequest authenticates a request when client user authentication
4670
// is enabled. It can be called from a handler after the target changefeed has
4771
// supplied its persisted keyspace ID.

‎api/middleware/changefeed_operation.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func ChangefeedOperationMiddleware(operation string) gin.HandlerFunc {
110110

111111
statusCode := c.Writer.Status()
112112
lastError := c.Errors.Last()
113+
// ErrorHandleMiddleware writes the error response after this middleware
114+
// returns, so sample the status it is about to write. A handler that
115+
// already wrote a response keeps its status.
116+
if lastError != nil && statusCode < http.StatusBadRequest && !c.Writer.Written() {
117+
statusCode = errorResponseStatus(lastError.Err)
118+
}
113119
result := "success"
114120
if statusCode >= http.StatusBadRequest || lastError != nil {
115121
result = "failed"
@@ -123,6 +129,8 @@ func ChangefeedOperationMiddleware(operation string) gin.HandlerFunc {
123129
info.changefeed = c.Param(api.APIOpVarChangefeedID)
124130
}
125131

132+
// The name is the one the caller supplied, the same as LogMiddleware
133+
// records. It is verified only when client user authentication is on.
126134
username, _, _ := c.Request.BasicAuth()
127135
if username == "" {
128136
username = "anonymous"

0 commit comments

Comments
 (0)