Skip to content

Commit

Permalink
reduce log level info to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandredevely committed Oct 23, 2024
1 parent 4d26587 commit 7338070
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 43 deletions.
2 changes: 1 addition & 1 deletion controllers/auth_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AuthController(BaseController):
redirect_page_local_filename = 'redirect.mustache.html'

def __init__(self, config_controller=None):
self.logger.info( f"config_controller={config_controller}" )
self.logger.debug( f"config_controller={config_controller}" )
super().__init__(config_controller)
try:
self.oauth_html_redirect_page = oc.lib.load_local_file(filename=AuthController.redirect_page_local_filename)
Expand Down
4 changes: 2 additions & 2 deletions controllers/store_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def get(self):
return Results.success(result=value)

def wrapped_get( self, userid, key ):
self.logger.debug('')
# self.logger.debug('')
value = services.datastore.get_document_value_in_collection( self.databasename, userid, key)
if value is None:
# return default wrapped value
# for {"status": 200, "result": "img", "message": "ok"}
value = self.wrapped_key.get( key )
self.logger.debug(f"wrapped_get result {userid}:{key}->{value}" )
self.logger.debug(f"wrapped_get result key={key}->{value}" )
return value

@cherrypy.expose
Expand Down
4 changes: 2 additions & 2 deletions controllers/user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def getinfo(self):
@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def getlocation(self):
self.logger.debug('')
# self.logger.debug('')
(auth, user) = self.validate_env()
location = oc.od.user.getlocation( auth )
return Results.success(result=location)
Expand All @@ -53,7 +53,7 @@ def getlocation(self):
@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def whoami(self):
self.logger.debug('')
# self.logger.debug('')
auth = None
user = None
# same has super().validate_env
Expand Down
4 changes: 2 additions & 2 deletions oc/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def createhosturl( self, databasename ):
return url

def createclient(self, databasename):
self.logger.debug( f"databasename={databasename}")
# self.logger.debug( f"databasename={databasename}")
# hosturl = self.createhosturl( databasename )
# self.logger.debug( f"hosturl={hosturl}")
hosturl = self.createhosturl( databasename )
self.logger.debug( f"createclient MongoClient {hosturl}")
# self.logger.debug( f"createclient MongoClient {hosturl}")
mongo_client = MongoClient(host=hosturl)
# connectTimeoutMS=self.connectTimeoutMS,
# socketTimeoutMS=self.socketTimeoutMS,
Expand Down
8 changes: 0 additions & 8 deletions oc/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ def filter(self, record):
''' Log Filter that add to the current log record a userid field '''
''' containing the user id (extracted from the http request) '''
''' add node_name '''
''' add thread ident '''

# read thread ident
record.threadid = None
try:
record.threadid = threading.get_ident()
except Exception as e:
pass

# read node_name
record.nodename = node_name
Expand Down
12 changes: 6 additions & 6 deletions oc/od/kuberneteswatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def __init__(self):
self.logger.debug( f"ODKubernetesWatcher use namespace={self.orchestrator.namespace}")

def loopforevent( self ):
self.logger.debug('' )
# self.logger.debug('' )
self.watch = watch.Watch()
self.logger.debug('loopforevent start inifity loop')
# self.logger.debug('loopforevent start inifity loop')
while( True ): # inifity loop stop when watch.stop
try:
# watch list_namespaced_pod waiting for a valid ip addr
Expand Down Expand Up @@ -54,7 +54,7 @@ def loopforevent( self ):
# self.logger.debug( f"{event_type} -> {pod_event.metadata.name}:{podtype}" )
if podtype == self.orchestrator.pod_application_pull or \
podtype == self.orchestrator.pod_application :
self.logger.debug( f"{event_type} -> {pod_event.metadata.name}:{podtype}" )
# self.logger.debug( f"{event_type} -> {pod_event.metadata.name}:{podtype}" )
if isinstance( pod_event.status, V1PodStatus ):
if not isinstance(pod_event.status.container_statuses, list):
continue
Expand All @@ -78,7 +78,7 @@ def loopforevent( self ):
elif event_type == 'DELETED':
# if podevent type is pod
if isinstance( pod_event, V1Pod ) :
self.logger.debug( f"{event_type} -> {pod_event.metadata.name}" )
# self.logger.debug( f"{event_type} -> {pod_event.metadata.name}" )
podtype = pod_event.metadata.labels.get( 'type' )
if podtype == self.orchestrator.x11servertype :
self.logger.debug( f"{event_type} -> {pod_event.metadata.name}:{podtype}" )
Expand All @@ -90,12 +90,12 @@ def loopforevent( self ):
pass

def start(self):
self.logger.debug('starting watcher thread')
self.logger.debug('watcher thread is starting')
self.thead_event = threading.Thread(target=self.loopforevent)
self.thead_event.start() # infinite loop until events.close()

