From 7962aa645b63db9da0bcf49646e20a5b86131677 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Tue, 3 Feb 2026 13:27:37 +0200 Subject: [PATCH] sm: launcher: runtimes: fix rootfs Signed-off-by: Mykhailo Lohvynenko --- src/sm/launcher/runtimes/rootfs/rootfs.cpp | 21 ++++++++++++++++++--- src/sm/launcher/runtimes/rootfs/rootfs.hpp | 2 -- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/sm/launcher/runtimes/rootfs/rootfs.cpp b/src/sm/launcher/runtimes/rootfs/rootfs.cpp index ef071c84..31a8db06 100644 --- a/src/sm/launcher/runtimes/rootfs/rootfs.cpp +++ b/src/sm/launcher/runtimes/rootfs/rootfs.cpp @@ -133,6 +133,15 @@ Error RootfsRuntime::StartInstance(const InstanceInfo& instance, InstanceStatus& return ErrorEnum::eNone; } + if (static_cast(mPendingInstance) == static_cast(instance) + && instance.mManifestDigest == mPendingInstance.mManifestDigest) { + status.mState = InstanceStateEnum::eActivating; + + mStatusReceiver->OnInstancesStatusesReceived(Array {&status, 1}); + + return ErrorEnum::eNone; + } + mStatusReceiver->OnInstancesStatusesReceived(Array {&status, 1}); Error err = ErrorEnum::eNone; @@ -197,11 +206,13 @@ Error RootfsRuntime::GetInstanceMonitoringData( void RootfsRuntime::RunHealthCheck(std::unique_ptr status) { - LOG_DBG() << "Start health check for rootfs update" << Log::Field("version", mPendingVersion); + LOG_DBG() << "Start health check for rootfs update" << Log::Field("version", mPendingInstance.mVersion); ActionType nextAction = ActionTypeEnum::eDoApply; if (auto err = mUpdateChecker.Check(); !err.IsNone()) { + LOG_ERR() << "Health check for rootfs update failed" << err; + status->mState = InstanceStateEnum::eFailed; status->mError = AOS_ERROR_WRAP(err); @@ -209,13 +220,14 @@ void RootfsRuntime::RunHealthCheck(std::unique_ptr status) } if (auto err = StoreAction(nextAction); !err.IsNone()) { + LOG_ERR() << "Failed to store rootfs update action" << err; + status->mState = InstanceStateEnum::eFailed; status->mError = AOS_ERROR_WRAP(err); } if (auto err = mRebooter.Reboot(); !err.IsNone()) { - status->mState = InstanceStateEnum::eFailed; - status->mError = AOS_ERROR_WRAP(err); + LOG_WRN() << "Failed to reboot system after rootfs update health check" << err; } mStatusReceiver->OnInstancesStatusesReceived(Array {status.get(), 1}); @@ -427,6 +439,7 @@ Error RootfsRuntime::SaveInstanceInfo(const InstanceInfo& instance, const std::f try { json->set("itemId", instance.mItemID.CStr()); json->set("subjectId", instance.mSubjectID.CStr()); + json->set("instance", instance.mInstance); json->set("manifestDigest", instance.mManifestDigest.CStr()); json->set("type", instance.mType.ToString().CStr()); json->set("version", instance.mVersion.CStr()); @@ -464,6 +477,8 @@ Error RootfsRuntime::LoadInstanceInfo(const std::filesystem::path& path, Instanc err = instance.mSubjectID.Assign(jsonObject.GetValue("subjectId").c_str()); AOS_ERROR_CHECK_AND_THROW(err); + instance.mInstance = jsonObject.GetValue("instance"); + err = instance.mManifestDigest.Assign(jsonObject.GetValue("manifestDigest").c_str()); AOS_ERROR_CHECK_AND_THROW(err); diff --git a/src/sm/launcher/runtimes/rootfs/rootfs.hpp b/src/sm/launcher/runtimes/rootfs/rootfs.hpp index 04459bfb..664d8451 100644 --- a/src/sm/launcher/runtimes/rootfs/rootfs.hpp +++ b/src/sm/launcher/runtimes/rootfs/rootfs.hpp @@ -180,10 +180,8 @@ class RootfsRuntime : public RuntimeItf { mutable std::mutex mMutex; std::optional mHealthCheckThread; InstanceInfo mCurrentInstance {}; - StaticString mCurrentVersion; RuntimeInfo mRuntimeInfo; InstanceInfo mPendingInstance; - StaticString mPendingVersion; }; } // namespace aos::sm::launcher