Skip to content

Commit

Permalink
tkt-77710: fix(jail/fetch): Check for existence of plugin_index befor…
Browse files Browse the repository at this point in the history
…e second run (#2727)

* fix(jail/fetch): Check for existence of plugin_index before second run

The second run only succeeds because the directory would have caused an EOF, but afterwards results in duplicate creation of plugins

Ticket: #77710

* *cough*
  • Loading branch information
Brandon Schneider committed Mar 7, 2019
1 parent 6b72ed0 commit 95cb046
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/middlewared/middlewared/plugins/jail.py
Expand Up @@ -409,6 +409,7 @@ def fetch(self, job, options):
"""Fetches a release or plugin."""
fetch_output = {'install_notes': []}
release = options.get('release', None)

post_install = False

verrors = ValidationErrors()
Expand Down Expand Up @@ -467,13 +468,20 @@ def progress_callback(content, exception):
iocage = ioc.IOCage(callback=progress_callback, silent=False)

if options["name"] is not None:
# WORKAROUND until rewritten for #39653
# We want the plugins to not prompt interactively
try:
iocage.fetch(plugin_file=True, _list=True, **options)
except Exception:
# Expected, this is to avoid it later
pass
pool = IOCJson().json_get_value('pool')
iocroot = IOCJson(pool).json_get_value('iocroot')
plugin_index = pathlib.Path(
f'{iocroot}/.plugin_index'
)

if not plugin_index.is_dir():
# WORKAROUND until rewritten for #39653
# We want the plugins to not prompt interactively
try:
iocage.fetch(plugin_file=True, _list=True, **options)
except Exception:
# Expected, this is to avoid it later
pass

options["plugin_file"] = True
start_msg = 'Starting plugin install'
Expand All @@ -485,8 +493,6 @@ def progress_callback(content, exception):
iocage.fetch(**options)

if post_install and options['name'] is not None:
pool = IOCJson().json_get_value('pool')
iocroot = IOCJson(pool).json_get_value('iocroot')
plugin_manifest = pathlib.Path(
f'{iocroot}/.plugin_index/{options["name"]}.json'
)
Expand Down

0 comments on commit 95cb046

Please sign in to comment.