Skip to content

An open source, self-hosted, real-time port monitoring and discovery tool.

fix: correct TrueNAS container memory units (#118)

Mostafa Wahiedd98921519b5a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5d7bb5..e9d2c0d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,26 +4,34 @@ All notable changes to portracker will be documented in this file.
## [Unreleased]
+## [1.3.13] - 2026-09-14
+
+### Fixed
+
+<!-- whatsnew:title=Correct memory sizes for TrueNAS containers -->
+<!-- whatsnew:description=Container memory now shows the correct amount instead of unrealistically large values. -->
+- **[TrueNAS Container Memory]**: Preserve byte-valued container memory from the TrueNAS API instead of applying the MiB conversion used for virtual machines. Ordinary VM memory conversion is unchanged.
+
## [1.3.12] - 2026-09-13
### Fixed
-<!-- whatsnew:title=Fixed startup on ARM64 Docker hosts -->
-<!-- whatsnew:description=Portracker starts correctly again on ARM64 Docker hosts, including Apple Silicon and ARM Linux systems. -->
+<!-- whatsnew:title=Fixed startup on Apple Silicon Macs -->
+<!-- whatsnew:description=Portracker now starts correctly in Docker on Apple Silicon Macs and other ARM-based devices. -->
- **[ARM64 Startup]**: Prevent host-installed dependencies from overwriting target-platform dependencies during Docker builds, preserving the correct SQLite native binding in ARM64 images (#115).
## [1.3.11] - 2026-09-11
### Security
-<!-- whatsnew:title=Authentication now protects settings and integrations -->
-<!-- whatsnew:description=When authentication is enabled, settings and autoxpose controls now require a signed-in session. Existing autoxpose connections must be reconnected once after upgrading. Reported by Mirko Benacci. -->
+<!-- whatsnew:title=Sign-in protection for settings and autoxpose -->
+<!-- whatsnew:description=With sign-in enabled, you must be signed in to access settings and autoxpose controls. Reconnect autoxpose once after upgrading. Reported by Mirko Benacci. -->
- **[Authentication Boundary]**: Protected settings and autoxpose routes when `ENABLE_AUTH=true`, preventing unauthenticated configuration changes, integration inventory access, and server-side URL requests. autoxpose requests are pinned to validated addresses, time/size bounded, and prevented from reaching loopback, link-local, reserved, or redirect destinations; intended private LAN destinations remain supported. Browser access is same-origin by default, and generic settings writes cannot change connection state. Existing saved autoxpose connections are intentionally cleared and must be reconnected once by a signed-in user. Reported by Mirko Benacci.
### Fixed
-<!-- whatsnew:title=Fixed a crash caused by containers exposing thousands of ports -->
-<!-- whatsnew:description=Some apps (like the Ubikron stack) expose thousands of unpublished internal ports on a single container, which could make the dashboard run out of memory. Portracker now filters oversized internal-port sets before they reach the dashboard. -->
+<!-- whatsnew:title=Fixed dashboard crashes with some apps -->
+<!-- whatsnew:description=Apps that list thousands of internal ports no longer overwhelm the dashboard. Published ports remain visible. -->
- **[Large Port Count Crash]**: Oversized unpublished/internal port sets are filtered before they reach the dashboard. The limit (`MAX_INTERNAL_PORTS_PER_CONTAINER`, default 100) applies to Docker and TrueNAS collection, local API responses, peer scan responses, and local or remote container details (#108).
<!-- whatsnew:title=Faster recovery when TrueNAS is unavailable -->
@@ -45,9 +53,11 @@ All notable changes to portracker will be documented in this file.
### Fixed
-<!-- whatsnew:title=Service status & sidebar shortcut fixes -->
-<!-- whatsnew:description=Probes use the Docker host gateway for 0.0.0.0 ports so status no longer flips to yellow/red on default-bridge installs. The sidebar tip now shows the correct keyboard shortcut for your OS. -->
+<!-- whatsnew:title=More reliable service status -->
+<!-- whatsnew:description=Services using Docker's default network no longer incorrectly appear yellow or red because Portracker checked the wrong address. -->
- **[Probe Host Resolution]**: Service status probes fall back to the Docker host gateway for `0.0.0.0`/`::` ports instead of `127.0.0.1`, fixing false yellow/red statuses on default-bridge installs without `HOST_OVERRIDE`.
+<!-- whatsnew:title=Correct keyboard shortcuts for your computer -->
+<!-- whatsnew:description=The sidebar tip now shows the appropriate shortcuts for your operating system, without awkward line wrapping. -->
- **[Sidebar Shortcut Label]**: The "sidebar has knobs" tip now shows the correct keyboard shortcut for your OS (`⌘B`/`⌘K` on macOS, `Ctrl+B`/`Ctrl+K` elsewhere) instead of a combined string that could wrap mid-pair on narrow sidebars.
## [1.3.8] - 2026-05-04
diff --git a/backend/collectors/truenas_collector.js b/backend/collectors/truenas_collector.js
index 258165f..88b8c57 100644
--- a/backend/collectors/truenas_collector.js
+++ b/backend/collectors/truenas_collector.js
@@ -1607,13 +1607,13 @@ class TrueNASCollector extends BaseCollector {
this.log(`Collected ${realVMs.length} TrueNAS virtual machines`);
}
if (enhancedData.containers && enhancedData.containers.length > 0) {
- const lxcContainers = enhancedData.containers.map((vm) => ({
+ results.vms.push(...enhancedData.containers.map((vm) => ({
type: "vm",
id: vm.id,
name: vm.name,
status: this._mapVMStatus(vm.status),
vcpus: vm.cpu,
- memory: vm.memory ? vm.memory * 1024 * 1024 : null,
+ memory: vm.memory || null,
autostart: vm.autostart,
platform: "truenas",
platform_data: {
@@ -1625,9 +1625,8 @@ class TrueNASCollector extends BaseCollector {
storage_pool: vm.storage_pool,
orig_data: vm,
},
- }));
- results.vms.push(...lxcContainers);
- this.log(`Collected ${lxcContainers.length} TrueNAS LXC containers`);
+ })));
+ this.log(`Collected ${enhancedData.containers.length} TrueNAS LXC containers`);
}
if (!failures.length) this.logInfo("Enhanced features collection completed successfully");
diff --git a/backend/collectors/truenas_collector.test.js b/backend/collectors/truenas_collector.test.js
index 176cdd9..61c971a 100644
--- a/backend/collectors/truenas_collector.test.js
+++ b/backend/collectors/truenas_collector.test.js
@@ -103,4 +103,36 @@ describe("bounded TrueNAS enrichment", () => {
expect(result.systemInfo.hostname).toBe("enriched");
expect(result.ports).toHaveLength(1);
});
+
+ test.each([4294967296, 8589934592])("preserves container memory bytes (%i) while converting VM MiB", async containerMemory => {
+ const collector = fixture();
+ const virtualMachine = { id: "memory-vm", name: "memory-vm", memory: 4096, status: "RUNNING" };
+ const container = { id: "memory-container", name: "memory-container", memory: containerMemory, status: "RUNNING" };
+ collector._ensureTrueNASClient = async () => {};
+ collector._collectEnhancedFeatures = async () => ({ vms: [virtualMachine], containers: [container], failures: [] });
+
+ const result = await collector.collectAll();
+ expect(result.enhancedFeaturesStatus.state).toBe("ready");
+ expect(result.vms.find(item => item.id === virtualMachine.id).memory).toBe(4294967296);
+ expect(result.vms.find(item => item.id === container.id)).toEqual(expect.objectContaining({
+ memory: containerMemory,
+ platform_data: expect.objectContaining({ container_type: "lxc", orig_data: container }),
+ }));
+ expect(virtualMachine.memory).toBe(4096);
+ expect(container.memory).toBe(containerMemory);
+ });
+
+ test.each([undefined, null, 0])("keeps unavailable VM and container memory (%s) as null", async memory => {
+ const collector = fixture();
+ collector._ensureTrueNASClient = async () => {};
+ collector._collectEnhancedFeatures = async () => ({
+ vms: [{ id: "memory-vm", memory, status: "RUNNING" }],
+ containers: [{ id: "memory-container", memory, status: "RUNNING" }],
+ failures: [],
+ });
+
+ const result = await collector.collectAll();
+ expect(result.vms).toHaveLength(2);
+ expect(result.vms.every(item => item.memory === null)).toBe(true);
+ });
});
\ No newline at end of file
diff --git a/package.json b/package.json
index c1b0db8..a4e656f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portracker",
- "version": "1.3.12",
+ "version": "1.3.13",
"description": "A multi-platform port-tracking dashboard",
"main": "backend/index.js",
"scripts": {
diff --git a/scripts/browser-contracts.mjs b/scripts/browser-contracts.mjs
index 694051c..9d51baf 100644
--- a/scripts/browser-contracts.mjs
+++ b/scripts/browser-contracts.mjs
@@ -53,6 +53,19 @@ async function settings(page) {
await page.keyboard.press('Escape');
}
+async function memoryLabels(page, options) {
+ for (const [name, memory] of [['contract-vm', '1 GB'], ['contract-lxc-4g', '4 GB'], ['contract-lxc-8g', '8 GB']]) {
+ const heading = page.getByRole('heading', { name, exact: true });
+ await heading.waitFor();
+ const card = heading.locator('xpath=ancestor::div[contains(@class,"rounded-lg")][1]');
+ await card.getByText(memory, { exact: true }).waitFor();
+ await card.scrollIntoViewIfNeeded();
+ const bounds = await card.boundingBox();
+ assert(bounds && bounds.x >= 0 && bounds.x + bounds.width <= options.viewport.width, 'Memory card is clipped');
+ await card.screenshot({ path: path.join(options.artifacts, `${options.viewport.width}-${name}.png`), animations: 'disabled' });
+ }
+}
+
async function viewportContract(browser, options) {
const context = await browser.newContext({ viewport: options.viewport, reducedMotion: 'reduce' });
const page = await context.newPage();
@@ -72,6 +85,7 @@ async function viewportContract(browser, options) {
await search.fill('18080');
await page.getByText('18080', { exact: true }).first().waitFor();
await search.fill('');
+ await memoryLabels(page, options);
await releaseNotice(page, options.version);
await settings(page);
await page.reload({ waitUntil: 'domcontentloaded' });
diff --git a/scripts/contract-fixture.cjs b/scripts/contract-fixture.cjs
index 6d4baed..44ca25c 100644
--- a/scripts/contract-fixture.cjs
+++ b/scripts/contract-fixture.cjs
@@ -52,6 +52,10 @@ new WebSocket.Server({ server: tls }).on('connection', socket => {
else if (message.method === 'system.info') result = { hostname: 'contract-truenas', version: 'TrueNAS-25.10.4', cores: 4, physmem: 8589934592 };
else if (message.method === 'app.query') result = [{ id: 'native-app', name: 'native-app', state: 'RUNNING', active_workloads: { used_ports: [] } }];
else if (message.method === 'vm.query') result = [{ id: 1, name: 'contract-vm', status: { state: 'RUNNING' }, vcpus: 2, memory: 1024 }];
+ else if (message.method === 'virt.instance.query') result = [
+ { id: 'contract-lxc-4g', name: 'contract-lxc-4g', status: 'RUNNING', cpu: 2, memory: 4294967296 },
+ { id: 'contract-lxc-8g', name: 'contract-lxc-8g', status: 'RUNNING', cpu: 2, memory: 8589934592 },
+ ];
else result = [];
socket.send(JSON.stringify({ msg: 'result', id: message.id, result }));
});
diff --git a/scripts/image-contracts.mjs b/scripts/image-contracts.mjs
index 801a9de..e3b6453 100644
--- a/scripts/image-contracts.mjs
+++ b/scripts/image-contracts.mjs
@@ -185,6 +185,12 @@ async function discoveryContracts() {
assert(!scan.body.ports.some(port => Number(port.host_port) >= 20000 && Number(port.host_port) <= 20100), 'Excess internal ports leaked');
assert.equal(scan.body.enhancedFeaturesStatus.state, 'ready'); assert.equal(scan.body.systemInfo.enhanced, true);
assert(scan.body.applications.some(item => item.platform_data?.type === 'truenas_app')); assert(scan.body.vms.length > 0);
+ assert.equal(scan.body.vms.find(item => item.id === 1).memory, 1073741824, 'VM memory must convert MiB to bytes');
+ for (const [id, memory] of [['contract-lxc-4g', 4294967296], ['contract-lxc-8g', 8589934592]]) {
+ const container = scan.body.vms.find(item => item.id === id);
+ assert.equal(container?.memory, memory, 'Container memory must stay in bytes');
+ assert.equal(container.platform_data.orig_data.memory, memory, 'Raw container memory must be preserved');
+ }
const peer = await request('/api/servers/contract-a/scan'); assert.equal(peer.status, 200); assert(peer.body.ports.some(port => Number(port.host_port) === 8088));
const cycle = await request('/api/servers/order', { method: 'PUT', body: { items: [{ id: 'contract-a', parentId: 'contract-b', position: 1 }, { id: 'contract-b', parentId: 'contract-a', position: 0 }] } }); assert.equal(cycle.status, 400);
record('docker-ports-peer-scan-truenas-and-order-integrity');