-
Notifications
You must be signed in to change notification settings - Fork 7
cm: launcher: rank scheduling errors in balancer #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature_release_9.1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * Copyright (C) 2025 EPAM Systems, Inc. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #ifndef AOS_CORE_CM_LAUNCHER_RANKEDERROR_HPP_ | ||
| #define AOS_CORE_CM_LAUNCHER_RANKEDERROR_HPP_ | ||
|
|
||
| #include <core/common/tools/error.hpp> | ||
|
|
||
| namespace aos::cm::launcher { | ||
|
|
||
| /** | ||
| * Error container with explicit error rank. | ||
| */ | ||
| struct RankedError { | ||
| static constexpr int cLowErrorRank = 1; | ||
|
Check warning on line 18 in src/core/cm/launcher/rankederror.hpp
|
||
| static constexpr int cHighErrorRank = 2; | ||
|
Check warning on line 19 in src/core/cm/launcher/rankederror.hpp
|
||
| static constexpr int cNoErrorRank = 3; | ||
|
Check warning on line 20 in src/core/cm/launcher/rankederror.hpp
|
||
|
|
||
| // cppcheck-suppress noExplicitConstructor | ||
| RankedError(const Error& error = ErrorEnum::eNone, int errorRank = cNoErrorRank) | ||
|
Check warning on line 23 in src/core/cm/launcher/rankederror.hpp
|
||
| : mError(error) | ||
| , mErrorRank(errorRank) | ||
| { | ||
| } | ||
|
|
||
| bool IsNone() const { return mError.IsNone(); } | ||
|
|
||
| /** | ||
| * Selects error with higher rank. | ||
| * | ||
| * If one of errors is none, returns the other one. | ||
| */ | ||
| static RankedError SelectHigherRankedError(const RankedError& left, const RankedError& right) | ||
| { | ||
| if (left.IsNone()) { | ||
| return right; | ||
| } | ||
|
|
||
| if (right.IsNone()) { | ||
| return left; | ||
| } | ||
|
|
||
| return left.mErrorRank >= right.mErrorRank ? left : right; | ||
| } | ||
|
|
||
| Error mError; | ||
| int mErrorRank {}; | ||
|
Check warning on line 50 in src/core/cm/launcher/rankederror.hpp
|
||
| }; | ||
|
|
||
| /** | ||
| * Container that holds value and ranked error. | ||
| * | ||
| * @tparam T value type. | ||
| */ | ||
| template <typename T> | ||
| struct RetWithRankedError { | ||
| // cppcheck-suppress noExplicitConstructor | ||
| /** | ||
| * Constructs return value with error instance and rank. | ||
| * | ||
| * @param value return value. | ||
| * @param error return error. | ||
| * @param errorRank return error rank. | ||
| */ | ||
| RetWithRankedError(const T& value, const Error& error = ErrorEnum::eNone, int errorRank = RankedError::cNoErrorRank) | ||
|
Check warning on line 68 in src/core/cm/launcher/rankederror.hpp
|
||
| : mValue(value) | ||
| , mRankedError(error, errorRank) | ||
| { | ||
| } | ||
|
|
||
| // cppcheck-suppress noExplicitConstructor | ||
| /** | ||
| * Constructs return value with error instance and rank. | ||
| * | ||
| * @param value return value. | ||
| * @param error return error. | ||
| * @param errorRank return error rank. | ||
| */ | ||
| RetWithRankedError(T&& value, const Error& error = ErrorEnum::eNone, int errorRank = RankedError::cNoErrorRank) | ||
|
Check failure on line 82 in src/core/cm/launcher/rankederror.hpp
|
||
| : mValue(Move(value)) | ||
| , mRankedError(error, errorRank) | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * Comparison operators. | ||
| */ | ||
| bool operator==(const RetWithRankedError<T>& other) const | ||
|
Check warning on line 91 in src/core/cm/launcher/rankederror.hpp
|
||
| { | ||
| return mValue == other.mValue && mRankedError.mError == other.mRankedError.mError | ||
| && mRankedError.mErrorRank == other.mRankedError.mErrorRank; | ||
| } | ||
| bool operator!=(const RetWithRankedError<T>& other) const { return !(*this == other); } | ||
|
Check warning on line 96 in src/core/cm/launcher/rankederror.hpp
|
||
|
|
||
| /** | ||
| * Holds returned value. | ||
| */ | ||
| T mValue; | ||
|
|
||
| /** | ||
| * Holds returned ranked error. | ||
| */ | ||
| RankedError mRankedError; | ||
| }; | ||
|
|
||
| } // namespace aos::cm::launcher | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still do not understand why we need ranked error. Instance scheduling should fail on first error.
In our case, if there are different manifests for different arch. First we should check if there are nodes matches item arches. If not, return error - no suitable node architecture found. Then we try to schedule according to resource, if there are not enough resources available, return resource error.