Race condition while running auto_lint.py

Bug #1991897 reported by Mert Kirpici
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

There is a code block that ensures there's only one instance of the `auto_lint.py` process executing at any given moment. Usually this script is run on a cronjob, which is installed to the system during the install hook of the juju-lint charm. I said "usually" because there are two instances where this script is run as a subprocess by the charm itself:
1 - during install: after the cronjob installation is completed, the script is run once.
2 - during config-changed.

If any of these hooks are running while the cronjob is also running, the charm code is crashing, which is not very graceful.

Output taken from LP #1990992

unit-juju-lint-0: 23:00:03 ERROR unit.juju-lint/0.juju-log auto_lint.py failed with this output:
/var/lib/juju/agents/unit-juju-lint-0/charm/venv/juju/loop.py:4: UserWarning: juju.loop module is being deprecated by 3.0, use juju.jasyncio instead
  warnings.warn('juju.loop module is being deprecated by 3.0, use juju.jasyncio instead')
/var/lib/juju/agents/unit-juju-lint-0/charm/venv/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
  "class": algorithms.Blowfish,
/tmp/auto_lint.pid already exists, exiting

unit-juju-lint-0: 23:00:03 ERROR unit.juju-lint/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "./src/charm.py", line 125, in <module>
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/venv/ops/main.py", line 431, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/venv/ops/main.py", line 142, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/venv/ops/framework.py", line 283, in emit
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/venv/ops/framework.py", line 743, in _emit
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/venv/ops/framework.py", line 790, in _reemit
  File "./src/charm.py", line 91, in on_config_changed
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/lib/lib_jujulint.py", line 183, in run_auto_lint
    raise error
  File "/var/lib/juju/agents/unit-juju-lint-0/charm/lib/lib_jujulint.py", line 173, in run_auto_lint
    subprocess.check_output([lint_script], stderr=subprocess.STDOUT).decode(
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/auto_lint.py']' returned non-zero exit status 1.
unit-juju-lint-0: 23:00:04 ERROR juju.worker.uniter.operation hook "config-changed" (via hook dispatching script: dispatch) failed: exit status 1

Tags: bseng-463
Eric Chen (eric-chen)
tags: added: bseng-463
Changed in charm-juju-lint:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.