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

Make GRPC ports avaiable in settings file as override #911

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
3 changes: 0 additions & 3 deletions rqd/rqd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ def main():

logging.warning('RQD Starting Up')

if rqd.rqconstants.FACILITY == 'abq':
os.environ['TZ'] = 'PST8PDT'

rqCore = rqd.rqcore.RqCore(optNimbyOff)
rqCore.start()

Expand Down
2 changes: 0 additions & 2 deletions rqd/rqd/cuerqd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import logging as log
import os
import random
import re
import sys

import grpc

Expand Down
46 changes: 9 additions & 37 deletions rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import logging
import os
import platform
import re
import subprocess
import sys
import traceback
Expand Down Expand Up @@ -122,43 +121,11 @@
LOAD_MODIFIER = 0 # amount to add/subtract from load

if subprocess.getoutput('/bin/su --help').find('session-command') != -1:
SU_ARGUEMENT = '--session-command'
SU_ARGUMENT = '--session-command'
else:
SU_ARGUEMENT = '-c'

SP_OS = FACILITY = ''
proc = None
# Try to read facility and os from studio environment
if os.path.isfile('/usr/local/stdenv/.cshrc'):
proc = subprocess.Popen(
"csh -c 'unsetenv SP_PATH ; setenv CONSOLE 1 ; setenv HOME / ;"
" source /usr/local/stdenv/.cshrc ; echo $SP_OS $FACILITY'",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
elif os.path.isfile('/etc/csh.cshrc'):
# For maa on centos
proc = subprocess.Popen("csh -c 'source /etc/csh.cshrc ; echo $SP_OS $FACILITY'",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# If we have a popen process and it has successfully been run,
# get os and facility from result.
if proc:
out, err = proc.communicate()
if proc.returncode == 0:
SP_OS, FACILITY = out.split()[-2:]

if not 3 <= len(SP_OS) <= 10 or not re.match('^[A-Za-z0-9]*$', SP_OS):
if SP_OS:
logging.warning('SP_OS value of %s is out of allowed range' % SP_OS)
SP_OS = platform.system()

if len(FACILITY) != 3 or not re.match('^[A-Za-z0-9]*$', FACILITY):
if FACILITY:
logging.warning('FACILITY value of %s is out of allowed range' % FACILITY)
FACILITY = DEFAULT_FACILITY

# maa is small so decrease the ping in interval
if FACILITY == 'maa':
RQD_MAX_PING_INTERVAL_SEC = 30
SU_ARGUMENT = '-c'

SP_OS = platform.system()

try:
if os.path.isfile(CONFIG_FILE):
Expand All @@ -168,6 +135,11 @@
config = configparser.RawConfigParser()
logging.info('Loading config {}'.format(CONFIG_FILE))
config.read(CONFIG_FILE)

if config.has_option(__section, "RQD_GRPC_PORT"):
RQD_GRPC_PORT = config.getint(__section, "RQD_GRPC_PORT")
if config.has_option(__section, "CUEBOT_GRPC_PORT"):
CUEBOT_GRPC_PORT = config.getint(__section, "CUEBOT_GRPC_PORT")
if config.has_option(__section, "OVERRIDE_CORES"):
OVERRIDE_CORES = config.getint(__section, "OVERRIDE_CORES")
if config.has_option(__section, "OVERRIDE_PROCS"):
Expand Down
2 changes: 1 addition & 1 deletion rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def runLinux(self):
rqd.rqutil.permissionsHigh()
try:
if rqd.rqconstants.RQD_BECOME_JOB_USER:
tempCommand += ["/bin/su", runFrame.user_name, rqd.rqconstants.SU_ARGUEMENT,
tempCommand += ["/bin/su", runFrame.user_name, rqd.rqconstants.SU_ARGUMENT,
'"' + self._createCommandFile(runFrame.command) + '"']
else:
tempCommand += [self._createCommandFile(runFrame.command)]
Expand Down
2 changes: 1 addition & 1 deletion rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def __initMachineStats(self, pathCpuInfo=None):
"""Updates static machine information during initialization"""
self.__renderHost.name = self.getHostname()
self.__renderHost.boot_time = self.getBootTime()
self.__renderHost.facility = rqd.rqconstants.FACILITY
self.__renderHost.facility = rqd.rqconstants.DEFAULT_FACILITY
self.__renderHost.attributes['SP_OS'] = rqd.rqconstants.SP_OS

self.updateMachineStats()
Expand Down
2 changes: 1 addition & 1 deletion rqd/tests/rqcore_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def test_unlockAllWhenNimbyLocked(self):
class FrameAttendantThreadTests(pyfakefs.fake_filesystem_unittest.TestCase):
def setUp(self):
self.setUpPyfakefs()
rqd.rqconstants.SU_ARGUEMENT = '-c'
rqd.rqconstants.SU_ARGUMENT = '-c'

@mock.patch('platform.system', new=mock.Mock(return_value='Linux'))
@mock.patch('tempfile.gettempdir')
Expand Down