Skip to content

Commit f2aca14

Browse files
committed
merge v3
2 parents 0840c6d + 9b574fa commit f2aca14

36 files changed

+51497
-162
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,3 @@ jobs:
306306
- name: Push load test result
307307
if: ${{ success() && github.ref_name == 'v3'}}
308308
run: git push 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git' benchmark-results:benchmark-results
309-
310-
publish-packages:
311-
name: Publish NGINX Agent v3 packages
312-
if: ${{ github.ref_name == 'v3' &&
313-
!github.event.pull_request.head.repo.fork }}
314-
needs: [ lint, unit-test, performance-tests,
315-
load-tests, official-oss-image-integration-tests,
316-
official-plus-image-integration-tests,
317-
race-condition-test, integration-tests ]
318-
uses: ./.github/workflows/release-branch.yml
319-
secrets: inherit
320-
permissions:
321-
id-token: write
322-
contents: read
323-
with:
324-
packageVersion: "3.0.0"
325-
packageBuildNo: "${{ github.run_number }}"
326-
uploadAzure: true
327-
publishPackages: true
328-
releaseBranch: "v3"

.github/workflows/release-branch.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,6 @@ on:
3939
description: 'Location to publish packages to'
4040
required: false
4141
default: "https://up-ap.nginx.com"
42-
workflow_call:
43-
inputs:
44-
githubRelease:
45-
type: boolean
46-
default: false
47-
packageVersion:
48-
type: string
49-
default: "3.0.0"
50-
packageBuildNo:
51-
type: string
52-
default: "1"
53-
uploadAzure:
54-
type: boolean
55-
default: true
56-
publishPackages:
57-
type: boolean
58-
default: true
59-
tagRelease:
60-
type: boolean
61-
default: false
62-
createPullRequest:
63-
type: boolean
64-
default: false
65-
releaseBranch:
66-
type: string
67-
required: true
68-
uploadUrl:
69-
type: string
70-
default: "https://up-ap.nginx.com"
7142

7243
env:
7344
NFPM_VERSION: 'v2.35.3'

internal/collector/nginxplusreceiver/factory.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import (
99
"errors"
1010
"time"
1111

12+
"go.opentelemetry.io/collector/scraper"
13+
"go.opentelemetry.io/collector/scraper/scraperhelper"
14+
1215
"go.opentelemetry.io/collector/component"
1316
"go.opentelemetry.io/collector/consumer"
1417
"go.opentelemetry.io/collector/receiver"
1518

1619
"github.com/nginx/agent/v3/internal/collector/nginxplusreceiver/internal/metadata"
1720
)
1821

22+
// nolint: ireturn
1923
const defaultTimeout = 10 * time.Second
2024

2125
// nolint: ireturn
@@ -43,6 +47,19 @@ func createMetricsReceiver(
4347
}
4448

4549
nps := newNginxPlusScraper(params, cfg)
50+
npsMetrics, npsMetricsError := scraper.NewMetrics(
51+
nps.Scrape,
52+
scraper.WithStart(nps.Start),
53+
scraper.WithShutdown(nps.Shutdown),
54+
)
55+
if npsMetricsError != nil {
56+
return nil, npsMetricsError
57+
}
4658

47-
return nps, nil
59+
return scraperhelper.NewMetricsController(
60+
&cfg.ControllerConfig,
61+
params,
62+
metricsConsumer,
63+
scraperhelper.AddScraper(metadata.Type, npsMetrics),
64+
)
4865
}

internal/collector/otelcol.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ exporters:
156156
tls:
157157
insecure: {{ if .TLS -}}false{{ else -}}true{{- end }}
158158
{{- if .TLS }}
159+
insecure_skip_verify: {{ .TLS.SkipVerify }}
159160
{{ if gt (len .TLS.Ca) 0 -}}ca_file: "{{- .TLS.Ca -}}"{{- end }}
160161
{{ if gt (len .TLS.Cert) 0 -}}cert_file: "{{- .TLS.Cert -}}"{{- end }}
161162
{{ if gt (len .TLS.Key) 0 -}}key_file: "{{- .TLS.Key -}}"{{- end }}

