Skip to content

Commit

Permalink
use cmd for cni
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Nov 26, 2023
1 parent a17cfe7 commit c3a4ab7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/skatelet/cni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn lock<T>(ifname: &str, cb: &dyn Fn() -> Result<T, Box<dyn Error>>) -> Result<T
pub fn cni() {
match Cni::load() {
Cni::Add { container_id, ifname, netns, path, config } => {
// touch lock file at DEFAULT_CONF_PATH/<interface>/lock
// lock file at DEFAULT_CONF_PATH/<interface>/lock

match lock(&ifname, &|| {
// read file at DEFAULT_CONF_PATH/<interface>/addnhosts
Expand Down
11 changes: 5 additions & 6 deletions src/skatelet/skatelet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ enum Commands {
Apply(ApplyArgs),
System(SystemArgs),
Remove(RemoveArgs),
Cni,
}

pub async fn skatelet() -> Result<(), Box<dyn Error>> {
// we're being called as a CNI plugin
match var("CNI_COMMAND") {
Ok(_) => cni(),
_ => {}
}

let args = Cli::parse();
match args.command {
Commands::Apply(args) => apply::apply(args),
Commands::System(args) => system(args).await,
Commands::Remove(args) => remove(args),
Commands::Cni => {
cni();
Ok(())
},
// _ => Ok(())
}
}

0 comments on commit c3a4ab7

Please sign in to comment.