Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2066555

Summary: Backport 'Change to a proper policy for Resume operation'
Product: Red Hat OpenStack Reporter: Keigo Noha <knoha>
Component: python-django-horizonAssignee: Radomir Dopieralski <rdopiera>
Status: CLOSED ERRATA QA Contact: ikanias
Severity: medium Docs Contact:
Priority: medium    
Version: 16.2 (Train)CC: rdopiera
Target Milestone: z3Keywords: Triaged
Target Release: 16.2 (Train on RHEL 8.4)   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: python-django-horizon-16.2.3-2.20220404205507.3153a5b.el8ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-22 16:06:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Keigo Noha 2022-03-22 04:08:43 UTC
Description of problem:
While the customer wants to disable resume operation for users through horizon, changing the nova policy has a side effect to 'resume an instance'.

The current implementation in stable/train checked the wrong nova policy for resuming an instance.

~~~
    290 class ToggleSuspend(tables.BatchAction):
    291     name = "suspend"
    292     classes = ("btn-suspend",)
    293 
    294     @staticmethod
    295     def action_present(count):
    296         return (
    297             ungettext_lazy(
    298                 u"Suspend Instance",
    299                 u"Suspend Instances",
    300                 count
    301             ),
    302             ungettext_lazy(
    303                 u"Resume Instance",
    304                 u"Resume Instances",
    305                 count
    306             ),
    307         )
    308 
    309     @staticmethod
    310     def action_past(count):
    311         return (
    312             ungettext_lazy(
    313                 u"Suspended Instance",
    314                 u"Suspended Instances",
    315                 count
    316             ),
    317             ungettext_lazy(
    318                 u"Resumed Instance",
    319                 u"Resumed Instances",
    320                 count
    321             ),
    322         )
    323 
    324     def allowed(self, request, instance=None):
    325         if not api.nova.extension_supported('AdminActions',
    326                                             request):
    327             return False
    328         if not instance:
    329             return False
    330         self.suspended = instance.status == "SUSPENDED"
    331         if self.suspended:
    332             self.current_present_action = RESUME
    333             policy_rules = (
    334                 ("compute", "os_compute_api:os-rescue"),)
    335         else:
    336             self.current_present_action = SUSPEND
    337             policy_rules = (
    338                 ("compute", "os_compute_api:os-suspend-server:suspend"),)
    339 
    340         has_permission = policy.check(
    341             policy_rules, request,
    342             target={'project_id': getattr(instance, 'tenant_id', None)})
    343 
    344         return (has_permission and
    345                 (instance.status in ACTIVE_STATES or self.suspended) and
    346                 not is_deleting(instance))
~~~

To fix this, we need to backport https://review.opendev.org/c/openstack/horizon/+/831903 into RHOSP16.1 and 16.2.


Version-Release number of selected component (if applicable):
The current horizon in OSP16.1 and OSP16.2

How reproducible:
Everytime to try to resume an instance from suspended state.

Steps to Reproduce:
1. Deploy RHOSP16.1 or OSP16.2.
2. Change nova_policy.json for os-rescue from rule:admin_or_owner to rule:admin_api.
3. Launch an instance and suspend it from horizon then try to resume the instance.

Actual results:
'Resume an instance' in the menu isn't shown.

Expected results:
'Resume an instance' is shown.

Additional info:
Upstream LP: https://bugs.launchpad.net/horizon/+bug/1963652
Uptream Gerrit: https://review.opendev.org/c/openstack/horizon/+/831903

Comment 9 errata-xmlrpc 2022-06-22 16:06:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Release of components for Red Hat OpenStack Platform 16.2.3 (Train)), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:4793