Skip to content

sm: launcher: rename update instances to run instances#535

Open
mlohvynenko wants to merge 1 commit intoaosedge:feature_release_9.1from
mlohvynenko:feature_sm_itf
Open

sm: launcher: rename update instances to run instances#535
mlohvynenko wants to merge 1 commit intoaosedge:feature_release_9.1from
mlohvynenko:feature_sm_itf

Conversation

@mlohvynenko
Copy link
Member

This patch updated launcher interface to handle
run instances instead of update instances:

  • a list of desired run instances is passed to the launcher instead stop and start instances lists;
  • the launcher is responsible for stopping and starting instances based on the provided list of desired run instances;
  • instances are started based on the desired run instances priorities.

This patch updated launcher interface to handle
run instances instead of update instances:
- a list of desired run instances is passed to the launcher
instead stop and start instances lists;
- the launcher is responsible for stopping and starting instances
based on the provided list of desired run instances;
- instances are started based on the desired
run instances priorities.

Signed-off-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 91.07143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.25%. Comparing base (79d1152) to head (98c3fc6).

Files with missing lines Patch % Lines
src/core/sm/launcher/launcher.cpp 88.88% 5 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           feature_release_9.1     #535   +/-   ##
====================================================
  Coverage                85.25%   85.25%           
====================================================
  Files                      311      311           
  Lines                    27938    27964   +26     
  Branches                  3762     3767    +5     
====================================================
+ Hits                     23819    23842   +23     
- Misses                    4119     4122    +3     

☔ 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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Service Manager launcher API from “update instances (stop/start lists)” to “run instances (desired set)”, moving stop/start decision-making and start ordering (by priority) into the launcher implementation.

Changes:

  • Renamed launcher interface method from UpdateInstances(...) to RunInstances(instances).
  • Updated SM launcher implementation to derive stop/start sets internally and to sort desired instances by priority before starting.
  • Refactored and renamed SM launcher tests/mocks to match the new API.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/core/sm/tests/mocks/launchermock.hpp Updates mock interface to RunInstances(...).
src/core/sm/launcher/tests/launcher.cpp Renames tests and switches calls from UpdateInstances to RunInstances.
src/core/sm/launcher/launcher.hpp Updates public API + internal helpers/state to support “desired set” flow.
src/core/sm/launcher/launcher.cpp Implements RunInstances, adds sorting and internal stop-list derivation.
src/core/sm/launcher/itf/launcher.hpp Updates launcher interface contract to RunInstances(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +166
// Sort instances by priority and instance ID to have deterministic order of start/stop in case of same
// priority.
mStartInstances.Sort(
[](const InstanceInfo& a, const InstanceInfo& b) {
return a.mPriority > b.mPriority || (a.mPriority == b.mPriority && a.mInstance < b.mInstance);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The tie-breaker in the start-instances sort only compares mInstance, which is not unique across different mItemID/mSubjectID/mType. That means instances with the same priority and same mInstance can still start in a non-deterministic order (despite the comment). Consider using static_cast<const InstanceIdent&>(a) < static_cast<const InstanceIdent&>(b) (or a full ident comparison) as the secondary key to guarantee deterministic ordering.

Suggested change
// Sort instances by priority and instance ID to have deterministic order of start/stop in case of same
// priority.
mStartInstances.Sort(
[](const InstanceInfo& a, const InstanceInfo& b) {
return a.mPriority > b.mPriority || (a.mPriority == b.mPriority && a.mInstance < b.mInstance);
// Sort instances by priority and full instance ident to have deterministic order of start/stop
// in case of same priority.
mStartInstances.Sort(
[](const InstanceInfo& a, const InstanceInfo& b) {
if (a.mPriority != b.mPriority) {
return a.mPriority > b.mPriority;
}
// Use full InstanceIdent comparison as tie-breaker to guarantee deterministic ordering.
return static_cast<const InstanceIdent&>(a) < static_cast<const InstanceIdent&>(b);

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +169
// Sort instances by priority and instance ID to have deterministic order of start/stop in case of same
// priority.
mStartInstances.Sort(
[](const InstanceInfo& a, const InstanceInfo& b) {
return a.mPriority > b.mPriority || (a.mPriority == b.mPriority && a.mInstance < b.mInstance);
},
*sortTmpValue);
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

RunInstances() now sorts mStartInstances by priority (and a tie-breaker) before starting instances, but the updated test suite doesn’t appear to assert start-call ordering for different priorities (or tie cases). Adding a unit test that expects StartInstance to be invoked in descending priority order (and deterministically for ties) would protect this new behavior.

Copilot uses AI. Check for mistakes.
Comment on lines 530 to 534
return ErrorEnum::eNone;
}));

err = mLauncher.UpdateInstances(cStopInstances, cStartInstances);
err = mLauncher.RunInstances(cStartInstances);
ASSERT_TRUE(err.IsNone()) << tests::utils::ErrorToStr(err);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

After changing the call to mLauncher.RunInstances(cStartInstances), the cStopInstances variable defined earlier in this test is no longer referenced. Please remove that unused variable to avoid unused-variable warnings (which may be treated as errors in CI).

Copilot uses AI. Check for mistakes.
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