Skip to content

Commit e224f2a

Browse files
committed
ESC step 7: final cleanup/tweaks for hubblestack.adobe.net jenkins
1 parent 69c7368 commit e224f2a

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

.pipeline

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ pipeline {
8989
pip install --cache-dir .pip-cache -U pip
9090
echo no | ./mk-requires.sh
9191
pip install --cache-dir .pip-cache -U -r requirements.txt
92+
pip uninstall -y salt-ssh
93+
python -c "
94+
import sys
95+
try:
96+
import salt
97+
print('ERROR, SALT IS FOUND, ERROR')
98+
sys.exit(1)
99+
except:
100+
pass
101+
"
92102
'''
93103
}
94104
}

hubblestack/daemon.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -625,15 +625,15 @@ def _setup_logging(parsed_args):
625625

626626
# Setup logging
627627
hubblestack.log.setup_console_logger(**console_logging_opts)
628-
hubblestack.log.setup_file_logger(**file_logging_opts)
628+
if not parsed_args['skip_file_logger']:
629+
hubblestack.log.setup_file_logger(**file_logging_opts)
630+
with open(__opts__['log_file'], 'a') as _logfile:
631+
pass # ensure the file exists before we set perms on it
632+
os.chmod(__opts__['log_file'], 0o600)
629633

630-
with open(__opts__['log_file'], 'a') as _logfile:
631-
pass # ensure the file exists before we set perms on it
632-
# 384 is 0o600 permissions, written without octal for python 2/3 compat
633-
os.chmod(__opts__['log_file'], 384)
634634
configfile = parsed_args.get('configfile')
635635
if configfile and os.path.isfile(configfile):
636-
os.chmod(configfile, 384)
636+
os.chmod(configfile, 0o600)
637637

638638

639639
def _setup_dirs():
@@ -824,6 +824,9 @@ def parse_args(args=None):
824824
help='Pass in an alternative configuration file. Default: /etc/hubble/hubble')
825825
parser.add_argument('-p', '--no-pprint', help='Turn off pprint for single-function output',
826826
action='store_true')
827+
parser.add_argument('--skip-file-logger',
828+
help="Prevent logger from writing to /var/log/hubble.log",
829+
action='store_true')
827830
parser.add_argument('-v', '--verbose', action='count',
828831
help=('Verbosity level. Use -v or -vv or -vvv for '
829832
'varying levels of verbosity. Note that -vv '

hubblestack/log/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def setup_file_logger(log_file,
155155
_remove_temp_handler()
156156
rootlogger = logging.getLogger()
157157

158-
handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=max_bytes,
159-
backupCount=backup_count)
158+
fh_cls = logging.handlers.RotatingFileHandler
159+
handler = fh_cls(log_file, maxBytes=max_bytes, backupCount=backup_count)
160160
handler.setLevel(LOG_LEVELS.get(log_level, logging.ERROR))
161161

162162
formatter = logging.Formatter(log_format, date_format)

tests/unittests/test_hs_config.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def intentionally_removed_opts():
114114
"winrepo_user",
115115
}
116116

117+
@pytest.fixture
118+
def added_opts():
119+
return {'skip_file_logger',}
120+
117121
@pytest.fixture
118122
def salt_config_opts(intentionally_removed_opts):
119123
""" computed-opts.json are the opts as generated by hubble's 4.1 branch
@@ -156,10 +160,13 @@ def modified_hs_config_opts(__opts__, salt_config_opts):
156160
return opts
157161

158162
def test_new_hs_config_same_as_old_salt_config(modified_hs_config_opts,
159-
salt_config_opts, intentionally_removed_opts, test_paths):
163+
salt_config_opts, intentionally_removed_opts, test_paths, added_opts):
160164

161165
all_keys = set(modified_hs_config_opts).union(set(salt_config_opts))
162166
for key in all_keys:
167+
if key in added_opts:
168+
continue
169+
163170
assert key not in intentionally_removed_opts
164171
assert key in modified_hs_config_opts
165172
assert key in salt_config_opts
@@ -247,7 +254,7 @@ def test_winders_paths():
247254

248255
@pytest.mark.skipif(sys.platform != 'linux', reason="")
249256
def test_linux_for_real_kindof():
250-
opts = hubblestack.daemon.load_config(['-c', 'tests/unittests/resources/empty.config'])
257+
opts = hubblestack.daemon.load_config([ '-c', 'tests/unittests/resources/empty.config', '--skip-file-logger' ])
251258

252259
assert opts['cachedir'] == '/var/cache/hubble'
253260
assert opts['pidfile'] == '/var/run/hubble.pid'

0 commit comments

Comments
 (0)