Skip to content

Commit 4e5e54e

Browse files
committed
Merge branch 'main' into make-dev-manifest-dir-var
2 parents b0513a6 + 17db9f3 commit 4e5e54e

Some content is hidden

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

70 files changed

+45
-5395
lines changed

.golangci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ linters-settings:
7777
field-writes-are-uses: true
7878
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just wr◊ite. Default: false
7979
post-statements-are-reads: true
80-
# Mark all exported identifiers as used. Default: true
81-
exported-is-used: true
8280
# Mark all exported fields as used. Default: true
8381
exported-fields-are-used: false
8482
# Mark all function parameters as used. Default: true
@@ -770,7 +768,7 @@ linters-settings:
770768
# Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only). Default: false
771769
attr-only: false
772770
# Enforce using methods that accept a context. Default: false
773-
context-only: false
771+
context: ""
774772
# Enforce using static values for log messages. Default: false
775773
static-msg: false
776774
# Enforce using constants instead of raw keys. Default: false

Makefile.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OAPICODEGEN = github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0
22
LEFTHOOK = github.com/evilmartians/lefthook@v1.6.9
3-
GOLANGCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
3+
GOLANGCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
44
PROTOCGENGO = google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0
55
GOFUMPT = mvdan.cc/gofumpt@v0.6.0
66
COUNTERFEITER = github.com/maxbrunsfeld/counterfeiter/v6@v6.8.1

README.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ NGINX Agent is a companion daemon for your NGINX Open Source or NGINX Plus insta
1313
- Notifications of NGINX events
1414