internal/config/config.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func checkCollectorConfiguration(collector *Collector, config *Config) {
143143
if isOTelExporterConfigured(collector) && config.IsGrpcClientConfigured() && config.IsAuthConfigured() &&
144144
config.IsTLSConfigured() {
145145
slog.Info("No collector configuration found in NGINX Agent config, command server configuration found."+
146-
"Using default collector configuration", configLogOrigin)
146+
" Using default collector configuration", configLogOrigin)
147147
defaultCollector(collector, config)
148148
}
149149
}
@@ -373,13 +373,25 @@ func registerClientFlags(fs *flag.FlagSet) {
373373
fs.Int(
374374
ClientGRPCMaxMessageReceiveSizeKey,
375375
DefMaxMessageRecieveSize,
376-
"Updates the client grpc setting MaxRecvMsgSize with the specific value in MB.",
376+
"Updates the client grpc setting MaxRecvMsgSize with the specific value in bytes.",
377377
)
378378

379379
fs.Int(
380380
ClientGRPCMaxMessageSendSizeKey,
381381
DefMaxMessageSendSize,
382-
"Updates the client grpc setting MaxSendMsgSize with the specific value in MB.",
382+
"Updates the client grpc setting MaxSendMsgSize with the specific value in bytes.",
383+
)
384+
385+
fs.Uint32(
386+
ClientGRPCFileChunkSizeKey,
387+
DefFileChunkSize,
388+
"File chunk size in bytes.",
389+
)
390+
391+
fs.Uint32(
392+
ClientGRPCMaxFileSizeKey,
393+
DefMaxFileSize,
394+
"Max file size in bytes.",
383395
)
384396
}
385397

