Skip to content

Commit

Permalink
change bootstrap to include booting nodes in light mode
Browse files Browse the repository at this point in the history
Signed-off-by: Ashraf Fouda <[email protected]>
  • Loading branch information
ashraffouda committed Aug 11, 2024
1 parent 88ae10c commit a53014a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions bootstrap/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions bootstrap/bootstrap/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion bootstrap/bootstrap/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn version() -> Result<Version> {
Some(input) => match input {
Some(input) => match input.as_ref() {
"v3" => Version::V3,
"v4" => Version::V4,
m => {
bail!("unknown version: {}", m);
}
Expand All @@ -83,6 +84,7 @@ pub struct Config {
pub debug: bool,
pub runmode: RunMode,
pub version: Version,
pub light: bool,
}

impl Config {
Expand All @@ -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() {
Expand All @@ -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,
})
}
}

0 comments on commit a53014a

Please sign in to comment.