Skip to content

Commit

Permalink
fixed handling undefined variable in schema string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Aug 27, 2023
1 parent 771d29c commit 475f041
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ task :server_ut do
ENV['POSTGRES_URL'] = "postgresql://kkut:kkut@localhost:15432/"
Dir.chdir('server') do
sh 'rm -f .coverage'
sh "../venv/bin/poetry run pytest --ignore=./tests/example_tool --cov-branch --cov=. -s -r A -vv #{ENV['test']}"
sh "../venv/bin/poetry run pytest --ignore=./tests/example_tool --cov-branch --cov=. -s --log-level=info -r A -vv #{ENV['test']}"
sh 'rm -rf htmlcov'
sh '../venv/bin/poetry run coverage html -i --omit=./tests/*'
end
Expand Down
5 changes: 3 additions & 2 deletions agent/kraken/agent/docker_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import io
import re
import sys
import time
import json
import struct
Expand Down Expand Up @@ -239,11 +240,11 @@ def stop(self):
try:
self.cntr.kill()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
try:
self.cntr.remove()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

def _async_run(self, cmd, deadline, cwd='/', user='root'):
logs, exit_code = asyncio.run(self._dkr_run(None, cmd, cwd, deadline, user))
Expand Down
2 changes: 1 addition & 1 deletion agent/kraken/agent/jobber.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async def _send_keep_alive_to_server(proc_coord):
try:
rsp = srv.keep_alive(proc_coord.job_id)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
continue
if rsp.get('cancel', False):
proc_coord.cancel()
Expand Down
3 changes: 2 additions & 1 deletion agent/kraken/agent/kraken_gotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import json
import queue
import logging
Expand All @@ -30,7 +31,7 @@ def _process_output(q, text):
data = json.loads(l)
except Exception:
log.error('failed parsing: %s', l)
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
continue

if 'Output' in data:
Expand Down
3 changes: 2 additions & 1 deletion agent/kraken/agent/local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import json
import time
import signal
Expand Down Expand Up @@ -128,7 +129,7 @@ async def _async_pump_output(self, stream):
try:
line = await stream.readline()
except ValueError:
log.exception('IGNORED')
log.warning('IGNORED', exc_info=sys.exc_info())
continue
if line:
line = line.decode().rstrip()
Expand Down
5 changes: 3 additions & 2 deletions agent/kraken/agent/lxd_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
import re
import sys
import json
import time
import shlex
Expand Down Expand Up @@ -147,11 +148,11 @@ def stop(self):
try:
self.cntr.stop(wait=True)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
try:
self.cntr.delete(wait=True)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

def get_return_ip_addr(self):
return self.lab_net.config['ipv4.address'].split('/')[0]
Expand Down
5 changes: 3 additions & 2 deletions agent/kraken/agent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import time
import subprocess
import logging
Expand Down Expand Up @@ -208,7 +209,7 @@ def is_in_docker():
if 'docker' in fields[1]:
return True
except Exception:
log.exception('IGNORED')
log.warning('IGNORED', exc_info=sys.exc_info())
return False


Expand All @@ -220,7 +221,7 @@ def is_in_lxc():
if '.lxc' in fields[1]:
return True
except Exception:
log.exception('IGNORED')
log.warning('IGNORED', exc_info=sys.exc_info())
return False


Expand Down
7 changes: 4 additions & 3 deletions server/kraken/server/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import json
import time
import logging
Expand Down Expand Up @@ -868,7 +869,7 @@ def _handle_host_info(agent, req): # pylint: disable=unused-argument
db.session.commit()
except IntegrityError as e:
if not isinstance(e.orig, UniqueViolation):
log.exception('IGNORED')
log.warning('IGNORED', exc_info=sys.exc_info())

return resp

Expand Down Expand Up @@ -904,8 +905,8 @@ def _handle_unknown_agent(address, ip_address, agent):
db.session.commit()
if new:
log.info('created new agent instance %s for address %s', agent, address)
except Exception as e:
log.warning('IGNORED EXCEPTION: %s', str(e))
except Exception:
log.warning('IGNORED', exc_info=sys.exc_info())


def _serve_agent_request():
Expand Down
3 changes: 2 additions & 1 deletion server/kraken/server/bg/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import json
import time
import logging
Expand Down Expand Up @@ -1051,7 +1052,7 @@ def spawn_new_agents(agents_group_id):
try:
_, depl = ag.get_deployment()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
return

# check if limit of agents is reached
Expand Down
11 changes: 6 additions & 5 deletions server/kraken/server/cloud/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import logging
import datetime

