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
This commit is contained in:
@@ -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' },
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { NodeData } from '@/types'
|
||||
export type NodeType = NodeData['type']
|
||||
|
||||
const CONTAINER_MODE_TYPES = new Set<NodeType>(['proxmox', 'vm', 'lxc', 'docker_host'])
|
||||
const DOCKER_CONTAINER_PARENT_TYPES = new Set<NodeType>(['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
|
||||
|
||||
Reference in New Issue
Block a user