From a53014a3055acd25d53497ee1d400e301c3a93c8 Mon Sep 17 00:00:00 2001 From: Ashraf Fouda Date: Sun, 11 Aug 2024 16:33:45 +0300 Subject: [PATCH] change bootstrap to include booting nodes in light mode Signed-off-by: Ashraf Fouda --- .github/workflows/publish.yaml | 6 +++--- bootstrap/bootstrap/README.md | 4 ++-- bootstrap/bootstrap/src/bootstrap.rs | 11 ++++++++--- bootstrap/bootstrap/src/config.rs | 11 ++++++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 67d36eaf5..268377521 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -77,8 +77,8 @@ jobs: token: ${{ secrets.HUB_JWT }} action: tag user: tf-autobuilder - name: ${{ steps.tag.outputs.reference }}/zos.flist - target: tf-autobuilder/zos:${{ steps.version.outputs.version }}.flist + name: ${{ steps.tag.outputs.reference }}/zos-light.flist + target: tf-autobuilder/zos-light:${{ steps.version.outputs.version }}.flist # only for main branch (devnet) # this basically releases this build to devnet @@ -89,5 +89,5 @@ jobs: token: ${{ secrets.HUB_JWT }} action: crosstag user: tf-zos - name: development + name: development-zos-light target: tf-autobuilder/${{ steps.tag.outputs.reference }} diff --git a/bootstrap/bootstrap/README.md b/bootstrap/bootstrap/README.md index 5374ba3a3..c2bb27e90 100644 --- a/bootstrap/bootstrap/README.md +++ b/bootstrap/bootstrap/README.md @@ -17,7 +17,7 @@ will do a multiple stage bootstrap. Currently this is only two stages: ## How to works - Bootstrap is used by [0-initramfs](https://github.com/threefoldtech/0-initramfs/blob/development-zos-v3/packages/modules.sh) to basically add `internet` and `bootstrap` services to the base image -- After internet service is fully started, bootstrap will start to download flists needed to for zos node to work properly +- After internet service is fully started, bootstrap will start to download flists needed for zos node to work properly - As described above bootstrap run in two stages: - The first stage is used to update bootstrap itself, and it is done like that to avoid re-building the image if we only changed the bootstrap code. this update is basically done from `tf-autobuilder` repo in the [hub/tf-autobuilder](https://hub.grid.tf/tf-autobuilder) and download the latest bootstrap flist - - For the second stage bootstrap will download the flists for that env. bootstrap cares about `runmode` argument that we pass during the start of the node. for example if we passed `runmode=dev` it will get the the tag `development` under [hub/tf-zos](https://hub.grid.tf/tf-zos) each tag is linked to a sub-directory where all flists for this env exists to be downloaded and installed on the node + - For the second stage bootstrap will download the flists for that env. bootstrap cares about `runmode` argument that we pass during the start of the node. for example if we passed `runmode=dev-light` it will get the the tag `development-light` under [hub/tf-zos](https://hub.grid.tf/tf-zos) each tag is linked to a sub-directory where all flists for this env exists to be downloaded and installed on the node diff --git a/bootstrap/bootstrap/src/bootstrap.rs b/bootstrap/bootstrap/src/bootstrap.rs index 5e1c85ec8..413a30d4e 100644 --- a/bootstrap/bootstrap/src/bootstrap.rs +++ b/bootstrap/bootstrap/src/bootstrap.rs @@ -14,6 +14,7 @@ use retry; const ZOS_REPO: &str = "tf-zos"; const BIN_REPO_V2: &str = "tf-zos-bins"; const BIN_REPO_V3: &str = "tf-zos-v3-bins"; +const BIN_REPO_V4: &str = "tf-zos-v4-bins"; const FLIST_INFO_FILE: &str = "/tmp/flist.info"; const FLIST_NAME_FILE: &str = "/tmp/flist.name"; @@ -115,12 +116,16 @@ fn update_bootstrap() -> Result<()> { pub fn install(cfg: &config::Config) -> Result<()> { let repo = Repo::new(ZOS_REPO); - let runmode = cfg.runmode.to_string(); - // we need to list all taglinks inside the repo + let mut runmode = cfg.runmode.to_string(); + let mut listname = runmode; + if cfg.light { + listname = format!("{}-light", runmode) + } + // we need to list all taglinks let mut tag = None; for list in repo.list()? { - if list.kind == Kind::TagLink && list.name == runmode { + if list.kind == Kind::TagLink && list.name == listname { tag = Some(list); break; } diff --git a/bootstrap/bootstrap/src/config.rs b/bootstrap/bootstrap/src/config.rs index 1a918fc23..70cbbcb65 100644 --- a/bootstrap/bootstrap/src/config.rs +++ b/bootstrap/bootstrap/src/config.rs @@ -64,6 +64,7 @@ fn version() -> Result { Some(input) => match input { Some(input) => match input.as_ref() { "v3" => Version::V3, + "v4" => Version::V4, m => { bail!("unknown version: {}", m); } @@ -83,6 +84,7 @@ pub struct Config { pub debug: bool, pub runmode: RunMode, pub version: Version, + pub light: bool, } impl Config { @@ -105,6 +107,12 @@ impl Config { .takes_value(false) .help("run in debug mode, will use the bootstrap:development.flist"), ) + .arg( + Arg::with_name("light") + .short("l") + .takes_value(false) + .help("run in light mode, will use the bootstrap:development.flist"), + ) .get_matches(); let stage: u32 = match matches.value_of("stage").unwrap().parse() { @@ -119,10 +127,11 @@ impl Config { } Ok(Config { - stage: stage, + stage, debug: matches.occurrences_of("debug") > 0, runmode: runmode()?, version: version()?, + light: matches.occurrences_of("light") > 0, }) } }