Skip to content

Commit

Permalink
modify provision.sh to accept grpc port (#708)
Browse files Browse the repository at this point in the history
Modify provision.sh to accept a custom GRPC port using -p or
--grpc-port.
Fix a couple of return statements using the wrong error

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
  • Loading branch information
aryan9600 committed May 26, 2023
1 parent 22034dc commit f421319
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
27 changes: 21 additions & 6 deletions hack/scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ do_all_flintlock() {
local bridge_name="$4"
local insecure="$5"
local config_file="$6"
local port="$7"

install_flintlockd "$version"

Expand All @@ -314,10 +315,13 @@ do_all_flintlock() {
if [[ -z "$address" ]]; then
address=$(lookup_address "$parent_iface")
fi
write_flintlockd_config "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file"
if [[ -z "$port" ]]; then
port="9090"
fi
write_flintlockd_config "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file" "$port"

start_flintlockd_service
say "Flintlockd running at $address:9090 via interface $parent_iface"
say "Flintlockd running at $address:$port via interface $parent_iface"
}

# Fetch and install the flintlockd binary at the specified version
Expand Down Expand Up @@ -346,14 +350,15 @@ write_flintlockd_config() {
local bridge_name="$3"
local insecure="$4"
local config_file="$5"
local port="$6"

mkdir -p "$(dirname "$FLINTLOCKD_CONFIG_PATH")"

say "Writing flintlockd config to $FLINTLOCKD_CONFIG_PATH."

declare -A settings
settings["containerd-socket"]="$CONTAINERD_STATE_DIR/containerd.sock"
settings["grpc-endpoint"]="$address:9090"
settings["grpc-endpoint"]="$address:$port"
settings["verbosity"]="9"
settings["insecure"]="$insecure"

Expand Down Expand Up @@ -413,7 +418,7 @@ lookup_interface() {
lookup_address() {
local interface="$1"

ip route show | awk -v i="$interface" '$0 ~ i {print $9}' | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)'
ip route show | awk -v i="$interface" '$0 ~ i {print $9}' | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)' -m 1
}

## CONTAINERD
Expand Down Expand Up @@ -736,6 +741,7 @@ cmd_all() {
local skip_apt=false
local disk=""
local fl_address=""
local fl_port=""
local fl_iface=""
local bridge_name=""
local insecure=false
Expand Down Expand Up @@ -766,6 +772,10 @@ cmd_all() {
shift
fl_address="$1"
;;
"-p" | "--grpc-port")
shift
fl_port="$1"
;;
"-i" | "--parent-iface")
shift
fl_iface="$1"
Expand Down Expand Up @@ -821,7 +831,7 @@ cmd_all() {

install_firecracker "$fc_version"
do_all_containerd "$ctrd_version" "$set_thinpool"
do_all_flintlock "$fl_version" "$fl_address" "$fl_iface" "$bridge_name" "$insecure" "$flintlock_config_file"
do_all_flintlock "$fl_version" "$fl_address" "$fl_iface" "$bridge_name" "$insecure" "$flintlock_config_file" "$fl_port"

say "$(date -u +'%F %H:%M:%S %Z'): Host $(hostname) provisioned"
}
Expand Down Expand Up @@ -899,6 +909,7 @@ cmd_containerd() {
cmd_flintlock() {
local version="$FLINTLOCK_VERSION"
local address=""
local port=""
local parent_iface=""
local bridge_name=""
local insecure=false
Expand All @@ -918,6 +929,10 @@ cmd_flintlock() {
shift
address="$1"
;;
"-p" | "--grpc-port")
shift
port="$1"
;;
"-i" | "--parent-iface")
shift
parent_iface="$1"
Expand Down Expand Up @@ -945,7 +960,7 @@ cmd_flintlock() {

set_arch
prepare_dirs
do_all_flintlock "$version" "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file"
do_all_flintlock "$version" "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file" "$port"
}

cmd_direct_lvm() {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/containerd/image_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (im *imageService) snapshotAndMount(ctx context.Context,
logger.Debugf("image %s isn't unpacked, unpacking using %s snapshotter", image.Name(), snapshotter)

if unpackErr := image.Unpack(ctx, snapshotter); unpackErr != nil {
return nil, fmt.Errorf("unpacking %s with snapshotter %s: %w", image.Name(), snapshotter, err)
return nil, fmt.Errorf("unpacking %s with snapshotter %s: %w", image.Name(), snapshotter, unpackErr)
}
}

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/microvm/firecracker/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (p *fcProvider) startFirecracker(cmd *exec.Cmd, vmState State, detached boo
}

if startErr != nil {
return nil, fmt.Errorf("starting firecracker process: %w", err)
return nil, fmt.Errorf("starting firecracker process: %w", startErr)
}

return cmd.Process, nil
Expand Down

0 comments on commit f421319

Please sign in to comment.