Skip to content

Commit 6b53912

Browse files
Minor improvements and bugfixes (#90)
1 parent b1bff60 commit 6b53912

File tree

18 files changed

+332
-325
lines changed

18 files changed

+332
-325
lines changed

api/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.6
44

55
require (
66
github.com/gin-gonic/gin v1.11.0
7-
github.com/golang-jwt/jwt/v5 v5.3.0
7+
github.com/golang-jwt/jwt/v5 v5.3.1
88
github.com/google/uuid v1.6.0
99
github.com/stretchr/testify v1.11.1
1010
go.uber.org/mock v0.6.0
@@ -17,7 +17,7 @@ require (
1717
github.com/bytedance/sonic/loader v0.5.0 // indirect
1818
github.com/cloudwego/base64x v0.1.6 // indirect
1919
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
20-
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
20+
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
2121
github.com/gin-contrib/sse v1.1.0 // indirect
2222
github.com/go-playground/locales v0.14.1 // indirect
2323
github.com/go-playground/universal-translator v0.18.1 // indirect

api/host/logs_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
)
2323

2424
var (
25-
lineCountRange = valuerange.New(1, 10_000)
25+
lineCountRange = valuerange.New(1, 99_999)
2626
allowedQualifiers = map[string]bool{
2727
"access": true,
2828
"error": true,

certificate/letsencrypt/go.mod

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/go-acme/lego/v4 v4.31.0
1212
github.com/google/uuid v1.6.0
1313
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12
14-
github.com/nrdcg/oci-go-sdk/common/v1065 v1065.106.1
14+
github.com/nrdcg/oci-go-sdk/common/v1065 v1065.107.0
1515
go.uber.org/mock v0.6.0
1616
)
1717

@@ -31,7 +31,7 @@ require (
3131
github.com/alibabacloud-go/debug v1.0.1 // indirect
3232
github.com/alibabacloud-go/tea v1.4.0 // indirect
3333
github.com/alibabacloud-go/tea-utils/v2 v2.0.9 // indirect
34-
github.com/aliyun/credentials-go v1.4.10 // indirect
34+
github.com/aliyun/credentials-go v1.4.11 // indirect
3535
github.com/aws/aws-sdk-go-v2/config v1.32.7 // indirect
3636
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.17 // indirect
3737
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
@@ -46,7 +46,7 @@ require (
4646
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirect
4747
github.com/aws/smithy-go v1.24.0 // indirect
4848
github.com/aziontech/azionapi-go-sdk v0.144.0 // indirect
49-
github.com/baidubce/bce-sdk-go v0.9.258 // indirect
49+
github.com/baidubce/bce-sdk-go v0.9.259 // indirect
5050
github.com/benbjohnson/clock v1.3.5 // indirect
5151
github.com/boombuler/barcode v1.1.0 // indirect
5252
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
@@ -59,13 +59,13 @@ require (
5959
github.com/fatih/structs v1.1.0 // indirect
6060
github.com/felixge/httpsnoop v1.0.4 // indirect
6161
github.com/fsnotify/fsnotify v1.9.0 // indirect
62-
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
62+
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
6363
github.com/ghodss/yaml v1.0.0 // indirect
6464
github.com/go-acme/alidns-20150109/v4 v4.7.0 // indirect
65-
github.com/go-acme/esa-20240910/v2 v2.46.1 // indirect
65+
github.com/go-acme/esa-20240910/v2 v2.47.0 // indirect
6666
github.com/go-acme/jdcloud-sdk-go v1.64.0 // indirect
67-
github.com/go-acme/tencentclouddnspod v1.1.25 // indirect
68-
github.com/go-acme/tencentedgdeone v1.1.48 // indirect
67+
github.com/go-acme/tencentclouddnspod v1.3.24 // indirect
68+
github.com/go-acme/tencentedgdeone v1.3.38 // indirect
6969
github.com/go-errors/errors v1.5.1 // indirect
7070
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
7171
github.com/go-logr/logr v1.4.3 // indirect
@@ -80,7 +80,7 @@ require (
8080
github.com/gofrs/flock v0.13.0 // indirect
8181
github.com/gofrs/uuid v4.4.0+incompatible // indirect
8282
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
83-
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
83+
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
8484
github.com/golang/protobuf v1.5.4 // indirect
8585
github.com/google/go-querystring v1.2.0 // indirect
8686
github.com/google/pprof v0.0.0-20251213031049-b05bdaca462f // indirect
@@ -90,7 +90,7 @@ require (
9090
github.com/gophercloud/gophercloud v1.14.1 // indirect
9191
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
9292
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
93-
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.185 // indirect
93+
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.186 // indirect
9494
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
9595
github.com/infobloxopen/infoblox-go-client/v2 v2.11.0 // indirect
9696
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
@@ -120,7 +120,7 @@ require (
120120
github.com/nrdcg/mailinabox v0.3.0 // indirect
121121
github.com/nrdcg/namesilo v0.5.0 // indirect
122122
github.com/nrdcg/nodion v0.1.0 // indirect
123-
github.com/nrdcg/oci-go-sdk/dns/v1065 v1065.106.1 // indirect
123+
github.com/nrdcg/oci-go-sdk/dns/v1065 v1065.107.0 // indirect
124124
github.com/nrdcg/porkbun v0.4.0 // indirect
125125
github.com/nrdcg/vegadns v0.3.0 // indirect
126126
github.com/nzdjb/go-metaname v1.0.0 // indirect
@@ -135,9 +135,9 @@ require (
135135
github.com/regfish/regfish-dnsapi-go v0.1.1 // indirect
136136
github.com/sacloud/api-client-go v0.3.5 // indirect
137137
github.com/sacloud/go-http v0.1.9 // indirect
138-
github.com/sacloud/iaas-api-go v1.24.2 // indirect
138+
github.com/sacloud/iaas-api-go v1.25.0 // indirect
139139
github.com/sacloud/packages-go v0.0.12 // indirect
140-
github.com/sacloud/saclient-go v0.2.7 // indirect
140+
github.com/sacloud/saclient-go v0.3.0 // indirect
141141
github.com/sagikazarmark/locafero v0.12.0 // indirect
142142
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36 // indirect
143143
github.com/selectel/domains-go v1.1.0 // indirect
@@ -155,18 +155,18 @@ require (
155155
github.com/stretchr/objx v0.5.3 // indirect
156156
github.com/stretchr/testify v1.11.1 // indirect
157157
github.com/subosito/gotenv v1.6.0 // indirect
158-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.37 // indirect
158+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.42 // indirect
159159
github.com/tjfoc/gmsm v1.4.1 // indirect
160160
github.com/transip/gotransip/v6 v6.26.1 // indirect
161161
github.com/ultradns/ultradns-go-sdk v1.8.1-20250722213956-faef419 // indirect
162162
github.com/vinyldns/go-vinyldns v0.9.17 // indirect
163163
github.com/volcengine/volc-sdk-golang v1.0.235 // indirect
164164
github.com/vultr/govultr/v3 v3.26.1 // indirect
165-
github.com/yandex-cloud/go-genproto v0.46.0 // indirect
166-
github.com/yandex-cloud/go-sdk/services/dns v0.0.28 // indirect
167-
github.com/yandex-cloud/go-sdk/v2 v2.43.0 // indirect
165+
github.com/yandex-cloud/go-genproto v0.50.0 // indirect
166+
github.com/yandex-cloud/go-sdk/services/dns v0.0.32 // indirect
167+
github.com/yandex-cloud/go-sdk/v2 v2.49.0 // indirect
168168
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
169-
go.mongodb.org/mongo-driver v1.17.7 // indirect
169+
go.mongodb.org/mongo-driver v1.17.8 // indirect
170170
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
171171
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
172172
go.opentelemetry.io/otel v1.39.0 // indirect
@@ -185,9 +185,9 @@ require (
185185
golang.org/x/text v0.33.0 // indirect
186186
golang.org/x/time v0.14.0 // indirect
187187
golang.org/x/tools v0.41.0 // indirect
188-
google.golang.org/api v0.262.0 // indirect
189-
google.golang.org/genproto/googleapis/api v0.0.0-20260122232226-8e98ce8d340d // indirect
190-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260122232226-8e98ce8d340d // indirect
188+
google.golang.org/api v0.264.0 // indirect
189+
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
190+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
191191
google.golang.org/grpc v1.78.0 // indirect
192192
google.golang.org/protobuf v1.36.11 // indirect
193193
gopkg.in/ini.v1 v1.67.1 // indirect

core/nginx/log_reader.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ func newLogReader(configProvider *configuration.Configuration) *logReader {
2020
}
2121
}
2222

23-
func (r *logReader) read(
24-
_ context.Context,
25-
fileName string,
26-
tailSize int,
27-
) ([]logline.LogLine, error) {
23+
func (r *logReader) read(_ context.Context, fileName string) ([]logline.LogLine, error) {
2824
basePath, err := r.configProvider.Get("nginx-ignition.nginx.config-path")
2925
if err != nil {
3026
return nil, err
@@ -49,17 +45,5 @@ func (r *logReader) read(
4945
})
5046
}
5147

52-
if err = scanner.Err(); err != nil {
53-
return nil, err
54-
}
55-
56-
if len(lines) > tailSize {
57-
lines = lines[len(lines)-tailSize:]
58-
}
59-
60-
for i := 0; i < len(lines)/2; i++ {
61-
lines[i], lines[len(lines)-1-i] = lines[len(lines)-1-i], lines[i]
62-
}
63-
64-
return lines, nil
48+
return lines, scanner.Err()
6549
}

core/nginx/log_reader_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,13 @@ func Test_logReader(t *testing.T) {
2525
reader := newLogReader(cfg)
2626

2727
t.Run("read", func(t *testing.T) {
28-
t.Run("reads and reverses lines correctly", func(t *testing.T) {
29-
lines, err := reader.read(t.Context(), "test.log", 10)
28+
t.Run("reads lines correctly", func(t *testing.T) {
29+
lines, err := reader.read(t.Context(), "test.log")
3030
assert.NoError(t, err)
3131
assert.Equal(t, []logline.LogLine{
32-
{LineNumber: 2, Contents: "line3"},
33-
{LineNumber: 1, Contents: "line2"},
3432
{LineNumber: 0, Contents: "line1"},
35-
}, lines)
36-
})
37-
38-
t.Run("tails and reverses lines correctly", func(t *testing.T) {
39-
lines, err := reader.read(t.Context(), "test.log", 2)
40-
assert.NoError(t, err)
41-
assert.Equal(t, []logline.LogLine{
42-
{LineNumber: 2, Contents: "line3"},
4333
{LineNumber: 1, Contents: "line2"},
34+
{LineNumber: 2, Contents: "line3"},
4435
}, lines)
4536
})
4637
})

core/nginx/service.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,40 @@ func (s *service) GetHostLogs(
137137
lines int,
138138
search *LogSearch,
139139
) ([]logline.LogLine, error) {
140-
logLines, err := s.logReader.read(ctx, "host-"+hostID.String()+"."+qualifier+".log", lines)
141-
if err != nil || search == nil {
142-
return logLines, err
143-
}
144-
145-
return logline.Search(logLines, search.Query, search.SurroundingLines)
140+
return s.readLogs(ctx, lines, "host-"+hostID.String()+"."+qualifier+".log", search)
146141
}
147142

148143
func (s *service) GetMainLogs(
149144
ctx context.Context,
150145
lines int,
151146
search *LogSearch,
152147
) ([]logline.LogLine, error) {
153-
logLines, err := s.logReader.read(ctx, "main.log", lines)
154-
if err != nil || search == nil {
155-
return logLines, err
148+
return s.readLogs(ctx, lines, "main.log", search)
149+
}
150+
151+
func (s *service) readLogs(
152+
ctx context.Context,
153+
lines int,
154+
fileName string,
155+
search *LogSearch,
156+
) ([]logline.LogLine, error) {
157+
output, err := s.logReader.read(ctx, fileName)
158+
if err != nil {
159+
return nil, err
160+
}
161+
162+
if search != nil {
163+
output, err = logline.Search(output, search.Query, search.SurroundingLines)
164+
if err != nil {
165+
return nil, err
166+
}
167+
}
168+
169+
if len(output) > lines {
170+
output = output[len(output)-lines:]
156171
}
157172

158-
return logline.Search(logLines, search.Query, search.SurroundingLines)
173+
return output, nil
159174
}
160175

161176
func (s *service) rotateLogs(ctx context.Context) error {

core/nginx/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func Test_service(t *testing.T) {
3737
logReader: newLogReader(cfg),
3838
}
3939

40-
t.Run("returns requested number of lines in reverse order", func(t *testing.T) {
40+
t.Run("returns requested number of lines", func(t *testing.T) {
4141
lines, err := nginxService.GetMainLogs(t.Context(), 2, nil)
4242
assert.NoError(t, err)
4343
assert.Equal(t, []logline.LogLine{
44-
{LineNumber: 2, Contents: "line3"},
4544
{LineNumber: 1, Contents: "line2"},
45+
{LineNumber: 2, Contents: "line3"},
4646
}, lines)
4747
})
4848
})

core/settings/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
var (
2020
timeoutRange = valuerange.New(1, int(^uint(0)>>1))
2121
intervalRange = valuerange.New(1, int(^uint(0)>>1))
22-
logLinesRange = valuerange.New(0, 10000)
22+
logLinesRange = valuerange.New(0, 99_999)
2323
workerProcessesRange = valuerange.New(1, 100)
2424
workerConnectionsRange = valuerange.New(32, 4096)
2525
maximumBodySizeRange = valuerange.New(1, int(^uint(0)>>1))

core/settings/validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func Test_validator(t *testing.T) {
208208

209209
t.Run("log rotation maximum lines above range fails", func(t *testing.T) {
210210
s := newSettings()
211-
s.LogRotation.MaximumLines = 10001
211+
s.LogRotation.MaximumLines = 100000
212212
settingsValidator := newValidator(bindingCommands)
213213

214214
err := settingsValidator.validate(t.Context(), s)

database/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/JCoupalK/go-pgdump v1.1.1-0.20251117080142-ba155b05e5d3
77
github.com/golang-migrate/migrate/v4 v4.19.1
88
github.com/google/uuid v1.6.0
9-
github.com/lib/pq v1.10.9
9+
github.com/lib/pq v1.11.1
1010
github.com/stretchr/testify v1.11.1
1111
github.com/uptrace/bun v1.2.16
1212
github.com/uptrace/bun/dialect/pgdialect v1.2.16
@@ -41,7 +41,7 @@ require (
4141
golang.org/x/sys v0.40.0 // indirect
4242
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
4343
gopkg.in/yaml.v3 v3.0.1 // indirect
44-
modernc.org/libc v1.67.6 // indirect
44+
modernc.org/libc v1.67.7 // indirect
4545
modernc.org/mathutil v1.7.1 // indirect
4646
modernc.org/memory v1.11.0 // indirect
4747
)

0 commit comments

Comments
 (0)