diff --git a/client/fingerprint/memory.go b/client/fingerprint/memory.go index 04436e9b01c..8320f9bb77f 100644 --- a/client/fingerprint/memory.go +++ b/client/fingerprint/memory.go @@ -43,9 +43,15 @@ func (f *MemoryFingerprint) Fingerprint(req *FingerprintRequest, resp *Fingerpri if totalMemory > 0 { resp.AddAttribute("memory.totalbytes", fmt.Sprintf("%d", totalMemory)) + memoryMB := totalMemory / bytesInMB + + resp.Resources = &structs.Resources{ + MemoryMB: int(memoryMB), + } + resp.NodeResources = &structs.NodeResources{ Memory: structs.NodeMemoryResources{ - MemoryMB: totalMemory / bytesInMB, + MemoryMB: memoryMB, }, } } diff --git a/client/fingerprint/memory_test.go b/client/fingerprint/memory_test.go index c04b0f94747..8635b55fd5c 100644 --- a/client/fingerprint/memory_test.go +++ b/client/fingerprint/memory_test.go @@ -24,6 +24,8 @@ func TestMemoryFingerprint(t *testing.T) { require.NoError(err) assertNodeAttributeContains(t, response.Attributes, "memory.totalbytes") + require.NotNil(response.Resources, "expected response Resources to not be nil") + require.NotZero(response.Resources.MemoryMB, "expected memory to be non-zero") require.NotNil(response.NodeResources, "expected response NodeResources to not be nil") require.NotZero(response.NodeResources.Memory.MemoryMB, "expected memory to be non-zero") } @@ -44,6 +46,8 @@ func TestMemoryFingerprint_Override(t *testing.T) { assertNodeAttributeContains(t, response.Attributes, "memory.totalbytes") require := require.New(t) + require.NotNil(response.Resources) + require.EqualValues(response.Resources.MemoryMB, memoryMB) require.NotNil(response.NodeResources) require.EqualValues(response.NodeResources.Memory.MemoryMB, memoryMB) }