Skip to content
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

docs for network light #2397

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
72 changes: 54 additions & 18 deletions bootstrap/bootstrap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
8 changes: 6 additions & 2 deletions bootstrap/bootstrap/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ 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 listname = runmode.clone();
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
18 changes: 17 additions & 1 deletion bootstrap/bootstrap/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@ fn version() -> Result<Version> {
Ok(ver)
}

fn light() -> Result<bool> {
let params = kparams::params()?;
if params.contains_key("light") {
return Ok(true);
}
Ok(false)
}

pub struct Config {
pub stage: u32,
pub debug: bool,
pub runmode: RunMode,
pub version: Version,
pub light: bool,
}

impl Config {
Expand All @@ -105,6 +114,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"),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The light flag same as the runmode should be parsed from the kernel cmdline arguments not from the bootstrap command arguments.

.get_matches();

let stage: u32 = match matches.value_of("stage").unwrap().parse() {
Expand All @@ -119,10 +134,11 @@ impl Config {
}

Ok(Config {
stage: stage,
stage,
debug: matches.occurrences_of("debug") > 0,
runmode: runmode()?,
version: version()?,
light: light()?,
})
}
}
5 changes: 3 additions & 2 deletions bootstrap/bootstrap/src/kparams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ mod tests {

#[test]
fn test_parse() -> Result<(), Error> {
let input: &str = "initrd=initramfs-linux.img root=UUID=10f9e7bb-ba63-4fbd-a95e-c78b5496cfbe rootflags=subvol=root rw b43.allhwsupport=1";
let input: &str = "initrd=initramfs-linux.img light root=UUID=10f9e7bb-ba63-4fbd-a95e-c78b5496cfbe rootflags=subvol=root rw b43.allhwsupport=1";
let result = parse(input.as_bytes())?;
assert_eq!(result.len(), 5);
assert_eq!(result.len(), 6);
assert_eq!(result["rw"], None);
assert_eq!(result.contains_key("light"), true);
assert_eq!(result["rootflags"], Some(String::from("subvol=root")));
Ok(())
}
Expand Down
12 changes: 6 additions & 6 deletions cmds/internet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (

"github.com/threefoldtech/zos/pkg/app"
"github.com/threefoldtech/zos/pkg/environment"
"github.com/threefoldtech/zos/pkg/network/bootstrap"
"github.com/threefoldtech/zos/pkg/network/bridge"
"github.com/threefoldtech/zos/pkg/network/dhcp"
"github.com/threefoldtech/zos/pkg/network/ifaceutil"
"github.com/threefoldtech/zos/pkg/network/options"
"github.com/threefoldtech/zos/pkg/network/types"
"github.com/threefoldtech/zos/pkg/netlight/bootstrap"
"github.com/threefoldtech/zos/pkg/netlight/bridge"
"github.com/threefoldtech/zos/pkg/netlight/dhcp"
"github.com/threefoldtech/zos/pkg/netlight/ifaceutil"
"github.com/threefoldtech/zos/pkg/netlight/options"
"github.com/threefoldtech/zos/pkg/netlight/types"
"github.com/threefoldtech/zos/pkg/zinit"

"github.com/threefoldtech/zos/pkg/version"
Expand Down
84 changes: 0 additions & 84 deletions cmds/modules/gateway/main.go

This file was deleted.

Loading
Loading