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

check onboarding status #629

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
47 changes: 47 additions & 0 deletions kubernetes/linux/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,51 @@ waitforlisteneronTCPport() {
fi
}

checkAgentOnboardingStatus() {
local sleepdurationsecs=1
local totalsleptsecs=0
local isaadmsiauthmode=$1
local waittimesecs=$2
local numeric='^[0-9]+$'

if [ -z "$1" ] || [ -z "$2" ]; then
echo "${FUNCNAME[0]} called with incorrect arguments<$1 , $2>. Required arguments <#isaadmsiauthmode, #wait-time-in-seconds>"
return -1
else

if [[ $waittimesecs =~ $numeric ]]; then
successMessage="Onboarding success"
failureMessage="Failed to register certificate with OMS Homing service, giving up"
if [ "${isaadmsiauthmode}" == "true" ]; then
successMessage="Loaded data sources"
failureMessage="Failed to load data sources into config"
fi
while true
ganga1980 marked this conversation as resolved.
Show resolved Hide resolved
do
if [ $totalsleptsecs -gt $waittimesecs ]; then
echo "${FUNCNAME[0]} giving up checking agent onboarding status after $totalsleptsecs secs"
return 1
fi

if grep "$successMessage" "${MDSD_LOG}/mdsd.info"; then
echo "Onboarding success"
return 0
elif grep "$failureMessage" "${MDSD_LOG}/mdsd.err"; then
echo "Onboarding Failure: Reason: Failed to onboard the agent"
echo "Onboarding Failure: Please verify log analytics workspace configuration such as existence of the workspace, workspace key and workspace enabled for public ingestion"
return 1
fi
sleep $sleepdurationsecs
totalsleptsecs=$(($totalsleptsecs+1))
done
else
echo "${FUNCNAME[0]} called with non-numeric arguments<$2>. Required arguments <#wait-time-in-seconds>"
return -1
fi
fi
}


#using /var/opt/microsoft/docker-cimprov/state instead of /var/opt/microsoft/omsagent/state since the latter gets deleted during onboarding
mkdir -p /var/opt/microsoft/docker-cimprov/state

Expand Down Expand Up @@ -672,6 +717,8 @@ service rsyslog stop
echo "getting rsyslog status..."
service rsyslog status

checkAgentOnboardingStatus $AAD_MSI_AUTH_MODE 30

shutdown() {
pkill -f mdsd
}
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/linux/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
update-locale LANG=en_US.UTF-8

#install oneagent - Official bits (08/04/2021)
wget https://github.com/microsoft/Docker-Provider/releases/download/08042021-oneagent/azure-mdsd_1.10.1-build.master.251_x86_64.deb
wget https://github.com/microsoft/Docker-Provider/releases/download/06242021-oneagent/azure-mdsd_1.10.3-build.master.257_x86_64.deb

/usr/bin/dpkg -i $TMPDIR/azure-mdsd*.deb
cp -f $TMPDIR/mdsd.xml /etc/mdsd.d
Expand Down