Fix delete when failed to upload

Bug #2068926 reported by Lindley Werner Soares Vieira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Low
Lindley Werner Soares Vieira

Bug Description

Brief Description
-----------------
If for some reason 'software upload <patch>' fails, 'software delete'
must be able to fully delete the load. In the case it tries to
delete a package from apt-ostree and does not find the component, it
means that the package does not exist, so it does not need to be
deleted.

Severity
--------
Minor: System/Feature is usable with minor issue

Steps to Reproduce
------------------
Software upload <patch> (fail)

software delete <patch>

Expected Behavior
------------------

The patch to be deleted

Actual Behavior
----------------

Error

Reproducibility
---------------

Intermittent: Just when upload fails

Timestamp/Logs
-------------

2024-06-05T20:49:01: software-controller-daemon[3040:139985734858496]: software_controller.py(1590): INFO: Deleting releases: starlingx-24.09.1
2024-06-05T20:49:01: software-controller-daemon[3040:139985734858496]: apt_utils.py(57): INFO: Removing package: kpatch-kmod-rt
2024-06-05T20:49:02: software-controller-daemon[3040:139985734858496]: apt_utils.py(71): ERROR: "apt-ostree repo remove" error: return code 1 , Output: Error: Component '24.09.1' as given to --component is not know.
(it does not appear as component in /var/www/pages/updates/debian/rel-24.09/conf/distributions (did you mistype?))
There have been errors!
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apt_ostree/utils.py", line 30, in run_command
    return subprocess.run(
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['reprepro', '-b', '/var/www/pages/updates/debian/rel-24.09', '-C', '24.09.1', 'remove', 'bullseye', 'kpatch-kmod-rt']' returned non-zero exit status 255.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/apt-ostree", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/apt_ostree/cmd/shell.py", line 47, in main
    cli(prog_name="apt-ostree")
  File "/usr/lib/python3/dist-packages/click/core.py", line 829, in _call_
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/apt_ostree/cmd/repo/remove.py", line 29, in remove
    Repo(state).remove()
  File "/usr/lib/python3/dist-packages/apt_ostree/repo.py", line 127, in remove
    r = utils.run_command(
  File "/usr/lib/python3/dist-packages/apt_ostree/utils.py", line 45, in run_command
    % (e.returncode, e.stderr.decode("utf-8"))
AttributeError: 'NoneType' object has no attribute 'decode'

2024-06-05T20:49:02: software-controller-daemon[3040:139985734858496]: utils.py(62): ERROR: Failed to remove package.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/software/apt_utils.py", line 59, in package_remove
    subprocess.run(
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['apt-ostree', 'repo', 'remove', '--feed', '/var/www/pages/updates/debian/rel-24.09', '--release', 'bullseye', '--component', '24.09.1', 'kpatch-kmod-rt']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pecan/core.py", line 683, in _call_
    self.invoke_controller(controller, args, kwargs, state)
  File "/usr/lib/python3/dist-packages/pecan/core.py", line 574, in invoke_controller
    result = controller(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/software/api/controllers/v1/release.py", line 99, in delete
    result = sc.software_release_delete_api(list(args))
  File "/usr/lib/python3/dist-packages/software/software_controller.py", line 1612, in software_release_delete_api
    apt_utils.package_remove(package_repo_dir, release.sw_release, packages)
  File "/usr/lib/python3/dist-packages/software/apt_utils.py", line 72, in package_remove
    raise APTOSTreeCommandFail(msg)
software.exceptions.APTOSTreeCommandFail: Failed to remove package.

Changed in starlingx:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to update (master)

Reviewed: https://review.opendev.org/c/starlingx/update/+/921522
Committed: https://opendev.org/starlingx/update/commit/d5ce2ba16d388ef34d33232fe5c75b5903e8329b
Submitter: "Zuul (22348)"
Branch: master

commit d5ce2ba16d388ef34d33232fe5c75b5903e8329b
Author: Lindley Werner <email address hidden>
Date: Fri Jun 7 10:29:13 2024 -0300

    Fix delete when failed to upload

    If for some reason 'software upload <patch>' fails, 'software delete'
    must be able to fully delete the load. In the case it tries to
    delete a package from apt-ostree and does not find the component, it
    means that the package does not exist, so it does not need to be
    deleted.

    Test plan:
    PASS: Delete a patch after 'software upload' fails

    Closes-bug: 2068926

    Change-Id: I2b0559628182d6716e2aa0a15de57898e003fe67
    Signed-off-by: Lindley Werner <email address hidden>

Changed in starlingx:
status: In Progress → Fix Released
Ghada Khalil (gkhalil)
Changed in starlingx:
importance: Undecided → Low
tags: added: stx.10.0 stx.update
Changed in starlingx:
assignee: nobody → Lindley Werner Soares Vieira (lindley-vieira)
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.