Skip to content

Commit 18b5567

Browse files
committed
Merge branch 'v3' into stop-file-watcher-monitoring-log-files
2 parents 790eb26 + 6fc1f16 commit 18b5567

34 files changed

+1209
-687
lines changed

.testcoverage.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ exclude:
4040
- ^test/.*$
4141
- app.go # app.go and main.go should be tested by integration tests.
4242
- main.go
43-
# Intentionally ignoring as GetProcesses & KillProcess arent being tested as they are wrappers
43+
# ignore wrappers around gopsutil
4444
- internal/datasource/host
4545
- internal/watcher/process
46+
- pkg/nginxprocess
4647

4748
# NOTES:
4849
# - symbol `/` in all path regexps will be replaced by

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ can be merged. Your agreement signature will be safely stored by F5 and no longe
4848

4949
<!-- ### Go Guidelines Here Linter-->
5050

51+
* when writing [table-driven tests](https://go.dev/wiki/TableDrivenTests), add a numbered prefix to each test case name (`Test 1:`, `Test 2:`, and so on) to make it easier to see which cases failed.
52+
5153
### Git Guidelines
5254

5355
* Keep a clean, concise and meaningful git commit history on your branch (within reason), rebasing locally and squashing before submitting a PR.

api/grpc/mpi/v1/command.pb.go

Lines changed: 404 additions & 391 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.pb.validate.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ message ContainerInfo {
9090
string container_id = 1 [(buf.validate.field).string.uuid = true];
9191
// The name of the host
9292
string hostname = 2 [(buf.validate.field).string.address = true];
93+
// Release information of the container
94+
ReleaseInfo release_info = 3;
9395
}
9496

9597
// A response to a CreateConnectionRequest

docs/proto/protos.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ Container information
721721
| ----- | ---- | ----- | ----------- |
722722
| container_id | [string](#string) | | The identifier of the container |
723723
| hostname | [string](#string) | | The name of the host |
724+
| release_info | [ReleaseInfo](#mpi-v1-ReleaseInfo) | | Release information of the container |
724725

725726

726727

internal/collector/otel_collector_plugin.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ func (oc *Collector) Init(ctx context.Context, mp bus.MessagePipeInterface) erro
120120
oc.processReceivers(ctx, oc.config.Collector.Receivers.OtlpReceivers)
121121
}
122122

123+
if !oc.stopped {
124+
return errors.New("OTel collector already running")
125+
}
126+
123127
bootErr := oc.bootup(runCtx)
124128
if bootErr != nil {
125129
slog.ErrorContext(runCtx, "Unable to start OTel Collector", "error", bootErr)
@@ -219,6 +223,7 @@ func (oc *Collector) Close(ctx context.Context) error {
219223
slog.ErrorContext(ctx, "Failed to shutdown OTel Collector", "error", err, "state", oc.service.GetState())
220224
} else {
221225
slog.InfoContext(ctx, "OTel Collector shutdown", "state", oc.service.GetState())
226+
oc.stopped = true
222227
}
223228
}
224229

@@ -374,6 +379,11 @@ func (oc *Collector) restartCollector(ctx context.Context) {
374379
var runCtx context.Context
375380
runCtx, oc.cancel = context.WithCancel(ctx)
376381

382+
if !oc.stopped {
383+
slog.ErrorContext(ctx, "Unable to restart OTel collector, failed to stop collector")
384+
return
385+
}
386+
377387
bootErr := oc.bootup(runCtx)
378388
if bootErr != nil {
379389
slog.ErrorContext(runCtx, "Unable to start OTel Collector", "error", bootErr)

internal/datasource/host/info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func (i *Info) ContainerInfo(ctx context.Context) *v1.Resource_ContainerInfo {
144144
ContainerInfo: &v1.ContainerInfo{
145145
ContainerId: i.getContainerID(),
146146
Hostname: hostname,
147+
ReleaseInfo: i.getReleaseInfo(ctx, i.osReleaseLocation),
147148
},
148149
}
149150
}

internal/datasource/host/info_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,20 @@ func TestInfo_IsContainer(t *testing.T) {
426426

427427
func TestInfo_ContainerInfo(t *testing.T) {
428428
ctx := context.Background()
429+
430+
osReleaseFile := helpers.CreateFileWithErrorCheck(t, os.TempDir(), "os-release")
431+
defer helpers.RemoveFileWithErrorCheck(t, osReleaseFile.Name())
432+
err := os.WriteFile(osReleaseFile.Name(), []byte(ubuntuReleaseInfo), os.ModeAppend)
433+
require.NoError(t, err)
434+
435+
releaseInfo := &v1.ReleaseInfo{
436+
Codename: "jammy",
437+
Id: "ubuntu",
438+
Name: "Ubuntu",
439+
VersionId: "22.04",
440+
Version: "22.04.5 LTS (Jammy Jellyfish)",
441+
}
442+
429443
tests := []struct {
430444
name string
431445
mountInfo string
@@ -501,8 +515,9 @@ func TestInfo_ContainerInfo(t *testing.T) {
501515

502516
execMock := &execfakes.FakeExecInterface{}
503517
execMock.HostnameReturns(test.expectHostname, nil)
518+
execMock.ReleaseInfoReturns(releaseInfo)
504519

505-
_, err := mountInfoFile.WriteString(test.mountInfo)
520+
_, err = mountInfoFile.WriteString(test.mountInfo)
506521
require.NoError(tt, err)
507522

508523
err = mountInfoFile.Close()
@@ -515,6 +530,7 @@ func TestInfo_ContainerInfo(t *testing.T) {
515530

516531
assert.Equal(tt, test.expectContainerID, containerInfo.ContainerInfo.GetContainerId())
517532
assert.Equal(tt, test.expectHostname, containerInfo.ContainerInfo.GetHostname())
533+
assert.Equal(t, releaseInfo, containerInfo.ContainerInfo.GetReleaseInfo())
518534
})
519535
}
520536
}

internal/file/file_manager_service.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ func (fms *FileManagerService) UpdateOverview(
121121
defer backoffCancel()
122122

123123
sendUpdateOverview := func() (*mpi.UpdateOverviewResponse, error) {
124-
slog.DebugContext(newCtx, "Sending update overview request", "request", request,
125-
"parent_correlation_id", correlationID)
126124
if fms.fileServiceClient == nil {
127125
return nil, errors.New("file service client is not initialized")
128126
}
@@ -131,6 +129,14 @@ func (fms *FileManagerService) UpdateOverview(
131129
return nil, errors.New("CreateConnection rpc has not being called yet")
132130
}
133131

132+
slog.InfoContext(newCtx, "Updating file overview",
133+
"instance_id", request.GetOverview().GetConfigVersion().GetInstanceId(),
134+
"parent_correlation_id", correlationID,
135+
)
136+
slog.DebugContext(newCtx, "Sending update overview request",
137+
"request", request, "parent_correlation_id", correlationID,
138+
)
139+
134140
response, updateError := fms.fileServiceClient.UpdateOverview(newCtx, request)
135141

136142
validatedError := grpc.ValidateGrpcError(updateError)
@@ -178,8 +184,6 @@ func (fms *FileManagerService) setupIdentifiers(ctx context.Context, iteration i
178184
}
179185

180186
newCtx := context.WithValue(ctx, logger.CorrelationIDContextKey, requestCorrelationID)
181-
slog.InfoContext(newCtx, "Updating file overview", "instance_id", logger.GetCorrelationIDAttr(ctx),
182-
"parent_correlation_id", correlationID)
183187

184188
return newCtx, correlationID
185189
}

0 commit comments

Comments
 (0)