Adopt network to running instance - #635
Conversation
mlohvynenko
left a comment
There was a problem hiding this comment.
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
mykola-kobets-epam
left a comment
There was a problem hiding this comment.
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
| /** | ||
| * Bridge link kind. | ||
| */ | ||
| static constexpr auto cLinkKindBridge = "bridge"; |
There was a problem hiding this comment.
Probably better to make it as Aos Enum?
| Error AddInstanceToCache(const String& instanceID, const String& networkID); | ||
| RetWithError<bool> IsInstanceInterfaceAlive( | ||
| const String& instanceID, const String& hostIfName, const String& bridgeIfName) const; | ||
| Error AdoptInstance(const String& instanceID, const String& networkID); |
| } | ||
| } | ||
|
|
||
| if (auto errDNS = AdoptDNSServer(entry.mNetworkID); !errDNS.IsNone()) { |
There was a problem hiding this comment.
Use err =
and in the following condition
|
|
||
| auto cleanupMonitoring = DeferRelease(&instanceID, [this, &err](const String* id) { | ||
| if (!err.IsNone()) { | ||
| if (auto errStop = mNetMonitor->StopInstanceMonitoring(*id); !errStop.IsNone()) { |
There was a problem hiding this comment.
no, assigning to err here would disarm the other defers: they all guard on !err.IsNone() and are destroyed after this one, so a successful StopInstanceMonitoring would reset err and silently skip the remaining rollbacks.
9ffe3e6 to
cb3a210
Compare
al1img
left a comment
There was a problem hiding this comment.
Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
InterfaceManagerItf exposed only mutating operations, so there was no way to tell an interface that must be created from one that is already on the system and can be adopted as is. Same for network namespaces. Add InterfaceManagerItf::GetLink returning link kind, master, vlan ID and admin state (eNotFound when the link is absent) and NamespaceManagerItf::IsNetworkNamespaceExist. Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
After a crash SM restarts with an empty mPhysicalNetworks, so the first StartInstanceNetwork ran CreateNetwork over links that are still up. Recreating them is not a no-op: rtnl_link_add is issued without NLM_F_EXCL, so the kernel treats it as a modify request and CreateVlan pushes a freshly generated MAC onto the live vlan, breaking traffic of the instances still running on it. Probe each link with the new InterfaceManagerItf::GetLink and create only what is missing. Rollback deletes a link only when this call created it, so a failure midway no longer tears down an adopted one. Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
CleanupLeftoverInstances tore down every instance recorded in storage on Start: it detached the host veth and deleted the network namespace even when the instance was alive and correctly wired, so an SM crash cut the network of containers that kept running. Replace it with ReconcileInstances, which checks the system before acting. An instance whose host veth is up, is a veth and is enslaved to its own bridge, and whose network namespace still exists, is adopted: nothing on the system is touched, only the runtime cache is restored. Everything else keeps the previous teardown path. Adopting into the runtime cache also makes the launcher restart flow work: StartInstanceNetwork now short-circuits with eAlreadyExist, which the launcher already tolerates. Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
DeleteInstanceNetworkConfig removes the DNS record through the handle in mDNSServers, which is runtime state and is empty after a restart. Without a handle a dead leftover instance kept its addnhosts record. Adopt the handle before the cleanup again, now that DNSServer::Init loads the existing records instead of truncating them and so no longer drops the records of instances adopted on the same network. Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
FirewallItf gains RemoveOrphans so that the firewall no longer has to wipe its whole table on start to get rid of what a crashed SM left behind. Call it from Start with the instances and networks known from storage, so artifacts of anything gone are removed while the rules protecting the instances that kept running stay in place. Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Signed-off-by: Mykola Solianko <mykola_solianko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
cb3a210 to
beaa5b2
Compare
|


No description provided.