From 43426e96aca53aabb4d7c40fa53882c840633fd1 Mon Sep 17 00:00:00 2001 From: Pouzor Date: Sat, 16 May 2026 16:47:14 +0200 Subject: [PATCH] feat(docker): allow vm and proxmox as parent for docker_container Extend docker_container parent rule to accept vm and proxmox nodes in addition to docker_host and lxc, covering nested virtualization topologies (Docker on a VM, Docker directly on Proxmox host). ha-relevant: yes --- .../utils/__tests__/virtualEdgeParent.test.ts | 18 +++++++++++++++++- frontend/src/utils/virtualEdgeParent.ts | 5 +++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/__tests__/virtualEdgeParent.test.ts b/frontend/src/utils/__tests__/virtualEdgeParent.test.ts index 66f638b..6308866 100644 --- a/frontend/src/utils/__tests__/virtualEdgeParent.test.ts +++ b/frontend/src/utils/__tests__/virtualEdgeParent.test.ts @@ -42,7 +42,23 @@ describe('resolveVirtualEdgeParent', () => { expect(res).toEqual({ childId: 'dc1', parentId: 'lxc1' }) }) - it('returns null when docker_container links to non-host/lxc target', () => { + it('nests docker_container under vm', () => { + const res = resolveVirtualEdgeParent( + { id: 'dc1', type: 'docker_container' }, + { id: 'vm1', type: 'vm' }, + ) + expect(res).toEqual({ childId: 'dc1', parentId: 'vm1' }) + }) + + it('nests docker_container under proxmox (reverse direction)', () => { + const res = resolveVirtualEdgeParent( + { id: 'px1', type: 'proxmox' }, + { id: 'dc1', type: 'docker_container' }, + ) + expect(res).toEqual({ childId: 'dc1', parentId: 'px1' }) + }) + + it('returns null when docker_container links to unsupported parent type', () => { const res = resolveVirtualEdgeParent( { id: 'dc1', type: 'docker_container' }, { id: 'srv1', type: 'server' }, diff --git a/frontend/src/utils/virtualEdgeParent.ts b/frontend/src/utils/virtualEdgeParent.ts index 924e8f9..b239822 100644 --- a/frontend/src/utils/virtualEdgeParent.ts +++ b/frontend/src/utils/virtualEdgeParent.ts @@ -3,6 +3,7 @@ import type { NodeData } from '@/types' export type NodeType = NodeData['type'] const CONTAINER_MODE_TYPES = new Set(['proxmox', 'vm', 'lxc', 'docker_host']) +const DOCKER_CONTAINER_PARENT_TYPES = new Set(['docker_host', 'lxc', 'vm', 'proxmox']) export interface VirtualEdgeEndpoint { id: string @@ -27,10 +28,10 @@ export function resolveVirtualEdgeParent( if (CONTAINER_MODE_TYPES.has(srcType) && (tgtType === 'lxc' || tgtType === 'vm')) { return { childId: tgtId, parentId: srcId } } - if (srcType === 'docker_container' && (tgtType === 'docker_host' || tgtType === 'lxc')) { + if (srcType === 'docker_container' && DOCKER_CONTAINER_PARENT_TYPES.has(tgtType)) { return { childId: srcId, parentId: tgtId } } - if (tgtType === 'docker_container' && (srcType === 'docker_host' || srcType === 'lxc')) { + if (tgtType === 'docker_container' && DOCKER_CONTAINER_PARENT_TYPES.has(srcType)) { return { childId: tgtId, parentId: srcId } } return null