Skip to content

Refactor network manager#528

Open
MykolaSuperman wants to merge 6 commits intoaosedge:feature_release_9.1from
MykolaSuperman:refactor_network_manager
Open

Refactor network manager#528
MykolaSuperman wants to merge 6 commits intoaosedge:feature_release_9.1from
MykolaSuperman:refactor_network_manager

Conversation

@MykolaSuperman
Copy link

No description provided.

@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch from 529ffc6 to f022560 Compare March 6, 2026 10:21
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 92.75905% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.20%. Comparing base (fdbddb4) to head (550fa1e).

Files with missing lines Patch % Lines
src/core/sm/networkmanager/networkmanager.cpp 80.00% 56 Missing ⚠️
...rc/core/sm/networkmanager/tests/networkmanager.cpp 99.51% 2 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##           feature_release_9.1     #528      +/-   ##
=======================================================
- Coverage                85.27%   85.20%   -0.08%     
=======================================================
  Files                      311      309       -2     
  Lines                    27931    27835      -96     
  Branches                  3762     3732      -30     
=======================================================
- Hits                     23818    23716     -102     
- Misses                    4113     4119       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch 7 times, most recently from b90964f to 1aede72 Compare March 9, 2026 11:03
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2025 EPAM Systems, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026

/**
* Network provider interface (SM -> CM network service).
*/
class NetworkProviderItf {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit test for this interface and network.md file that describes the purpose if this interfae.

* SPDX-License-Identifier: Apache-2.0
*/

#ifndef AOS_CORE_COMMON_NETWORK_ITF_NETWORKPROVIDER_HPP_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is part of networkmanager then it should be in networkmanager folder and networkmanager namespace.


void Balancer::Init(InstanceManager& instanceManager, imagemanager::ItemInfoProviderItf& itemInfoProvider,
oci::OCISpecItf& ociSpec, NodeManager& nodeManager, MonitoringProviderItf& monitorProvider,
InstanceRunnerItf& runner, NetworkManager& networkManager)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do launcher unit tests work after these changes?

StaticString<cSubnetLen> mSubnet;
StaticString<cIPLen> mIP;
uint64_t mVlanID {};
struct NetworkServiceData {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have services any more. Rename to UpdateItemNetworkParameters.

Shortcut parameters to params:

NetworkParams
InstanceNetworkParams
UpdateItemNetworkParams

Can InstanceNetworkParams have the following fields:

struct InstanceNetworkParams {
    NetworkParams mNetworkParams;
    StaticArray<StaticString<cIPLen>, cMaxNumDNSServers> mDNSServers;
    StaticArray<FirewallRule, cMaxNumFirewallRules>      mFirewallRules;
   ...

?

* @param networks network parameters.
* @return Error.
* @param period traffic period.
* @return Error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period at the end

LOG_DBG() << "Update networks";
LOG_DBG() << "Get system traffic";

return AOS_ERROR_WRAP(mNetMonitor->GetSystemTraffic(inputTraffic, outputTraffic));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not put operators in macro. It reduces readability.

{
LOG_DBG() << "Get instance traffic" << Log::Field("instanceID", instanceID);

return AOS_ERROR_WRAP(mNetMonitor->GetInstanceTraffic(instanceID, inputTraffic, outputTraffic));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

*/
Error SetTrafficPeriod(TrafficPeriod period) override;

Error PrepareInstanceNetwork(const String& instanceID, const String& networkID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment public API

Error PrepareInstanceNetwork(const String& instanceID, const String& networkID,
const InstanceNetworkParameters& instanceNetworkParameters, const NetworkServiceData& serviceData) override;

Error CleanupInstanceNetwork(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch from 1c36656 to 3c0f471 Compare March 18, 2026 13:44
- NetworkParameters -> NetworkParams
- InstanceNetworkParameters -> InstanceNetworkAllocation
- UpdateNetworkParameters -> UpdateItemNetworkParams (NetworkServiceData)

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch 4 times, most recently from c3523c3 to 3d896e4 Compare March 18, 2026 14:27
/**
* Instance network runtime parameters for Start (not stored in DB).
*/
struct InstanceNetworkRuntimeParameters {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InstanceNetworkRuntimeParams

@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch 2 times, most recently from 57f1298 to 1a1bfd6 Compare March 20, 2026 12:35
Mykola Solianko added 5 commits March 20, 2026 16:23
Add network provider interface for SM to communicate with CM
for network allocation and release operations.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
- Remove CM networkmanager module (moved to SM-driven model)
- Update CM launcher to remove network management
- Update smcontroller to use NetworkProviderItf

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
Add types.hpp with:
- InstanceNetworkConfig: network config for Create (stored in DB)
- InstanceNetworkRuntimeParameters: runtime paths for Start

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
Replace PrepareInstanceNetwork/CleanupInstanceNetwork with 4 methods:
- CreateInstanceNetwork: CM allocation + DB (idempotent)
- StartInstanceNetwork: physical setup from cached params
- StopInstanceNetwork: physical cleanup, clears bridge/VLAN if last
- ReleaseInstanceNetwork: DB + CM release, requires Stop first

Key changes:
- InstanceNetworkInfo extended with InstanceNetworkConfig and
  InstanceNetworkAllocation for offline Start after reboot
- Init no longer removes instance network info from DB
- Init no longer creates bridge/VLAN (deferred to Start)
- EnsureNodeNetwork split into logical (CM) and physical parts
- Thread-safe access to mInstanceNetworkInfos cache
- networkID validation in Start/Stop/Release

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
- Update all NM tests to use Create+Start / Stop+Release
- Add tests: networkID mismatch, Release without Stop, idempotent Create
- Update NetworkManagerMock with 4 methods
- Add NetworkProviderMock
- Update launcher tests for new API

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
@MykolaSuperman MykolaSuperman force-pushed the refactor_network_manager branch from 1a1bfd6 to 550fa1e Compare March 20, 2026 14:24
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants