This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 673394 - Flex Guest unable to subscribe to child channel if regular entitlement runs out, even if flex guest entitlements available
Flex Guest unable to subscribe to child channel if regular entitlement runs o...
Status: CLOSED ERRATA
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Virtualization (Show other bugs)
540
All Linux
high Severity medium
: ---
: ---
Assigned To: Milan Zazrivec
Jan Hutař
: Reopened
Depends On:
Blocks: sat54-errata
  Show dependency treegraph
 
Reported: 2011-01-27 21:22 EST by Xixi
Modified: 2012-04-02 08:23 EDT (History)
6 users (show)

See Also:
Fixed In Version: spacewalk-java-1.2.39-37
Doc Type: Bug Fix
Doc Text:
Cause: A bug in the way the server computes number of available channel subscriptions. Consequence: The server would disallow a flex guest eligible system to be subscribed to a child channel if regular entitlements ran out even if there were flex guest entitlements available. Fix: The fix was a bit invasive. Result: Results of channel subscription now reflect the status of available flex / regular entitlements.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-11-07 04:55:57 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Xixi 2011-01-27 21:22:32 EST
Description of problem:
On System Details -> Software -> Software Channels page
(rhn/systems/details/SystemChannels.do), trying to subscribe a flex guest system to a child channel will fail if the regular entitlement for that channel is 0, even if there're plenty of flex guest entitlement available.

Version-Release number of selected component (if applicable):
Red Hat Network (RHN) Satellite 5.4.0

How reproducible:
Always.

Steps to Reproduce:
1. Have 5.4 satellite with both regular and flex guest entitlements.
2. Subscribe a KVM guest (running on an unsubscribed RHEL host) to
rhel-x86_64-server-5.
3. Verify that it consumes a flex guest entitlement for the base channel's
channel family.
4. Overview > Subscription Management > Software Channel Entitlements shows the
RHN tools child channel has 1 regular entitlement available and 100 flex
entitlements available:
"Channel Entitlement: Red Hat Network Tools for Red Hat Enterprise Linux
Regular Consumed: 1  
Regular Available: 1 
Consumed Flex Guests: 0   
Available Flex Guests: 100
Systems Subscribed: 1"
5.Go to the system profile's Software > Software Channels tab, and see that the
number of available "regular" entitlements is displayed for the system, even
though it should be able to consume flex guest entitlements:
"Red Hat Network Tools for RHEL Server (v.5 64-bit x86_64) (1 available)"
6.Subscribe the system to this child channel, and note that the # available
stays at 1
"Red Hat Network Tools for RHEL Server (v.5 64-bit x86_64) (1 available)"
and that the Software Channel Entitlements page shows that a flex guest
entitlement has been consumed:
"Channel Entitlement: Red Hat Network Tools for Red Hat Enterprise Linux  
Regular Consumed: 1  
Regular Available: 1  
Consumed Flex Guests: 1  
Available Flex Guests: 99  
Systems Subscribed: 2"
7. Now, unsubscribe this flex guest system from the Tools child channel, and subscribe another non-flex guest system to the Tools channel, so that the last remaining regular entitlement is consumed. The software channel entitlements is updated as expected:
"Channel Entitlement: Red Hat Network Tools for Red Hat Enterprise Linux
Regular Consumed: 2
Regular Available: 0
Consumed Flex Guests: 0
Available Flex Guests: 100
Systems Subscribed: 2"
8. Try again to subscribe the original flex guest system to the Tools channel. Note that the child channel shows "0 available":
"Red Hat Network Tools for RHEL Server (v.5 64-bit x86_64) (0 available)"
If you check the child channel and click "Change Subscriptions", then a red banner message appears at the top of the page:
"Note: Some channel subscriptions could not be updated because there were no available subscriptions."
and the attempted Tools channel subscription fails.

Actual results:
For flex guest system, subscribing to child channel with available flex entitlements fails if regular entitlements == 0 

Expected results:
For flex guest system, subscribing to child channel with available flex entitlements succeeds

Additional info:
Comment 1 Xixi 2011-01-27 21:26:23 EST
The bug is due to SystemManager.canServerSubscribeToChannel() using ChannelManager.getAvailableEntitlements to check for available subscriptions which only returns regular entitlements.  If the server is a flex guest, it should check for flex guest entitlements.

code/src/com/redhat/rhn/manager/system/SystemManager.java
...
    public static boolean canServerSubscribeToChannel(Org orgIn, Server serverIn,
            Channel channelIn) {

        if (serverIn.isSubscribed(channelIn)) {
            log.debug("already subscribed.  return true");
            return true;
        }

        // If channel is free for this guest, dont check avail subs
        if (ChannelManager.isChannelFreeForSubscription(serverIn, channelIn)) {
            log.debug("its a free channel for this server, returning true");
            return true;
        }

        // Otherwise check available subs
        Long availableSubscriptions =
            ChannelManager.getAvailableEntitlements(orgIn, channelIn);

        if (availableSubscriptions != null &&
                (availableSubscriptions.longValue() < 1)) {
            log.debug("avail subscriptions is to small : " + availableSubscriptions);
            return false;
        }
        log.debug("canServerSubscribeToChannel true!");
        return true;
    }
...


Adding the following log4j debug:
log4j.logger.com.redhat.rhn.manager.system=DEBUG
log4j.logger.com.redhat.rhn.manager.channel=DEBUG
log4j.logger.com.redhat.rhn.frontend.action.systems.sdc.SystemChannelsAction=DEBUG

shows:
2011-01-27 16:25:22,147 [TP-Processor3] DEBUG com.redhat.rhn.frontend.action.systems.sdc.SystemChannelsAction - Adding child id: 223
2011-01-27 16:25:22,197 [TP-Processor3] DEBUG com.redhat.rhn.manager.system.UpdateChildChannelsCommand - subscribing to new channels
2011-01-27 16:25:22,205 [TP-Processor3] DEBUG com.redhat.rhn.manager.system.UpdateChildChannelsCommand - checking to see if we can sub: rhn-tools-rhel-x86_64-server-5
2011-01-27 16:25:22,205 [TP-Processor3] DEBUG com.redhat.rhn.manager.channel.ChannelManager - isChannelFreeForSubscription.start: rhn-tools-rhel-x86_64-server-5
2011-01-27 16:25:22,207 [TP-Processor3] DEBUG com.redhat.rhn.manager.channel.ChannelManager - levels   : [com.redhat.rhn.domain.common.VirtSubscriptionLevel@ed75e132, com.redhat.rhn.domain.common.VirtSubscriptionLevel@8051b3cd]
2011-01-27 16:25:22,207 [TP-Processor3] DEBUG com.redhat.rhn.manager.channel.ChannelManager - host is null, returning false
2011-01-27 16:25:22,209 [TP-Processor3] DEBUG com.redhat.rhn.manager.channel.ChannelManager - getAvailableEntitlements: rhn-tools-rhel-x86_64-server-5 got: 0
2011-01-27 16:25:22,209 [TP-Processor3] DEBUG com.redhat.rhn.manager.system.SystemManager - avail subscriptions is to small : 0
2011-01-27 16:25:22,209 [TP-Processor3] DEBUG com.redhat.rhn.manager.system.UpdateChildChannelsCommand - we can't subscribe to the channel.
Comment 5 Xixi 2011-02-15 15:59:54 EST
Workaround is to make sure at least one regular entitlement exists for that child channel.
Comment 7 Milan Zazrivec 2011-02-24 08:36:37 EST
spacewalk.git master: 009afe5bf9fa73a050d3516c09437ba2d5f2c157
Comment 8 Milan Zazrivec 2011-02-24 09:02:24 EST
satellite.git master: 357c5e6cfc4544c19975faf691bfe9211450d811
Comment 9 Milan Zazrivec 2011-02-24 09:13:25 EST
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: A bug in the way the server computes number of available channel subscriptions.

Consequence: The server would disallow a flex guest eligible system to be subscribed to a child channel if regular entitlements ran out even if there were flex guest entitlements available.

Fix: The fix was a bit invasive.

Result: Results of channel subscription now reflect the status of available flex / regular entitlements.
Comment 11 Jan Hutař 2011-03-03 05:00:57 EST
What I see with OLD packages, slightly differs from what is described in comment #0. This is what I see:

1. Have 5.4 satellite with both regular and flex guest entitlements
     Subscriptions -> System Entitlements
       Management (Base): 10
     Subscriptions -> Software Channel Entitlements
       Red Hat Enterprise Linux (core server):
         Regular Proposed Total: 1
         Flex Proposed Total: 10
       Red Hat Network Tools for Red Hat Enterprise Linux:
         Regular Proposed Total: 1
         Flex Proposed Total: 10
2. Subscribe a KVM guest (running on an unsubscribed RHEL host)
   to rhel-i386-server-5
3. Verify that it consumes a flex guest entitlement for the base
   channel's channel family
     Details page shows: Virtualization: KVM/QEMU
     Overview
       -> Subscription Management
         -> Virtualization Entitlements
           -> Guests Without Hosts
             system is there
           -> Flex Guest Entitlement Consumers
             system is there
         -> Software Channel Entitlements shows:
           -> Red Hat Enterprise Linux (core server)
             Regular Consumed: 0
             Regular Available: 1
             Consumed Flex Guests: 1
             Available Flex Guests: 9
             Systems Subscribed: 1
4. Add RHN Tools channel to the system in
   Details -> Software -> Software Channels
   Note there is "(1 available)" althought you have 1 regular
   and 10 flex
5. Note that it consumes a regular child channel's channel family
     Overview
       -> Subscription Management
         -> Software Channel Entitlements shows:
           -> Red Hat Network Tools for Red Hat Enterprise Linux
             Regular Consumed: 1
             Regular Available: 0
             Consumed Flex Guests: 0
             Available Flex Guests: 10
             Systems Subscribed: 1
   But as this is a flex system, it should consume flex variant
7. Register second FLEX-able system (I have just re-registered first
   one)
6. Go to the system profile's Software > Software Channels tab of
   new system, and see that the number of available "regular"
   entitlements is displayed for the system, even though it should
   be able to consume flex guest entitlements:
     Red Hat Network Tools for RHEL Server (v.5 32-bit x86) (0 available)

But generally, this is what I see and what I'm going to verify:

> Actual results:
> For flex guest system, subscribing to child channel with available flex
> entitlements fails if regular entitlements == 0 
> 
> Expected results:
> For flex guest system, subscribing to child channel with available flex
> entitlements succeeds
Comment 12 Jan Hutař 2011-03-03 05:48:02 EST
Hello,
using NEW packages (spacewalk-java-1.2.39-38.el5sat) I have done this and got ISE:

1) have RHEL base entitlements: 1 regular + 10 flex
        RHN Client Tools ents: 1 regular + 10 flex
2) register flex-able (host not registered) KVM guest
   => flex base consumed (PASS)
3) subscribed to RHN Client Tools channel
   => regular used (FAIL)
4) register that guest again to get another profile
5) new guest consumes flex base (PASS)
6) go to "Alter Channel Subscriptions" and check number of available
   RHN Client Tools entitlements
   (10 available) => flex bunch displayed (PASS)
7) now add RHN Client Tools channel for that new guest
   => Internal Server Error (FAIL)

http://pastebin.test.redhat.com/42813

Note for myself: I have to check on non-virtual system that only regular ones are displayed as available.
Comment 13 Milan Zazrivec 2011-03-03 06:17:55 EST
Are you sure the Satellite in question does have errata
http://rhn.redhat.com/errata/RHBA-2011-0156.html applied correctly?
Comment 14 Jan Hutař 2011-03-03 06:36:22 EST
You are right, that was the issue. Thanks!
Comment 15 Jan Hutař 2011-03-04 01:37:30 EST
I have reported bug 681844 - but it is not 100% reproducible and I do not think it is a regression from OLD to NEW.
Comment 16 Jan Hutař 2011-03-04 01:46:05 EST
With http://rhn.redhat.com/errata/RHBA-2011-0156.html applied correctly, I see this bug PASS correctly:

1) have RHEL base entitlements: 1 regular + 10 flex
        RHN Client Tools ents: 1 regular + 10 flex
2) register flex-able (host not registered) KVM guest
   => flex base consumed (PASS)
3) subscribed to RHN Client Tools channel
   => flex used (PASS)
4) register that guest again to get another profile
5) new guest consumes flex base (PASS)
6) go to "Alter Channel Subscriptions" and check number of available
   RHN Client Tools entitlements
   (9 available) => flex bunch displayed (PASS)
7) now add RHN Client Tools channel for that new guest
   => flex used (PASS)

I have also checked physical system consumes physical entitlement and displays correct physical available count.
Comment 17 Jan Hutař 2011-03-04 02:37:02 EST
Also reported bug 682112 discovered during this. That one was reproduced on OLD, so it is not a regression.
Comment 18 errata-xmlrpc 2011-03-17 10:11:26 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0362.html

Note You need to log in before you can comment on or make changes to this bug.