Bug 737935 - implement alternate guest uuid upload method
Summary: implement alternate guest uuid upload method
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 0.5
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: ---
Assignee: Bryan Kearney
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: rhsm-rhel62 743823
TreeView+ depends on / blocked
 
Reported: 2011-09-13 12:38 UTC by Radek Novacek
Modified: 2016-12-01 00:29 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 743823 (view as bug list)
Environment:
Last Closed: 2012-07-17 13:04:31 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 738678 0 unspecified CLOSED subscription-manager facts --update will override virt.guests made by virt-who 2021-02-22 00:41:40 UTC

Internal Links: 738678

Description Radek Novacek 2011-09-13 12:38:51 UTC
Description of problem:
Facts in candlepin database is limited to 255 characters. virt-who stores list of UUIDs of virtual machines in the fact virt.guests. More then 6 virtual guests present means that list of UUIDs is longer then 255 characters and can't be written to database.

How reproducible:
Try to store fact longer than 255 characters to candlepin database (run virt-who with more then 6 virtual guests)

Actual results:
rhsm.connection.RestlibException: Runtime Error could not insert collection: [org.fedoraproject.candlepin.model.Consumer.facts#8a90f8c6325fd85c013262a532911990] at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598


Expected results:
Fact is successfully written to database.

Comment 1 Chris Duryee 2011-09-26 16:40:45 UTC
Radek,

There are some technical limitations on the length of facts, like DB column length. Instead, given the number of UUIDs that might be reported by a host, we made a new rest call for reporting guest UUIDs associated with a consumer.

The change to virt-who should be relatively straightforward, and will avoid some of the issues we ran into when using facts (for example, https://bugzilla.redhat.com/show_bug.cgi?id=738678).

The new calls are as such:

get a list of all UUIDs:
GET /consumers/#{consumer_id}/guests

add a UUID to a consumer:
PUT /consumers/#{consumer_id}/guests/#{guest_id}

remove a UUID from a consumer:
DELETE /consumers/#{consumer_id}/guests/#{guest_id}

If you need more info, we can supply a patch for virt-who to alter it for the new calls, just let us know.

Comment 2 Radek Novacek 2011-09-27 08:00:46 UTC
Chris,

is this feature already implemented? I doesn't work for me with current master branch from git on fedorahosted.

Comment 3 Chris Duryee 2011-09-27 13:56:44 UTC
Try again, It just got pushed a few minutes ago.

hash is a6fcfb08cf32ce128c41caf85d578bf0ada4aea6

Comment 4 Devan Goodwin 2011-09-27 19:41:55 UTC
We've been discussing this afternoon, we're thinking that an explicit add/remove is going to be too error prone and easy to miss an event. We'd like to switch to pushing the entire list instead on each update.

Additionally I was wondering if virt-who will only do this when it detects an added/removed guest? Should/can it also do this periodically?

We were wondering about he risk of a missed add/remove event somehow, and if we should also mix in a periodic update as well. (if not virt-who, then perhaps by subscription-manager, who would get the list of guests from virt-who)

Thoughts?

Comment 5 Radek Novacek 2011-09-29 06:28:49 UTC
virt-who has 3 modes of running:

1) get list of guests, send them to candlepin and exit
2) on system with libvirt (not available with vdsm) it can listen for guest events (add/remove) and send only when needed
3) send guest list in specified interval

Since virt-who can run in 1) mode, it always reads the list of guest UUIDs from candlepin before updating it. When there is no change, no update is send.

If some add/remove event get lost somehow, in mode 2) next update can take very long time (until some libvirt event happens).

Comment 6 Devan Goodwin 2011-09-29 12:32:37 UTC
Which would you prefer as the most resilient and easiest to work with on our end:

- Add/Remove one guest ID at a time.

- Submit entire guest ID list. (whenever we detect add/remove events, or at an interval)

Comment 7 Chris Duryee 2011-10-04 19:41:32 UTC
9fbbe091c23f35c7782cf31f892ed5ea0159ae11 master 0.97.2+
75c647a RHEL6.2 0.97.13+

Comment 8 Chris Duryee 2011-10-04 20:32:11 UTC
in order to test this, you can do a PUT call to the consumer resource with the following (any UUIDs will work):

{"guestIds": ["53dddf75-9aba-bb66-ee79-fca18a0406aa", "58cb255e-2707-8ef3-4913-405bb4b7e58e", "7700b88b-561d-3eaa-2a6c-dd774612ac30", "86e9f8cc-95f5-8a8e-5f19-ca0e2da1f1e4", "cec855c2-6eb3-c7a6-831f-2339db1b7c92"]}

Then, you should see the UUIDs in cp_consumer_guest table.

Comment 12 John Sefler 2011-10-10 22:05:45 UTC
Due to dev design change, the appropriate component for this bug is entitlements/candlepin since this is now all a Candlepin API call (not python-rhsm nor subscription-manager).  changing now component now...

move to MODIFIED/ON_QA when the code gets merged to candlpin master.  I'm told it is currently in wottop-virt-guest branch.

Comment 14 Radek Novacek 2011-10-11 05:39:10 UTC
The patch for virt-who is ready, just waiting for exception+. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=743823

Comment 15 Keqin Hong 2011-10-17 11:15:52 UTC
Hi,
candlepin has only "PUT /consumers/{consumer_uuid}/guests/{guest_uuid}" REST API define. However, python-rhsm's current code doesn't match it. Is there any plan to update it?
//candlepin
$ git show a6fcfb08cf32ce128c41caf85d578bf0ada4aea6

+    @PUT
+    @Path("/{consumer_uuid}/guests/{guest_uuid}")
+    public void addGuest(
+        @PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid,
+        @PathParam("guest_uuid") String guestId) {
+        if (guestId == null) {
+            throw new BadRequestException(i18n.tr("You must supply a guest UUID"));
+        }
+        Consumer consumer = verifyAndLookupConsumer(consumerUuid);
+        consumer.addGuestId(guestId);
+        consumerCurator.merge(consumer);
+    }


//python-rhsm
//connection.py
 def updateConsumer(self, uuid, facts=None, installed_products=None,
                                                      guest_uuids=None):
        """
        Update a consumer on the server.

        Rather than requiring a full representation of the consumer, only some
        information is passed depending on what we wish to update.

        Note that installed_products and guest_uuids expects a certain format,
        example parsing is in subscription-manager's format_for_server() method.
        """
        params = {}
        if installed_products != None:
            params['installedProducts'] = installed_products
        if guest_uuids != None:
            params['guestIds'] = guest_uuids
        if facts != None:
            params['facts'] = facts

        method = "/consumers/%s" % self.sanitize(uuid)
        ret = self.conn.request_put(method, params)
        return ret

Comment 16 Michael Stead 2011-10-17 12:23:53 UTC
There has been some design change. "PUT /consumers/{consumer_uuid}/guests/{guest_uuid}" is old and is removed in wottop-virt-guest branch.

Guests will be added via the updateConsumer Candlepin API call.

Comment 17 Keqin Hong 2011-10-17 13:39:13 UTC
OK. virt-who functional testing then have to wait till the code is merged into master and pushed to stage env.

Comment 20 Bryan Kearney 2012-07-17 13:04:31 UTC
Marking all community bugs modified or beyong as closed.


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