Skip to content

Commit 4c65ca9

Browse files
committed
modify provision.sh to accept grpc port
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>
1 parent 22034dc commit 4c65ca9

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

hack/scripts/provision.sh

+21-6
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ do_all_flintlock() {
305305
local bridge_name="$4"
306306
local insecure="$5"
307307
local config_file="$6"
308+
local port="$7"
308309

309310
install_flintlockd "$version"
310311

@@ -314,10 +315,13 @@ do_all_flintlock() {
314315
if [[ -z "$address" ]]; then
315316
address=$(lookup_address "$parent_iface")
316317
fi
317-
write_flintlockd_config "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file"
318+
if [[ -z "$port" ]]; then
319+
port="9090"
320+
fi
321+
write_flintlockd_config "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file" "$port"
318322

319323
start_flintlockd_service
320-
say "Flintlockd running at $address:9090 via interface $parent_iface"
324+
say "Flintlockd running at $address:$port via interface $parent_iface"
321325
}
322326

323327
# Fetch and install the flintlockd binary at the specified version
@@ -346,14 +350,15 @@ write_flintlockd_config() {
346350
local bridge_name="$3"
347351
local insecure="$4"
348352
local config_file="$5"
353+
local port="$6"
349354

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

352357
say "Writing flintlockd config to $FLINTLOCKD_CONFIG_PATH."
353358

354359
declare -A settings
355360
settings["containerd-socket"]="$CONTAINERD_STATE_DIR/containerd.sock"
356-
settings["grpc-endpoint"]="$address:9090"
361+
settings["grpc-endpoint"]="$address:$port"
357362
settings["verbosity"]="9"
358363
settings["insecure"]="$insecure"
359364

@@ -413,7 +418,7 @@ lookup_interface() {
413418
lookup_address() {
414419
local interface="$1"
415420

416-
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]\.)'
421+
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
417422
}
418423

419424
## CONTAINERD
@@ -736,6 +741,7 @@ cmd_all() {
736741
local skip_apt=false
737742
local disk=""
738743
local fl_address=""
744+
local fl_port=""
739745
local fl_iface=""
740746
local bridge_name=""
741747
local insecure=false
@@ -766,6 +772,10 @@ cmd_all() {
766772
shift
767773
fl_address="$1"
768774
;;
775+
"-p" | "--grpc-port")
776+
shift
777+
fl_port="$1"
778+
;;
769779
"-i" | "--parent-iface")
770780
shift
771781
fl_iface="$1"
@@ -821,7 +831,7 @@ cmd_all() {
821831

822832
install_firecracker "$fc_version"
823833
do_all_containerd "$ctrd_version" "$set_thinpool"
824-
do_all_flintlock "$fl_version" "$fl_address" "$fl_iface" "$bridge_name" "$insecure" "$flintlock_config_file"
834+
do_all_flintlock "$fl_version" "$fl_address" "$fl_iface" "$bridge_name" "$insecure" "$flintlock_config_file" "$fl_port"
825835

826836
say "$(date -u +'%F %H:%M:%S %Z'): Host $(hostname) provisioned"
827837
}
@@ -899,6 +909,7 @@ cmd_containerd() {
899909
cmd_flintlock() {
900910
local version="$FLINTLOCK_VERSION"
901911
local address=""
912+
local port=""
902913
local parent_iface=""
903914
local bridge_name=""
904915
local insecure=false
@@ -918,6 +929,10 @@ cmd_flintlock() {
918929
shift
919930
address="$1"
920931
;;
932+
"-p" | "--grpc-port")
933+
shift
934+
port="$1"
935+
;;
921936
"-i" | "--parent-iface")
922937
shift
923938
parent_iface="$1"
@@ -945,7 +960,7 @@ cmd_flintlock() {
945960

946961
set_arch
947962
prepare_dirs
948-
do_all_flintlock "$version" "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file"
963+
do_all_flintlock "$version" "$address" "$parent_iface" "$bridge_name" "$insecure" "$config_file" "$port"
949964
}
950965

951966
cmd_direct_lvm() {

infrastructure/containerd/image_service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (im *imageService) snapshotAndMount(ctx context.Context,
169169
logger.Debugf("image %s isn't unpacked, unpacking using %s snapshotter", image.Name(), snapshotter)
170170

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

infrastructure/microvm/firecracker/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (p *fcProvider) startFirecracker(cmd *exec.Cmd, vmState State, detached boo
9292
}
9393

9494
if startErr != nil {
95-
return nil, fmt.Errorf("starting firecracker process: %w", err)
95+
return nil, fmt.Errorf("starting firecracker process: %w", startErr)
9696
}
9797

9898
return cmd.Process, nil

0 commit comments

Comments
 (0)