mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-04 14:45:41 +00:00
fix(drift): stop flagging declared external networks as drift (#1402)
The spatial drift engine reported a service attached to a declared
external network (top-level networks: { foo: { external: true } }) as
"attached to a network not declared in compose", marking the stack
permanently drifted. runtimeResourceName project-prefixed every declared
network to <project>_<key>, but Docker never prefixes an external
network: it references a pre-existing network by its real name. The
phantom <project>_<key> never matched the runtime name, so the
attachment fell through to a foreign-network finding.
Resolve external networks to their real name (the key, or a name:
override) without the project prefix, so the raw declared adapter agrees
with the rendered model the Network Inspector already used. Add unit,
adapter, and engine-level regression tests, and extend the adapter
equivalence test to cover an external network with no name override.
This commit is contained in:
@@ -349,6 +349,21 @@ describe('assembleStackDrift - network drift', () => {
|
||||
});
|
||||
expect(report.findings.filter(f => f.kind.startsWith('network-'))).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not flag an attachment to a declared external network (regression: shared arr-net)', () => {
|
||||
// arr-net is declared `external: true` with no name override, so Docker attaches
|
||||
// the container to the pre-existing network named "arr-net" (no project prefix).
|
||||
// The runtime matches the compose, so this must read as in-sync rather than a
|
||||
// foreign/undeclared-network finding.
|
||||
const report = assembleStackDrift({
|
||||
stack: 'plex',
|
||||
declared: { services: [service({ name: 'plex', networks: ['arr-net'] })], networks: { 'arr-net': { external: true } }, volumes: {} },
|
||||
containers: [container({ id: 'plex', service: 'plex', stack: 'plex', networks: [{ name: 'arr-net', id: 'a', ip: '' }] })],
|
||||
networks: [depNet('arr-net', { composeProject: null, stack: null })],
|
||||
});
|
||||
expect(report.findings.filter(f => f.kind.startsWith('network-'))).toEqual([]);
|
||||
expect(report.status).toBe('in-sync');
|
||||
});
|
||||
});
|
||||
|
||||
// ── normalizeImageRef ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user