-
Notifications
You must be signed in to change notification settings - Fork 372
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
Echo log to /dev/console during provisioning #2043
Changes from 5 commits
6806509
3a2475c
927b58b
b32e506
765b9f5
a3f67c6
a6f8ca7
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 |
---|---|---|
|
@@ -25,6 +25,32 @@ | |
from azurelinuxagent.common.utils.flexible_version import FlexibleVersion | ||
from azurelinuxagent.common.future import ustr, get_linux_distribution | ||
|
||
__DAEMON_VERSION_ENV_VARIABLE = '_AZURE_GUEST_AGENT_DAEMON_VERSION_' | ||
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. Why not put this under this class -
If position of that class is a problem, you can also move it from 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. those are mean for extensions, this one is not i used underscores to mark variables not meant to be used by extensions |
||
""" | ||
The daemon process sets this variable's value to the daemon's version number. | ||
The variable is set only on versions >= 2.2.53 | ||
""" | ||
|
||
|
||
def set_daemon_version(flexible_version): | ||
""" | ||
Sets the value of the _AZURE_GUEST_AGENT_DAEMON_VERSION_ environment variable. | ||
""" | ||
os.environ[__DAEMON_VERSION_ENV_VARIABLE] = ustr(flexible_version) | ||
|
||
|
||
def get_daemon_version(): | ||
""" | ||
Retrieves the value of the _AZURE_GUEST_AGENT_DAEMON_VERSION_ environment variable. | ||
The value indicates the version of the daemon that started the current agent process or, if the current | ||
process is the daemon, the version of the current process. | ||
If the variable is not set (because the agent is < 2.2.53, or the process was not started by the daemon and | ||
the process is not the daemon itself) the function returns "0.0.0.0" | ||
""" | ||
if __DAEMON_VERSION_ENV_VARIABLE in os.environ: | ||
return FlexibleVersion(os.environ[__DAEMON_VERSION_ENV_VARIABLE]) | ||
return FlexibleVersion("0.0.0.0") | ||
|
||
|
||
def get_f5_platform(): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,7 @@ | |
import tempfile | ||
from datetime import datetime, timedelta | ||
|
||
# pylint: disable=unused-import | ||
from azurelinuxagent.common.event import __event_logger__, add_log_event, MAX_NUMBER_OF_EVENTS, TELEMETRY_LOG_EVENT_ID,\ | ||
TELEMETRY_LOG_PROVIDER_ID, EVENTS_DIRECTORY | ||
# pylint: enable=unused-import | ||
from azurelinuxagent.common.event import __event_logger__, add_log_event, MAX_NUMBER_OF_EVENTS, EVENTS_DIRECTORY | ||
|
||
import azurelinuxagent.common.logger as logger | ||
from azurelinuxagent.common.utils import fileutil | ||
|
@@ -565,3 +562,32 @@ def test_stdout_appender(self, mock_sys_stdout): | |
|
||
# Validating only test-error gets logged and not others. | ||
self.assertEqual(1, mock_sys_stdout.call_count) | ||
|
||
def test_console_output_enabled_should_return_true_when_there_are_no_console_appenders(self): | ||
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. typo; should be "when_there_are_console_appenders" |
||
my_logger = logger.Logger() | ||
my_logger.add_appender(logger.AppenderType.STDOUT, logger.LogLevel.INFO, None) | ||
my_logger.add_appender(logger.AppenderType.CONSOLE, logger.LogLevel.INFO, None) | ||
|
||
self.assertTrue(my_logger.console_output_enabled(), "Console output should be enabled, appenders = {0}".format(my_logger.appenders)) | ||
|
||
def test_console_output_enabled_should_return_false_when_there_are_no_console_appenders(self): | ||
my_logger = logger.Logger() | ||
my_logger.add_appender(logger.AppenderType.STDOUT, logger.LogLevel.INFO, None) | ||
|
||
self.assertFalse(my_logger.console_output_enabled(), "Console output should not be enabled, appenders = {0}".format(my_logger.appenders)) | ||
|
||
def test_disable_console_output_should_remove_all_console_appenders(self): | ||
my_logger = logger.Logger() | ||
my_logger.add_appender(logger.AppenderType.STDOUT, logger.LogLevel.INFO, None) | ||
my_logger.add_appender(logger.AppenderType.CONSOLE, logger.LogLevel.INFO, None) | ||
my_logger.add_appender(logger.AppenderType.STDOUT, logger.LogLevel.INFO, None) | ||
my_logger.add_appender(logger.AppenderType.CONSOLE, logger.LogLevel.INFO, None) | ||
|
||
my_logger.disable_console_output() | ||
|
||
self.assertTrue( | ||
len(my_logger.appenders) == 2 and all(isinstance(a, logger.StdoutAppender) for a in my_logger.appenders), | ||
"The console appender was not removed: {0}".format(my_logger.appenders)) | ||
|
||
|
||
|
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.
Should this be added under the try just to be on the safer side?
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.
if the appender was not added we do not want do remove it (nothing bad would happen in the current implementation, but still)
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 think there's been some confusion, I meant moving the adding part under the try too. Just having a
logger.info
under try adds little value.