1515
## Development Environment Setup
16+
1617
### Installing Prerequisite Packages
18+
1719
The following packages need to be installed:
18-
- make
19-
- golang (https://go.dev/doc/install)
20-
- protoc (https://grpc.io/docs/protoc-installation/)
21-
- mdatagen (There is currently an issue installing mdatagen https://github.com/open-telemetry/opentelemetry-collector/issues/9281. See instructions below for workaround.)
20+
21+
- make
22+
- golang (<https://go.dev/doc/install>)
23+
- protoc (<https://grpc.io/docs/protoc-installation/>)
24+
- mdatagen (There is currently an [issue installing mdatagen](https://github.com/open-telemetry/opentelemetry-collector/issues/9281). See instructions below for workaround.)
2225

2326
#### Workaround to install mdatagen
24-
```
27+
28+
```console
2529
git clone https://github.com/open-telemetry/opentelemetry-collector.git
2630
cd opentelemetry-collector
2731
git checkout v0.124.0
@@ -30,47 +34,60 @@ go install
3034
```
3135

3236
Before starting development on the NGINX Agent, it is important to download and install the necessary tool and dependencies required by the NGINX Agent. You can do this by running the following `make` command:
33-
```
37+
38+
```console
3439
make install-tools
3540
```
3641

3742
### Building NGINX Agent from Source Code
43+
3844
Build NGINX Agent deb package:
39-
```
45+
46+
```console
4047
OSARCH=<operating system archiecture> make local-deb-package
4148
```
49+
4250
Build NGINX Agent rpm package:
43-
```
51+
52+
```console
4453
OSARCH=<operating system archiecture> make local-rpm-package
4554
```
55+
4656
Build NGINX Agent apk package:
47-
```
57+
58+
```console
4859
OSARCH=<operating system archiecture> make local-apk-package
4960
```
5061

5162
### Testing NGINX Agent
5263

5364
#### Unit tests
65+
5466
To run unit tests and check that there is enough test coverage run the following
55-
```
67+
68+
```console
5669
make unit-test coverge
5770
```
71+
5872
To check for race conditions, the unit tests can also be run with a race condition detector
59-
```
73+
74+
```console
6075
make race-condition-test
6176
```
6277

6378
#### Integration tests
79+
6480
To run integration tests, run the following
65-
```
81+
82+
```console
6683
make integration-test
6784
```
6885

6986
#### Testing with a mock management plane
87+
7088
For testing command operations, there is a mock management gRPC server that can be used. See here: [mock management gRPC server](test/mock/grpc/README.md) \
7189
For testing metrics, there is a mock management OTel collector that can be used. See here: [mock management OTel collector](test/mock/collector/README.md)
7290

73-
7491
## NGINX Agent Technical Specifications
7592

7693
### Supported Distributions
@@ -97,7 +114,7 @@ TBD
97114

98115
## Community
99116

100-
- Our [Slack channel #nginx-agent](https://nginxcommunity.slack.com/), is the go-to place to start asking questions and sharing your thoughts.
117+
- Our [NGINX Community Forum ](https://community.nginx.org/tag/agent) is the go-to place to ask questions and share your thoughts.
101118

102119
- Our [GitHub issues page](https://github.com/nginx/agent/issues) offers space for a more technical discussion at your own pace.
103120

internal/collector/nginxplusreceiver/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type APIDetails struct {
3232
}
3333

3434
// Validate checks if the receiver configuration is valid
35+
// nolint: ireturn
3536
func (cfg *Config) Validate() error {
3637
if cfg.APIDetails.URL == "" {
3738
return errors.New("endpoint cannot be empty for nginxplusreceiver")

internal/collector/otel_collector_plugin.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (oc *Collector) handleNginxConfigUpdate(ctx context.Context, msg *bus.Messa
263263
return
264264
}
265265

266-
reloadCollector := oc.checkForNewReceivers(nginxConfigContext)
266+
reloadCollector := oc.checkForNewReceivers(ctx, nginxConfigContext)
267267

268268
if reloadCollector {
269269
slog.InfoContext(ctx, "Reloading OTel collector config, nginx config updated")
@@ -394,7 +394,7 @@ func (oc *Collector) restartCollector(ctx context.Context) {
394394
}
395395
}
396396

397-
func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigContext) bool {
397+
func (oc *Collector) checkForNewReceivers(ctx context.Context, nginxConfigContext *model.NginxConfigContext) bool {
398398
nginxReceiverFound, reloadCollector := oc.updateExistingNginxPlusReceiver(nginxConfigContext)
399399

400400
if !nginxReceiverFound && nginxConfigContext.PlusAPI.URL != "" {
@@ -410,10 +410,12 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
410410
CollectionInterval: defaultCollectionInterval,
411411
},
412412
)
413+
slog.DebugContext(ctx, "NGINX Plus API found, NGINX Plus receiver enabled to scrape metrics")
413414

414415
reloadCollector = true
415416
} else if nginxConfigContext.PlusAPI.URL == "" {
416-
reloadCollector = oc.addNginxOssReceiver(nginxConfigContext)
417+
slog.WarnContext(ctx, "NGINX Plus API is not configured, searching for stub status endpoint")
418+
reloadCollector = oc.addNginxOssReceiver(ctx, nginxConfigContext)
417419
}
418420

419421
if oc.config.IsFeatureEnabled(pkgConfig.FeatureLogsNap) {
@@ -428,7 +430,7 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
428430
return reloadCollector
429431
}
430432

431-
func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigContext) bool {
433+
func (oc *Collector) addNginxOssReceiver(ctx context.Context, nginxConfigContext *model.NginxConfigContext) bool {
432434
nginxReceiverFound, reloadCollector := oc.updateExistingNginxOSSReceiver(nginxConfigContext)
433435

434436
if !nginxReceiverFound && nginxConfigContext.StubStatus.URL != "" {
@@ -445,8 +447,11 @@ func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigCo
445447
CollectionInterval: defaultCollectionInterval,
446448
},
447449
)
450+
slog.DebugContext(ctx, "Stub status endpoint found, OSS receiver enabled to scrape metrics")
448451

449452
reloadCollector = true
453+
} else if nginxConfigContext.StubStatus.URL == "" {
454+
slog.WarnContext(ctx, "Stub status endpoint not found, NGINX metrics not available")
450455
}
451456

452457
return reloadCollector

internal/datasource/host/info_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,12 @@ func TestInfo_ContainerInfo(t *testing.T) {
526526
info := NewInfo()
527527
info.mountInfoLocation = mountInfoFile.Name()
528528
info.exec = execMock
529+
info.osReleaseLocation = "/non/existent"
529530
containerInfo := info.ContainerInfo(ctx)
530531

531532
assert.Equal(tt, test.expectContainerID, containerInfo.ContainerInfo.GetContainerId())
532533
assert.Equal(tt, test.expectHostname, containerInfo.ContainerInfo.GetHostname())
533-
assert.Equal(t, releaseInfo, containerInfo.ContainerInfo.GetReleaseInfo())
534+
assert.Equal(tt, releaseInfo, containerInfo.ContainerInfo.GetReleaseInfo())
534535
})
535536
}
536537
}

site/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

site/README.md

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)