mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-13 13:03:01 +00:00
log.warning
This commit is contained in:
@@ -26,7 +26,7 @@ class CookieAPIHandler(APIHandler):
|
|||||||
def get(self, cookie_name, cookie_value=None):
|
def get(self, cookie_name, cookie_value=None):
|
||||||
cookie_name = quote(cookie_name, safe='')
|
cookie_name = quote(cookie_name, safe='')
|
||||||
if cookie_value is None:
|
if cookie_value is None:
|
||||||
self.log.warn("Cookie values in request body is deprecated, use `/cookie_name/cookie_value`")
|
self.log.warning("Cookie values in request body is deprecated, use `/cookie_name/cookie_value`")
|
||||||
cookie_value = self.request.body
|
cookie_value = self.request.body
|
||||||
else:
|
else:
|
||||||
cookie_value = cookie_value.encode('utf8')
|
cookie_value = cookie_value.encode('utf8')
|
||||||
|
@@ -26,16 +26,16 @@ class APIHandler(BaseHandler):
|
|||||||
# If no header is provided, assume it comes from a script/curl.
|
# If no header is provided, assume it comes from a script/curl.
|
||||||
# We are only concerned with cross-site browser stuff here.
|
# We are only concerned with cross-site browser stuff here.
|
||||||
if not host:
|
if not host:
|
||||||
self.log.warn("Blocking API request with no host")
|
self.log.warning("Blocking API request with no host")
|
||||||
return False
|
return False
|
||||||
if not referer:
|
if not referer:
|
||||||
self.log.warn("Blocking API request with no referer")
|
self.log.warning("Blocking API request with no referer")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
host_path = url_path_join(host, self.hub.server.base_url)
|
host_path = url_path_join(host, self.hub.server.base_url)
|
||||||
referer_path = referer.split('://', 1)[-1]
|
referer_path = referer.split('://', 1)[-1]
|
||||||
if not (referer_path + '/').startswith(host_path):
|
if not (referer_path + '/').startswith(host_path):
|
||||||
self.log.warn("Blocking Cross Origin API request. Referer: %s, Host: %s",
|
self.log.warning("Blocking Cross Origin API request. Referer: %s, Host: %s",
|
||||||
referer, host_path)
|
referer, host_path)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@@ -41,7 +41,7 @@ class UserListAPIHandler(APIHandler):
|
|||||||
continue
|
continue
|
||||||
user = self.find_user(name)
|
user = self.find_user(name)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
self.log.warn("User %s already exists" % name)
|
self.log.warning("User %s already exists" % name)
|
||||||
else:
|
else:
|
||||||
to_create.append(name)
|
to_create.append(name)
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class UserAdminAccessAPIHandler(APIHandler):
|
|||||||
@admin_only
|
@admin_only
|
||||||
def post(self, name):
|
def post(self, name):
|
||||||
current = self.get_current_user()
|
current = self.get_current_user()
|
||||||
self.log.warn("Admin user %s has requested access to %s's server",
|
self.log.warning("Admin user %s has requested access to %s's server",
|
||||||
current.name, name,
|
current.name, name,
|
||||||
)
|
)
|
||||||
if not self.settings.get('admin_access', False):
|
if not self.settings.get('admin_access', False):
|
||||||
|
@@ -293,7 +293,7 @@ class JupyterHub(Application):
|
|||||||
def _proxy_auth_token_default(self):
|
def _proxy_auth_token_default(self):
|
||||||
token = os.environ.get('CONFIGPROXY_AUTH_TOKEN', None)
|
token = os.environ.get('CONFIGPROXY_AUTH_TOKEN', None)
|
||||||
if not token:
|
if not token:
|
||||||
self.log.warn('\n'.join([
|
self.log.warning('\n'.join([
|
||||||
"",
|
"",
|
||||||
"Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.",
|
"Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.",
|
||||||
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.",
|
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.",
|
||||||
@@ -599,7 +599,7 @@ class JupyterHub(Application):
|
|||||||
try:
|
try:
|
||||||
os.chmod(secret_file, 0o600)
|
os.chmod(secret_file, 0o600)
|
||||||
except OSError:
|
except OSError:
|
||||||
self.log.warn("Failed to set permissions on %s", secret_file)
|
self.log.warning("Failed to set permissions on %s", secret_file)
|
||||||
# store the loaded trait value
|
# store the loaded trait value
|
||||||
self.cookie_secret = secret
|
self.cookie_secret = secret
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ class JupyterHub(Application):
|
|||||||
db = self.db
|
db = self.db
|
||||||
|
|
||||||
if self.admin_users and not self.authenticator.admin_users:
|
if self.admin_users and not self.authenticator.admin_users:
|
||||||
self.log.warn(
|
self.log.warning(
|
||||||
"\nJupyterHub.admin_users is deprecated."
|
"\nJupyterHub.admin_users is deprecated."
|
||||||
"\nUse Authenticator.admin_users instead."
|
"\nUse Authenticator.admin_users instead."
|
||||||
)
|
)
|
||||||
@@ -776,7 +776,7 @@ class JupyterHub(Application):
|
|||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def user_stopped(user):
|
def user_stopped(user):
|
||||||
status = yield user.spawner.poll()
|
status = yield user.spawner.poll()
|
||||||
self.log.warn("User %s server stopped with exit code: %s",
|
self.log.warning("User %s server stopped with exit code: %s",
|
||||||
user.name, status,
|
user.name, status,
|
||||||
)
|
)
|
||||||
yield self.proxy.delete_user(user)
|
yield self.proxy.delete_user(user)
|
||||||
@@ -800,7 +800,7 @@ class JupyterHub(Application):
|
|||||||
# user not running. This is expected if server is None,
|
# user not running. This is expected if server is None,
|
||||||
# but indicates the user's server died while the Hub wasn't running
|
# but indicates the user's server died while the Hub wasn't running
|
||||||
# if user.server is defined.
|
# if user.server is defined.
|
||||||
log = self.log.warn if user.server else self.log.debug
|
log = self.log.warning if user.server else self.log.debug
|
||||||
log("%s not running.", user.name)
|
log("%s not running.", user.name)
|
||||||
user.server = None
|
user.server = None
|
||||||
|
|
||||||
@@ -998,7 +998,7 @@ class JupyterHub(Application):
|
|||||||
self.load_config_file(self.config_file)
|
self.load_config_file(self.config_file)
|
||||||
self.init_logging()
|
self.init_logging()
|
||||||
if 'JupyterHubApp' in self.config:
|
if 'JupyterHubApp' in self.config:
|
||||||
self.log.warn("Use JupyterHub in config, not JupyterHubApp. Outdated config:\n%s",
|
self.log.warning("Use JupyterHub in config, not JupyterHubApp. Outdated config:\n%s",
|
||||||
'\n'.join('JupyterHubApp.{key} = {value!r}'.format(key=key, value=value)
|
'\n'.join('JupyterHubApp.{key} = {value!r}'.format(key=key, value=value)
|
||||||
for key, value in self.config.JupyterHubApp.items()
|
for key, value in self.config.JupyterHubApp.items()
|
||||||
)
|
)
|
||||||
@@ -1098,7 +1098,7 @@ class JupyterHub(Application):
|
|||||||
continue
|
continue
|
||||||
user = orm.User.find(self.db, route['user'])
|
user = orm.User.find(self.db, route['user'])
|
||||||
if user is None:
|
if user is None:
|
||||||
self.log.warn("Found no user for route: %s", route)
|
self.log.warning("Found no user for route: %s", route)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(route['last_activity'], ISO8601_ms)
|
dt = datetime.strptime(route['last_activity'], ISO8601_ms)
|
||||||
|
@@ -383,9 +383,9 @@ class PAMAuthenticator(LocalAuthenticator):
|
|||||||
pamela.authenticate(username, data['password'], service=self.service)
|
pamela.authenticate(username, data['password'], service=self.service)
|
||||||
except pamela.PAMError as e:
|
except pamela.PAMError as e:
|
||||||
if handler is not None:
|
if handler is not None:
|
||||||
self.log.warn("PAM Authentication failed (%s@%s): %s", username, handler.request.remote_ip, e)
|
self.log.warning("PAM Authentication failed (%s@%s): %s", username, handler.request.remote_ip, e)
|
||||||
else:
|
else:
|
||||||
self.log.warn("PAM Authentication failed: %s", e)
|
self.log.warning("PAM Authentication failed: %s", e)
|
||||||
else:
|
else:
|
||||||
return username
|
return username
|
||||||
|
|
||||||
@@ -396,8 +396,8 @@ class PAMAuthenticator(LocalAuthenticator):
|
|||||||
try:
|
try:
|
||||||
pamela.open_session(user.name, service=self.service)
|
pamela.open_session(user.name, service=self.service)
|
||||||
except pamela.PAMError as e:
|
except pamela.PAMError as e:
|
||||||
self.log.warn("Failed to open PAM session for %s: %s", user.name, e)
|
self.log.warning("Failed to open PAM session for %s: %s", user.name, e)
|
||||||
self.log.warn("Disabling PAM sessions from now on.")
|
self.log.warning("Disabling PAM sessions from now on.")
|
||||||
self.open_sessions = False
|
self.open_sessions = False
|
||||||
|
|
||||||
def post_spawn_stop(self, user, spawner):
|
def post_spawn_stop(self, user, spawner):
|
||||||
@@ -407,7 +407,7 @@ class PAMAuthenticator(LocalAuthenticator):
|
|||||||
try:
|
try:
|
||||||
pamela.close_session(user.name, service=self.service)
|
pamela.close_session(user.name, service=self.service)
|
||||||
except pamela.PAMError as e:
|
except pamela.PAMError as e:
|
||||||
self.log.warn("Failed to close PAM session for %s: %s", user.name, e)
|
self.log.warning("Failed to close PAM session for %s: %s", user.name, e)
|
||||||
self.log.warn("Disabling PAM sessions from now on.")
|
self.log.warning("Disabling PAM sessions from now on.")
|
||||||
self.open_sessions = False
|
self.open_sessions = False
|
||||||
|
|
||||||
|
@@ -154,14 +154,14 @@ class BaseHandler(RequestHandler):
|
|||||||
|
|
||||||
if cookie_id is None:
|
if cookie_id is None:
|
||||||
if self.get_cookie(cookie_name):
|
if self.get_cookie(cookie_name):
|
||||||
self.log.warn("Invalid or expired cookie token")
|
self.log.warning("Invalid or expired cookie token")
|
||||||
clear()
|
clear()
|
||||||
return
|
return
|
||||||
cookie_id = cookie_id.decode('utf8', 'replace')
|
cookie_id = cookie_id.decode('utf8', 'replace')
|
||||||
u = self.db.query(orm.User).filter(orm.User.cookie_id==cookie_id).first()
|
u = self.db.query(orm.User).filter(orm.User.cookie_id==cookie_id).first()
|
||||||
user = self._user_from_orm(u)
|
user = self._user_from_orm(u)
|
||||||
if user is None:
|
if user is None:
|
||||||
self.log.warn("Invalid cookie token")
|
self.log.warning("Invalid cookie token")
|
||||||
# have cookie, but it's not valid. Clear it and start over.
|
# have cookie, but it's not valid. Clear it and start over.
|
||||||
clear()
|
clear()
|
||||||
return user
|
return user
|
||||||
@@ -309,7 +309,7 @@ class BaseHandler(RequestHandler):
|
|||||||
if user.spawn_pending:
|
if user.spawn_pending:
|
||||||
# still in Spawner.start, which is taking a long time
|
# still in Spawner.start, which is taking a long time
|
||||||
# we shouldn't poll while spawn_pending is True
|
# we shouldn't poll while spawn_pending is True
|
||||||
self.log.warn("User %s server is slow to start", user.name)
|
self.log.warning("User %s server is slow to start", user.name)
|
||||||
# schedule finish for when the user finishes spawning
|
# schedule finish for when the user finishes spawning
|
||||||
IOLoop.current().add_future(f, finish_user_spawn)
|
IOLoop.current().add_future(f, finish_user_spawn)
|
||||||
else:
|
else:
|
||||||
@@ -319,7 +319,7 @@ class BaseHandler(RequestHandler):
|
|||||||
if status is None:
|
if status is None:
|
||||||
# hit timeout, but server's running. Hope that it'll show up soon enough,
|
# hit timeout, but server's running. Hope that it'll show up soon enough,
|
||||||
# though it's possible that it started at the wrong URL
|
# though it's possible that it started at the wrong URL
|
||||||
self.log.warn("User %s server is slow to become responsive", user.name)
|
self.log.warning("User %s server is slow to become responsive", user.name)
|
||||||
# schedule finish for when the user finishes spawning
|
# schedule finish for when the user finishes spawning
|
||||||
IOLoop.current().add_future(f, finish_user_spawn)
|
IOLoop.current().add_future(f, finish_user_spawn)
|
||||||
else:
|
else:
|
||||||
@@ -333,7 +333,7 @@ class BaseHandler(RequestHandler):
|
|||||||
status = yield user.spawner.poll()
|
status = yield user.spawner.poll()
|
||||||
if status is None:
|
if status is None:
|
||||||
status = 'unknown'
|
status = 'unknown'
|
||||||
self.log.warn("User %s server stopped, with exit code: %s",
|
self.log.warning("User %s server stopped, with exit code: %s",
|
||||||
user.name, status,
|
user.name, status,
|
||||||
)
|
)
|
||||||
yield self.proxy.delete_user(user)
|
yield self.proxy.delete_user(user)
|
||||||
@@ -364,7 +364,7 @@ class BaseHandler(RequestHandler):
|
|||||||
except gen.TimeoutError:
|
except gen.TimeoutError:
|
||||||
if user.stop_pending:
|
if user.stop_pending:
|
||||||
# hit timeout, but stop is still pending
|
# hit timeout, but stop is still pending
|
||||||
self.log.warn("User %s server is slow to stop", user.name)
|
self.log.warning("User %s server is slow to stop", user.name)
|
||||||
# schedule finish for when the server finishes stopping
|
# schedule finish for when the server finishes stopping
|
||||||
IOLoop.current().add_future(f, finish_stop)
|
IOLoop.current().add_future(f, finish_stop)
|
||||||
else:
|
else:
|
||||||
@@ -509,7 +509,7 @@ class CSPReportHandler(BaseHandler):
|
|||||||
@web.authenticated
|
@web.authenticated
|
||||||
def post(self):
|
def post(self):
|
||||||
'''Log a content security policy violation report'''
|
'''Log a content security policy violation report'''
|
||||||
self.log.warn("Content security violation: %s",
|
self.log.warning("Content security violation: %s",
|
||||||
self.request.body.decode('utf8', 'replace'))
|
self.request.body.decode('utf8', 'replace'))
|
||||||
|
|
||||||
default_handlers = [
|
default_handlers = [
|
||||||
|
@@ -123,10 +123,10 @@ class AdminHandler(BaseHandler):
|
|||||||
orders = self.get_arguments('order')
|
orders = self.get_arguments('order')
|
||||||
|
|
||||||
for bad in set(sorts).difference(available):
|
for bad in set(sorts).difference(available):
|
||||||
self.log.warn("ignoring invalid sort: %r", bad)
|
self.log.warning("ignoring invalid sort: %r", bad)
|
||||||
sorts.remove(bad)
|
sorts.remove(bad)
|
||||||
for bad in set(orders).difference({'asc', 'desc'}):
|
for bad in set(orders).difference({'asc', 'desc'}):
|
||||||
self.log.warn("ignoring invalid order: %r", bad)
|
self.log.warning("ignoring invalid order: %r", bad)
|
||||||
orders.remove(bad)
|
orders.remove(bad)
|
||||||
|
|
||||||
# add default sort as secondary
|
# add default sort as secondary
|
||||||
|
@@ -528,5 +528,5 @@ class LocalProcessSpawner(Spawner):
|
|||||||
status = yield self.poll()
|
status = yield self.poll()
|
||||||
if status is None:
|
if status is None:
|
||||||
# it all failed, zombie process
|
# it all failed, zombie process
|
||||||
self.log.warn("Process %i never died", self.pid)
|
self.log.warning("Process %i never died", self.pid)
|
||||||
|
|
||||||
|
@@ -228,7 +228,7 @@ class User(HasTraits):
|
|||||||
yield gen.with_timeout(timedelta(seconds=spawner.start_timeout), f)
|
yield gen.with_timeout(timedelta(seconds=spawner.start_timeout), f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, gen.TimeoutError):
|
if isinstance(e, gen.TimeoutError):
|
||||||
self.log.warn("{user}'s server failed to start in {s} seconds, giving up".format(
|
self.log.warning("{user}'s server failed to start in {s} seconds, giving up".format(
|
||||||
user=self.name, s=spawner.start_timeout,
|
user=self.name, s=spawner.start_timeout,
|
||||||
))
|
))
|
||||||
e.reason = 'timeout'
|
e.reason = 'timeout'
|
||||||
@@ -256,7 +256,7 @@ class User(HasTraits):
|
|||||||
yield self.server.wait_up(http=True, timeout=spawner.http_timeout)
|
yield self.server.wait_up(http=True, timeout=spawner.http_timeout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, TimeoutError):
|
if isinstance(e, TimeoutError):
|
||||||
self.log.warn(
|
self.log.warning(
|
||||||
"{user}'s server never showed up at {url} "
|
"{user}'s server never showed up at {url} "
|
||||||
"after {http_timeout} seconds. Giving up".format(
|
"after {http_timeout} seconds. Giving up".format(
|
||||||
user=self.name,
|
user=self.name,
|
||||||
|
@@ -78,14 +78,14 @@ def wait_for_http_server(url, timeout=10):
|
|||||||
if e.code != 599:
|
if e.code != 599:
|
||||||
# we expect 599 for no connection,
|
# we expect 599 for no connection,
|
||||||
# but 502 or other proxy error is conceivable
|
# but 502 or other proxy error is conceivable
|
||||||
app_log.warn("Server at %s responded with error: %s", url, e.code)
|
app_log.warning("Server at %s responded with error: %s", url, e.code)
|
||||||
yield gen.sleep(0.1)
|
yield gen.sleep(0.1)
|
||||||
else:
|
else:
|
||||||
app_log.debug("Server at %s responded with %s", url, e.code)
|
app_log.debug("Server at %s responded with %s", url, e.code)
|
||||||
return
|
return
|
||||||
except (OSError, socket.error) as e:
|
except (OSError, socket.error) as e:
|
||||||
if e.errno not in {errno.ECONNABORTED, errno.ECONNREFUSED, errno.ECONNRESET}:
|
if e.errno not in {errno.ECONNABORTED, errno.ECONNREFUSED, errno.ECONNRESET}:
|
||||||
app_log.warn("Failed to connect to %s (%s)", url, e)
|
app_log.warning("Failed to connect to %s (%s)", url, e)
|
||||||
yield gen.sleep(0.1)
|
yield gen.sleep(0.1)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user