Skip to content

Commit 0024261

Browse files
authored
Update container OS details on the control plane UI (#977)
* chore: add proto * chore: update the protos * chore: lint * chore: update test
1 parent 96b0501 commit 0024261

File tree

6 files changed

+454
-392
lines changed

6 files changed

+454
-392
lines changed

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/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
}

0 commit comments

Comments
 (0)