@@ -716,6 +728,8 @@ func resolveClient() *Client {
716728
MaxMessageSize: viperInstance.GetInt(ClientGRPCMaxMessageSizeKey),
717729
MaxMessageReceiveSize: viperInstance.GetInt(ClientGRPCMaxMessageReceiveSizeKey),
718730
MaxMessageSendSize: viperInstance.GetInt(ClientGRPCMaxMessageSendSizeKey),
731+
MaxFileSize: viperInstance.GetUint32(ClientGRPCMaxFileSizeKey),
732+
FileChunkSize: viperInstance.GetUint32(ClientGRPCFileChunkSizeKey),
719733
},
720734
Backoff: &BackOff{
721735
InitialInterval: viperInstance.GetDuration(ClientBackoffInitialIntervalKey),

internal/config/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ func checkDefaultsClientValues(t *testing.T, viperInstance *viper.Viper) {
104104
assert.Equal(t, DefMaxMessageSize, viperInstance.GetInt(ClientGRPCMaxMessageSizeKey))
105105
assert.Equal(t, DefMaxMessageRecieveSize, viperInstance.GetInt(ClientGRPCMaxMessageReceiveSizeKey))
106106
assert.Equal(t, DefMaxMessageSendSize, viperInstance.GetInt(ClientGRPCMaxMessageSendSizeKey))
107+
assert.Equal(t, DefFileChunkSize, viperInstance.GetUint32(ClientGRPCFileChunkSizeKey))
108+
assert.Equal(t, DefMaxFileSize, viperInstance.GetUint32(ClientGRPCMaxFileSizeKey))
107109
assert.Equal(t, make(map[string]string), viperInstance.GetStringMapString(LabelsRootKey))
108110
}
109111

@@ -781,6 +783,8 @@ func createConfig() *Config {
781783
MaxMessageSize: 1048575,
782784
MaxMessageReceiveSize: 1048575,
783785
MaxMessageSendSize: 1048575,
786+
MaxFileSize: 485753,
787+
FileChunkSize: 48575,
784788
},
785789
Backoff: &BackOff{
786790
InitialInterval: 200 * time.Millisecond,

internal/config/defaults.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package config
66

77
import (
8-
"math"
98
"time"
109

1110
pkg "github.com/nginx/agent/v3/pkg/config"
@@ -28,9 +27,11 @@ const (
2827
DefCommandTLServerNameKey = ""
2928

3029
// Client GRPC Settings
31-
DefMaxMessageSize = 0 // 0 = unset
32-
DefMaxMessageRecieveSize = 4194304 // default 4 MB
33-
DefMaxMessageSendSize = math.MaxInt32
30+
DefMaxMessageSize = 0 // 0 = unset
31+
DefMaxMessageRecieveSize = 4194304 // default 4 MB
32+
DefMaxMessageSendSize = 4194304 // default 4 MB
33+
DefMaxFileSize uint32 = 1048576 // 1MB
34+
DefFileChunkSize uint32 = 524288 // 0.5MB
3435

3536
// Client HTTP Settings
3637
DefHTTPTimeout = 10 * time.Second
@@ -41,11 +42,11 @@ const (
4142
DefGRPCKeepAlivePermitWithoutStream = true
4243

4344
// Client Backoff defaults
44-
DefBackoffInitialInterval = 500 * time.Millisecond
45+
DefBackoffInitialInterval = 1 * time.Second
4546
DefBackoffRandomizationFactor = 0.5 // the value is 0 <= and < 1
46-
DefBackoffMultiplier = 1.5
47-
DefBackoffMaxInterval = 5 * time.Second
48-
DefBackoffMaxElapsedTime = 30 * time.Second
47+
DefBackoffMultiplier = 3
48+
DefBackoffMaxInterval = 20 * time.Second
49+
DefBackoffMaxElapsedTime = 1 * time.Minute
4950

5051
// Watcher defaults
5152
DefInstanceWatcherMonitoringFrequency = 5 * time.Second

internal/config/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ var (
3636
ClientGRPCMaxMessageSendSizeKey = pre(ClientRootKey) + "grpc_max_message_send_size"
3737
ClientGRPCMaxMessageReceiveSizeKey = pre(ClientRootKey) + "grpc_max_message_receive_size"
3838
ClientGRPCMaxMessageSizeKey = pre(ClientRootKey) + "grpc_max_message_size"
39+
ClientGRPCMaxFileSizeKey = pre(ClientRootKey) + "grpc_max_file_size"
40+
ClientGRPCFileChunkSizeKey = pre(ClientRootKey) + "grpc_file_chunk_size"
3941

4042
ClientBackoffInitialIntervalKey = pre(ClientRootKey) + "backoff_initial_interval"
4143
ClientBackoffMaxIntervalKey = pre(ClientRootKey) + "backoff_max_interval"

internal/config/testdata/nginx-agent.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ client:
3535
max_message_size: 1048575
3636
max_message_receive_size: 1048575
3737
max_message_send_size: 1048575
38+
max_file_size: 485753
39+
file_chunk_size: 48575
3840
backoff:
3941
initial_interval: 200ms
4042
max_interval: 10s

internal/config/types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ type (
8383
KeepAlive *KeepAlive `yaml:"keepalive" mapstructure:"keepalive"`
8484
// if MaxMessageSize is size set then we use that value,
8585
// otherwise MaxMessageRecieveSize and MaxMessageSendSize for individual settings
86-
MaxMessageSize int `yaml:"max_message_size" mapstructure:"max_message_size"`
87-
MaxMessageReceiveSize int `yaml:"max_message_receive_size" mapstructure:"max_message_receive_size"`
88-
MaxMessageSendSize int `yaml:"max_message_send_size" mapstructure:"max_message_send_size"`
86+
MaxMessageSize int `yaml:"max_message_size" mapstructure:"max_message_size"`
87+
MaxMessageReceiveSize int `yaml:"max_message_receive_size" mapstructure:"max_message_receive_size"`
88+
MaxMessageSendSize int `yaml:"max_message_send_size" mapstructure:"max_message_send_size"`
89+
MaxFileSize uint32 `yaml:"max_file_size" mapstructure:"max_file_size"`
90+
FileChunkSize uint32 `yaml:"file_chunk_size" mapstructure:"file_chunk_size"`
8991
}
9092

9193
KeepAlive struct {
@@ -231,7 +233,7 @@ type (
231233
}
232234

233235
ContainerMetricsReceiver struct {
234-
CollectionInterval time.Duration `yaml:"-" mapstructure:"collection_interval"`
236+
CollectionInterval time.Duration `yaml:"collection_interval" mapstructure:"collection_interval"`
235237
}
236238

237239
HostMetrics struct {

0 commit comments

Comments
 (0)