Skip to content

Commit 47e8662

Browse files
authored
dumpling: return error if init log file failed (#60801)
close #60689
1 parent 351445e commit 47e8662

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed

DEPS.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,13 +5893,13 @@ def go_deps():
58935893
name = "com_github_pingcap_log",
58945894
build_file_proto_mode = "disable_global",
58955895
importpath = "github.com/pingcap/log",
5896-
sha256 = "ecdf624669a639a91f49a368f7090df11e9bff366f404fc8a379035fb4d9fe7f",
5897-
strip_prefix = "github.com/pingcap/[email protected].20241212030209-7e3ff8601a2a",
5896+
sha256 = "8c5ac751f87626274ace3b615ff7b88552eede51c58eddb6c1f0a7ba5b191c6e",
5897+
strip_prefix = "github.com/pingcap/[email protected].20250424032633-85a82d016f84",
58985898
urls = [
5899-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5900-
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5901-
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5902-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5899+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5900+
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5901+
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5902+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
59035903
],
59045904
)
59055905
go_repository(

dumpling/log/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "log",
@@ -11,3 +11,12 @@ go_library(
1111
"@org_uber_go_zap//:zap",
1212
],
1313
)
14+
15+
go_test(
16+
name = "log_test",
17+
timeout = "short",
18+
srcs = ["log_test.go"],
19+
embed = [":log"],
20+
flaky = True,
21+
deps = ["@com_github_stretchr_testify//require"],
22+
)

dumpling/log/log_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 PingCAP, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package log
16+
17+
import (
18+
"os"
19+
"testing"
20+
21+
"github.com/stretchr/testify/require"
22+
)
23+
24+
func TestInitLogNoPermission(t *testing.T) {
25+
tmpDir := t.TempDir()
26+
conf := &Config{
27+
Level: "debug",
28+
File: tmpDir + "/test.log",
29+
Format: "text",
30+
}
31+
32+
logger, _, err := InitAppLogger(conf)
33+
require.NoError(t, err)
34+
require.NotNil(t, logger)
35+
36+
err = os.Chmod(tmpDir, 0)
37+
require.NoError(t, err)
38+
39+
_, _, err = InitAppLogger(conf)
40+
require.ErrorContains(t, err, "permission denied")
41+
}

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ require (
8989
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
9090
github.com/pingcap/fn v1.0.0
9191
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d
92-
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a
92+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84
9393
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
9494
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
9595
github.com/pingcap/tipb v0.0.0-20250401143359-775c2379cbc7
@@ -336,4 +336,3 @@ replace (
336336
sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
337337
sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
338338
)
339-

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d h1:52qhTQG8G8V/pHo
685685
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
686686
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
687687
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
688-
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8=
689-
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
688+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84 h1:ljnSbUq7LOkUtLtDXjTS5GanSWSAQ8pgVn7ucXMeMK8=
689+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
690690
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 h1:T4pXRhBflzDeAhmOQHNPRRogMYxP13V7BkYw3ZsoSfE=
691691
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5/go.mod h1:rlimy0GcTvjiJqvD5mXTRr8O2eNZPBrcUgiWVYp9530=
692692
github.com/pingcap/tipb v0.0.0-20250401143359-775c2379cbc7 h1:iRRoPMrpj4jkIzhMT+yabc98bhGeUzAFSjh5HUOn5Yg=

0 commit comments

Comments
 (0)