Expand Down Expand Up @@ -72,7 +73,7 @@ def create_vms(ag, system, num,
try:
sec_grp = ec2.describe_security_groups(GroupNames=[grp_name])
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
if not sec_grp:
rsp = requests.get('https://checkip.amazonaws.com')
my_ip = rsp.text.strip()
Expand Down Expand Up @@ -160,7 +161,7 @@ def create_vms(ag, system, num,
try:
i.wait_until_running()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
continue
i.load()
name = '.'.join(i.public_dns_name.split('.')[:2])
Expand Down Expand Up @@ -189,7 +190,7 @@ def destroy_vm(ag, agent): # pylint: disable=unused-argument
i = ec2.Instance(instance_id)
i.terminate()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())


def vm_exists(ag, agent):
Expand Down Expand Up @@ -232,7 +233,7 @@ def cleanup_dangling_vms(ag):
vms = ec2.instances.filter(Filters=[{'Name': 'tag:kraken-group', 'Values': ['%d' % ag.id]}])
vms = list(vms)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
return 0, 0, 0, 0, 0

instances = 0
Expand Down Expand Up @@ -272,7 +273,7 @@ def cleanup_dangling_vms(ag):
try:
vm.terminate()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

orphaned_terminated_instances += 1

Expand Down
5 changes: 3 additions & 2 deletions server/kraken/server/cloud/aws_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import time
import logging

Expand Down Expand Up @@ -163,7 +164,7 @@ def create_fargate_tasks(ag, system, num,
task=t,
reason='stopping other tasks due to an error')
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

for task in tasks_ready:
address = task['address']
Expand Down Expand Up @@ -192,4 +193,4 @@ def destroy_fargate_task(ag, agent): # pylint: disable=unused-argument
task=task_arn,
reason='stopping task that completed the job')
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
3 changes: 2 additions & 1 deletion server/kraken/server/cloud/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import base64
import random
import logging
Expand Down Expand Up @@ -490,7 +491,7 @@ def cleanup_dangling_vms(ag): # pylint: disable=unused-argument
try:
_destroy_azure_vm(rg, vm.name, cc, nc)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

orphaned_terminated_instances += 1

Expand Down
7 changes: 4 additions & 3 deletions server/kraken/server/cloud/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import time
import base64
import logging
Expand Down Expand Up @@ -203,7 +204,7 @@ def destroy_pod(ag, agent): # pylint: disable=unused-argument
try:
core_api.delete_namespaced_pod(pod_name, namespace)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())


def pod_exists(ag, agent): # pylint: disable=unused-argument
Expand All @@ -216,7 +217,7 @@ def pod_exists(ag, agent): # pylint: disable=unused-argument
try:
core_api.read_namespaced_pod(pod_name, namespace)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
return False

return True
Expand Down Expand Up @@ -260,7 +261,7 @@ def cleanup_dangling_pods(ag):
try:
core_api.delete_namespaced_pod(pod.metadata.name, namespace)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

orphaned_terminated_instances += 1

Expand Down
3 changes: 2 additions & 1 deletion server/kraken/server/kkrq.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import os
import sys
import json
import logging

Expand Down Expand Up @@ -85,7 +86,7 @@ def _exception_handler(job, exc_type, exc_value, traceback): # pylint: disable=
for ex in ignore_excs:
if ex in str(exc_value) or ex in str(traceback):
return
log.exception('IGNORED')
log.warning('IGNORED', exc_info=sys.exc_info())


def main():
Expand Down
7 changes: 4 additions & 3 deletions server/kraken/server/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import json
import logging
import smtplib
Expand Down Expand Up @@ -260,21 +261,21 @@ def notify(run, event):
try:
_notify_slack(run, event, slack)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

# email
email = notification.get('email', None)
try:
_notify_email(run, event, email)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())

# github
github = notification.get('github', None)
try:
_notify_github(run, event, github)
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())


def check_email_settings():
Expand Down
5 changes: 3 additions & 2 deletions server/kraken/server/qneck.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import os
import sys
import time
import json
import logging
Expand Down Expand Up @@ -127,7 +128,7 @@ def _main_loop():
executing_jobs[key] = job

except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
time.sleep(1)


Expand All @@ -138,7 +139,7 @@ def main():
try:
_main_loop()
except Exception:
log.exception('IGNORED EXCEPTION')
log.warning('IGNORED', exc_info=sys.exc_info())
time.sleep(10)


Expand Down
Loading

0 comments on commit 475f041

Please sign in to comment.