144 lines
4.9 KiB
Diff
144 lines
4.9 KiB
Diff
|
|
From 8cd9d4dd70ec0601490d0b1fd997ba4e05aff420 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Yuhang Wei <weiyuhang3@huawei.com>
|
||
|
|
Date: Tue, 16 Jan 2024 17:25:17 +0800
|
||
|
|
Subject: [PATCH 03/13] Remove cleanup method and related code
|
||
|
|
|
||
|
|
Signed-off-by: Yuhang Wei <weiyuhang3@huawei.com>
|
||
|
|
---
|
||
|
|
KubeOS-Rust/agent/src/rpc/agent.rs | 3 ---
|
||
|
|
KubeOS-Rust/agent/src/rpc/agent_impl.rs | 14 +---------
|
||
|
|
KubeOS-Rust/cli/src/method/cleanup.rs | 29 ---------------------
|
||
|
|
KubeOS-Rust/cli/src/method/mod.rs | 1 -
|
||
|
|
KubeOS-Rust/manager/src/api/agent_status.rs | 11 +-------
|
||
|
|
5 files changed, 2 insertions(+), 56 deletions(-)
|
||
|
|
delete mode 100644 KubeOS-Rust/cli/src/method/cleanup.rs
|
||
|
|
|
||
|
|
diff --git a/KubeOS-Rust/agent/src/rpc/agent.rs b/KubeOS-Rust/agent/src/rpc/agent.rs
|
||
|
|
index 13775af..2496bfb 100644
|
||
|
|
--- a/KubeOS-Rust/agent/src/rpc/agent.rs
|
||
|
|
+++ b/KubeOS-Rust/agent/src/rpc/agent.rs
|
||
|
|
@@ -22,9 +22,6 @@ pub trait Agent {
|
||
|
|
#[rpc(name = "upgrade")]
|
||
|
|
fn upgrade(&self) -> RpcResult<Response>;
|
||
|
|
|
||
|
|
- #[rpc(name = "cleanup")]
|
||
|
|
- fn cleanup(&self) -> RpcResult<Response>;
|
||
|
|
-
|
||
|
|
#[rpc(name = "configure")]
|
||
|
|
fn configure(&self, req: ConfigureRequest) -> RpcResult<Response>;
|
||
|
|
|
||
|
|
diff --git a/KubeOS-Rust/agent/src/rpc/agent_impl.rs b/KubeOS-Rust/agent/src/rpc/agent_impl.rs
|
||
|
|
index 7101d0d..bc1eabd 100644
|
||
|
|
--- a/KubeOS-Rust/agent/src/rpc/agent_impl.rs
|
||
|
|
+++ b/KubeOS-Rust/agent/src/rpc/agent_impl.rs
|
||
|
|
@@ -17,7 +17,7 @@ use log::{debug, error, info};
|
||
|
|
use manager::{
|
||
|
|
api::{AgentStatus, ConfigureRequest, ImageType, Response, UpgradeRequest},
|
||
|
|
sys_mgmt::{CtrImageHandler, DiskImageHandler, DockerImageHandler, CONFIG_TEMPLATE, DEFAULT_GRUBENV_PATH},
|
||
|
|
- utils::{clean_env, get_partition_info, switch_boot_menuentry, PreparePath, RealCommandExecutor},
|
||
|
|
+ utils::{get_partition_info, switch_boot_menuentry, RealCommandExecutor},
|
||
|
|
};
|
||
|
|
use nix::{sys::reboot::RebootMode, unistd::sync};
|
||
|
|
|
||
|
|
@@ -40,10 +40,6 @@ impl Agent for AgentImpl {
|
||
|
|
RpcFunction::call(|| self.upgrade_impl())
|
||
|
|
}
|
||
|
|
|
||
|
|
- fn cleanup(&self) -> RpcResult<Response> {
|
||
|
|
- RpcFunction::call(|| self.cleanup_impl())
|
||
|
|
- }
|
||
|
|
-
|
||
|
|
fn configure(&self, req: ConfigureRequest) -> RpcResult<Response> {
|
||
|
|
RpcFunction::call(|| self.configure_impl(req))
|
||
|
|
}
|
||
|
|
@@ -94,14 +90,6 @@ impl AgentImpl {
|
||
|
|
Ok(Response { status: AgentStatus::Upgraded })
|
||
|
|
}
|
||
|
|
|
||
|
|
- pub fn cleanup_impl(&self) -> Result<Response> {
|
||
|
|
- let _lock = self.mutex.lock().unwrap();
|
||
|
|
- info!("Start to cleanup");
|
||
|
|
- let paths = PreparePath::default();
|
||
|
|
- clean_env(paths.update_path, paths.mount_path, paths.image_path)?;
|
||
|
|
- Ok(Response { status: AgentStatus::CleanedUp })
|
||
|
|
- }
|
||
|
|
-
|
||
|
|
pub fn configure_impl(&self, mut req: ConfigureRequest) -> Result<Response> {
|
||
|
|
let _lock = self.mutex.lock().unwrap();
|
||
|
|
debug!("Received a 'configure' request: {:?}", req);
|
||
|
|
diff --git a/KubeOS-Rust/cli/src/method/cleanup.rs b/KubeOS-Rust/cli/src/method/cleanup.rs
|
||
|
|
deleted file mode 100644
|
||
|
|
index d1d7dbe..0000000
|
||
|
|
--- a/KubeOS-Rust/cli/src/method/cleanup.rs
|
||
|
|
+++ /dev/null
|
||
|
|
@@ -1,29 +0,0 @@
|
||
|
|
-/*
|
||
|
|
- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
|
||
|
|
- * KubeOS is licensed under the Mulan PSL v2.
|
||
|
|
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||
|
|
- * You may obtain a copy of Mulan PSL v2 at:
|
||
|
|
- * http://license.coscl.org.cn/MulanPSL2
|
||
|
|
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||
|
|
- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||
|
|
- * PURPOSE.
|
||
|
|
- * See the Mulan PSL v2 for more details.
|
||
|
|
- */
|
||
|
|
-
|
||
|
|
-use kubeos_manager::api;
|
||
|
|
-use serde_json::value::RawValue;
|
||
|
|
-
|
||
|
|
-use crate::method::callable_method::RpcMethod;
|
||
|
|
-
|
||
|
|
-#[derive(Default)]
|
||
|
|
-pub struct CleanupMethod {}
|
||
|
|
-
|
||
|
|
-impl RpcMethod for CleanupMethod {
|
||
|
|
- type Response = api::Response;
|
||
|
|
- fn command_name(&self) -> &'static str {
|
||
|
|
- "cleanup"
|
||
|
|
- }
|
||
|
|
- fn command_params(&self) -> Vec<Box<RawValue>> {
|
||
|
|
- vec![]
|
||
|
|
- }
|
||
|
|
-}
|
||
|
|
diff --git a/KubeOS-Rust/cli/src/method/mod.rs b/KubeOS-Rust/cli/src/method/mod.rs
|
||
|
|
index b04b0fd..e1f38bc 100644
|
||
|
|
--- a/KubeOS-Rust/cli/src/method/mod.rs
|
||
|
|
+++ b/KubeOS-Rust/cli/src/method/mod.rs
|
||
|
|
@@ -11,7 +11,6 @@
|
||
|
|
*/
|
||
|
|
|
||
|
|
pub mod callable_method;
|
||
|
|
-pub mod cleanup;
|
||
|
|
pub mod configure;
|
||
|
|
pub mod prepare_upgrade;
|
||
|
|
pub mod request;
|
||
|
|
diff --git a/KubeOS-Rust/manager/src/api/agent_status.rs b/KubeOS-Rust/manager/src/api/agent_status.rs
|
||
|
|
index e466a50..bb16e6b 100644
|
||
|
|
--- a/KubeOS-Rust/manager/src/api/agent_status.rs
|
||
|
|
+++ b/KubeOS-Rust/manager/src/api/agent_status.rs
|
||
|
|
@@ -12,19 +12,10 @@
|
||
|
|
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
-#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||
|
|
+#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
|
||
|
|
pub enum AgentStatus {
|
||
|
|
- Unknown,
|
||
|
|
- NotApplied,
|
||
|
|
UpgradeReady,
|
||
|
|
Upgraded,
|
||
|
|
Rollbacked,
|
||
|
|
Configured,
|
||
|
|
- CleanedUp,
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-impl Default for AgentStatus {
|
||
|
|
- fn default() -> Self {
|
||
|
|
- Self::Unknown
|
||
|
|
- }
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.34.1
|
||
|
|
|