Skip to content

Commit

Permalink
Merge pull request #9132 from Azure/dvirnaim/bug/update_hostnetwork
Browse files Browse the repository at this point in the history
fix hostnetwork in update
  • Loading branch information
udidekel authored Oct 30, 2023
2 parents 745fde0 + de36d53 commit 2f8e75f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions Solutions/SAP/sapcon-instance-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ while [[ $# -gt 0 ]]; do
DEVURL="$2"
shift 2
;;
--hostnetwork)
HOSTNETWORK=1
shift 1
;;
--dev-acr-login)
DEVACRLOGIN="$2"
shift 2
Expand Down Expand Up @@ -203,6 +207,7 @@ while IFS= read -r contname; do
fi
read -r -a containervariables <<<$(docker inspect "$contname" --format '{{.Config.Env}}' | tr -d '[' | tr -d ']' | tr ' ' ' ')
envstring=""
cmdparams=""
for variable in "${containervariables[@]}"; do
if [[ ! $variable == PATH=* ]] &&
[[ ! $variable == LANG=* ]] &&
Expand Down Expand Up @@ -265,12 +270,14 @@ while IFS= read -r contname; do
docker cp "$contname":$sdkfileloc "/tmp/sapcon-update/$contname/inst/"
fi
sdkfilename=$(ls -1r /tmp/sapcon-update/$contname/inst/nwrfc*.zip | head -n 1)

if [ $HOSTNETWORK ]; then
cmdparams+=" --network host "
fi
if [ ! $NOTESTRUN ]; then
# If test run is required
testruncontainer="$contname-testrun"
log "Creating agent $contname in test mode"
docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $envstring $ContainerNetworkSetting --name "$testruncontainer" $dockerimage$tagver --sapconinstanceupdate >/dev/null
docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $cmdparams $envstring $ContainerNetworkSetting --name "$testruncontainer" $dockerimage$tagver --sapconinstanceupdate >/dev/null
docker cp "$sdkfilename" "$testruncontainer":$sdkfileloc
docker start "$testruncontainer" >/dev/null

Expand Down Expand Up @@ -344,7 +351,7 @@ while IFS= read -r contname; do
if [ $dryrunsuccess == 1 ]; then
log "Creating updated agent $contname"
labelstring="--label Cloud=$CLOUD "
docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $envstring $labelstring $restartpolicystring $ContainerNetworkSetting --name "$contname" $dockerimage$tagver >/dev/null
docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $cmdparams $envstring $labelstring $restartpolicystring $ContainerNetworkSetting --name "$contname" $dockerimage$tagver >/dev/null
docker cp "$sdkfilename" "$contname":"$sdkfileloc"
fi
#Cleaning sapcon-update folder
Expand Down
4 changes: 2 additions & 2 deletions Solutions/SAP/sapcon-sentinel-kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ while [[ $# -gt 0 ]]; do
SID="$2"
shift 2
;;
--hostnetwork)
--hostnetwork)
HOSTNETWORK=1
shift 1
;;
Expand Down Expand Up @@ -793,7 +793,7 @@ cmdparams=" --label Cloud=$CLOUD"
cmdparams+=" -e SENTINEL_AGENT_GUID=$(uuidgen) "

if [ $HOSTNETWORK ]; then
cmdparams+=" --network host"
cmdparams+=" --network host "
fi

if [ "$MODE" == "kvmi" ]; then
Expand Down
2 changes: 1 addition & 1 deletion Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ elif [ "$MODE" == "kvsi" ]; then
cmdparams+=" -e AZURE_CLIENT_ID=$APPID -e AZURE_CLIENT_SECRET=$APPSECRET -e AZURE_TENANT_ID=$TENANT"
fi
if [ $HOSTNETWORK ]; then
cmdparams+=" --network host"
cmdparams+=" --network host "
fi
sudo docker create -v "$sysfileloc":/sapcon-app/sapcon/config/system $cmdparams --name "$containername" $dockerimage$tagver >/dev/null

Expand Down

0 comments on commit 2f8e75f

Please sign in to comment.