def stop(self):
self.logger.debug('ODKubernetesWatcher thread stopping')
self.logger.debug('watcher thread is stopping')
if isinstance( self.thead_event, threading.Thread ):
while self.thead_event.is_alive():
self.logger.debug('thread watcher is alive')
Expand Down
2 changes: 1 addition & 1 deletion oc/od/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def _create_dict(self, authinfo, userinfo, arguments):
# Default secret
mydict_secret = { 'principal' : ODSecret.strtob64( principal ),
'realm' : ODSecret.strtob64( realm ),
'keytab' : ODSecret.bytestob64( keytab ), # this is a binary file
'keytab' : ODSecret.bytestob64( keytab ),
'krb5_conf' : ODSecret.strtob64( krb5_conf ),
'data' : ODSecret.strtob64( str_dict_data),
'authprotocol': ODSecret.strtob64( self.authprotocol)
Expand Down
18 changes: 1 addition & 17 deletions oc/od/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def start(self):
start threads
* kuberneteswatcher
"""
self.logger.debug('')
if isinstance( self.kuberneteswatcher, oc.od.kuberneteswatcher.ODKubernetesWatcher):
self.kuberneteswatcher.start()

Expand All @@ -63,11 +62,10 @@ def stop( self):
stop threads
* kuberneteswatcher
"""
self.logger.debug('')
# stop thread imagewatcher if instance exists
if isinstance( self.kuberneteswatcher, oc.od.kuberneteswatcher.ODKubernetesWatcher):
try:
self.logger.debug( 'kuberneteswatcher stop')
self.logger.debug( 'kuberneteswatcher in stopping')
self.kuberneteswatcher.stop()
self.logger.debug( 'kuberneteswatcher stopped')
except Exception as e:
Expand Down Expand Up @@ -118,7 +116,6 @@ def init_keymanager(self):
def init_locator(self):
"""geolocatization from ip address
"""
self.logger.info('')
import oc.od.locator
self.locatorPublicInternet = oc.od.locator.ODLocatorPublicInternet()
self.locatorPrivateActiveDirectory = {}
Expand Down Expand Up @@ -149,23 +146,19 @@ def init_jwtdesktop(self):
"""Load rsa keys jwtdesktopprivatekeyfile jwtdesktoppublickeyfile payloaddesktoppublickeyfile
to build the jwtdesktop
"""
self.logger.info('')
import oc.auth.jwtdesktop
self.jwtdesktop = oc.auth.jwtdesktop.ODDesktopJWToken( settings.jwt_config_desktop )

def init_internaldns(self):
self.logger.info('')
if settings.internaldns.get('enable') is True:
import oc.od.internaldns
self.internaldns = oc.od.internaldns.ODInternalDNS( domain=settings.internaldns.get('domain'), server=settings.internaldns.get('server'), secret=settings.internaldns.get('secret') )

def init_accounting(self):
self.logger.info('')
import oc.od.accounting
self.accounting = oc.od.accounting.ODAccounting()

def init_datastore(self):
self.logger.info('')
import oc.datastore
self.datastore = oc.datastore.ODMongoDatastoreClient(settings.mongodburl)

Expand All @@ -187,42 +180,34 @@ def init_datastore(self):
return True

def init_datacache(self):
self.logger.info('')
import oc.sharecache
self.sharecache = oc.sharecache.ODMemcachedSharecache(settings.memconnectionstring)

def init_prelogin(self):
self.logger.info('')
import oc.auth.prelogin
self.prelogin = oc.auth.prelogin.ODPrelogin( config=settings.prelogin,
memcache_connection_string=settings.memconnectionstring )

def init_logmein(self):
self.logger.info('')
import oc.auth.logmein
self.logmein = oc.auth.logmein.ODLogmein( config=settings.logmein )

def init_messageinfo(self):
self.logger.info('')
import oc.od.messageinfo
self.messageinfo = oc.od.messageinfo.ODMessageInfoManager(settings.memconnectionstring)

def init_auth(self):
self.logger.info('')
import oc.auth.authservice
self.auth = oc.auth.authservice.ODAuthTool(settings.default_host_url, settings.jwt_config_user, settings.authmanagers)

def init_applist( self ):
self.logger.info('')
import oc.od.apps
# Build applist cache data
self.apps = oc.od.apps.ODApps(mongodburl=settings.mongodburl)
self.apps.cached_applist(bRefresh=True)

def init_kuberneteswatcher( self ):
self.logger.info('')
self.kuberneteswatcher = oc.od.kuberneteswatcher.ODKubernetesWatcher()
# oc.od.kuberneteswatcher.ODKubernetesWatcher()

# use services to access
services = ODServices()
Expand All @@ -233,7 +218,6 @@ def init_infra():
find configuration for kubernetes
"""
logger.info('')

# Check kubernetes config
myOrchestrator = oc.od.orchestrator.ODOrchestratorKubernetes()
Expand Down
2 changes: 1 addition & 1 deletion oc/od/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def whoami(auth, user):
'container_id',
'hostedby'
"""
logger.debug('')
# logger.debug('')

# return default value
userinfo = {
Expand Down
6 changes: 3 additions & 3 deletions od.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,19 @@ def healthz(self):
class ODCherryWatcher(plugins.SimplePlugin):
""" signal thread to stop when cherrypy stop"""
def start(self):
logger.debug( "ODCherryWatcher start events, skipping" )
# logger.debug( "ODCherryWatcher start events" )
oc.od.services.services.start()

def stop(self):
logger.debug("ODCherryWatcher is stopping. Stopping runnging thread")
# logger.debug("ODCherryWatcher is stopping. Stopping runnging thread")
oc.od.services.services.stop()


def run_server():
logger.info("Starting cherrypy service...")
# update config for cherrypy with the od.config file
cherrypy.config.update(settings.get_configuration_file_name())
logger.info(f"cherrypy.config.update({settings.get_configuration_file_name()})")
logger.debug(f"cherrypy.config.update({settings.get_configuration_file_name()}) done")
# set auth tools
cherrypy.tools.auth = services.services.auth
# set /API
Expand Down

0 comments on commit 7338070

Please sign in to comment.