-
Notifications
You must be signed in to change notification settings - Fork 375
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
Wait and retry for rsm goal state #2801
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,14 @@ | |
# | ||
set -euo pipefail | ||
|
||
AGENT_PYTHON_SCRIPT="agent-python" | ||
AGENT_SERVICE_SCRIPT="agent-service" | ||
PYTHON=$(source $AGENT_PYTHON_SCRIPT) | ||
PYTHON=$(get-agent-python) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add a comment describing what this script does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already added a comment. |
||
echo "Agent's Python: $PYTHON" | ||
# some distros return .pyc byte file instead source file .py. So, I retrieve parent directory first. | ||
version_file_dir=$($PYTHON -c 'import azurelinuxagent.common.version as v; import os; print(os.path.dirname(v.__file__))') | ||
version_file_full_path="$version_file_dir/version.py" | ||
sed -E -i "s/AGENT_VERSION\s+=\s+'[0-9.]+'/AGENT_VERSION = '1.0.0.0'/" $version_file_full_path | ||
sed -i 's/GAUpdates.Enabled=n/GAUpdates.Enabled=y/g' /etc/waagent.conf | ||
sed -i '$a AutoUpdate.GAFamily=Test' /etc/waagent.conf | ||
source $AGENT_SERVICE_SCRIPT restart | ||
waagent_conf_path=$($PYTHON -c 'from azurelinuxagent.common.osutil import get_osutil; osutil=get_osutil(); print(osutil.agent_conf_file_path)') | ||
sed -i 's/GAUpdates.Enabled=n/GAUpdates.Enabled=y/g' "$waagent_conf_path" | ||
sed -i '$a AutoUpdate.GAFamily=Test' "$waagent_conf_path" | ||
echo "Restarting service..." | ||
agent-service restart |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env pypy3 | ||
|
||
# Microsoft Azure Linux Agent | ||
# | ||
# Copyright 2018 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import argparse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add a comment describing what this script does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
import sys | ||
import time | ||
|
||
from azurelinuxagent.common.protocol.util import get_protocol_util | ||
from azurelinuxagent.common.protocol.goal_state import GoalState, GoalStateProperties | ||
|
||
|
||
def get_requested_version(gs: GoalState) -> str: | ||
agent_families = gs.extensions_goal_state.agent_families | ||
agent_family_manifests = [m for m in agent_families if m.name == "Test" and len(m.uris) > 0] | ||
if len(agent_family_manifests) == 0: | ||
raise Exception( | ||
u"No manifest links found for agent family Test, skipping agent update verification") | ||
manifest = agent_family_manifests[0] | ||
if manifest.is_requested_version_specified and manifest.requested_version is not None: | ||
return str(manifest.requested_version) | ||
return "" | ||
|
||
|
||
try: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-v', '--version', required=True) | ||
args = parser.parse_args() | ||
|
||
protocol = get_protocol_util().get_protocol(init_goal_state=False) | ||
protocol.client.reset_goal_state( | ||
goal_state_properties=GoalStateProperties.ExtensionsGoalState | GoalStateProperties.Certificates) | ||
|
||
attempts = 5 | ||
while attempts > 0: | ||
protocol.client.update_goal_state() | ||
goal_state = protocol.client.get_goal_state() | ||
requested_version = get_requested_version(goal_state) | ||
if requested_version == args.version: | ||
print("Latest GS includes rsm requested version : {0}.".format(requested_version)) | ||
break | ||
print("RSM requested version GS not available yet to the agent, checking again in 30 secs.") | ||
attempts -= 1 | ||
time.sleep(30) | ||
|
||
except Exception as e: | ||
print(f"{e}", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
sys.exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing this echo so that the output is just the same as "waagent --version"