Merge pull request #1113 from canonical/fix_server_state_rerun

Fix reruning in production system_setup on WSL
This commit is contained in:
Didier Roche 2021-11-03 12:54:06 +01:00 committed by GitHub
commit 3d2be8f66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -68,14 +68,14 @@ def main():
need_start_server = False need_start_server = False
server_args = [] server_args = []
server_output_dir = "/var/log/installer" server_output_dir = "/var/log/installer"
server_state_file = "/run/subiquity/server-state"
if '--dry-run' in args: if '--dry-run' in args:
opts, unknown = parser.parse_known_args(args) opts, unknown = parser.parse_known_args(args)
server_state_file = ".subiquity/run/subiquity/server-state"
if opts.socket is None: if opts.socket is None:
need_start_server = True need_start_server = True
server_output_dir = '.subiquity' server_output_dir = '.subiquity'
sock_path = os.path.join(server_output_dir, 'socket') sock_path = os.path.join(server_output_dir, 'socket')
if os.path.exists('.subiquity/run/subiquity/server-state'):
os.unlink('.subiquity/run/subiquity/server-state')
opts.socket = sock_path opts.socket = sock_path
server_args = ['--dry-run', '--socket=' + sock_path] + unknown server_args = ['--dry-run', '--socket=' + sock_path] + unknown
else: else:
@ -90,6 +90,8 @@ def main():
server_output = open(os.path.join(server_output_dir, 'server-output'), 'w') server_output = open(os.path.join(server_output_dir, 'server-output'), 'w')
if need_start_server: if need_start_server:
if os.path.exists(server_state_file):
os.unlink(server_state_file)
server_parser = make_server_args_parser() server_parser = make_server_args_parser()
server_parser.parse_args(server_args) # just to check server_parser.parse_args(server_args) # just to check
server_cmd = [sys.executable, '-m', 'system_setup.cmd.server'] + \ server_cmd = [sys.executable, '-m', 'system_setup.cmd.server'] + \