Bug 737935 - implement alternate guest uuid upload method
implement alternate guest uuid upload method
Product: Candlepin
Classification: Community
Component: candlepin (Show other bugs)
Unspecified Unspecified
high Severity unspecified
: ---
: ---
Assigned To: Bryan Kearney
John Sefler
Depends On:
Blocks: rhsm-rhel62 743823
  Show dependency treegraph
Reported: 2011-09-13 08:38 EDT by Radek Novacek
Modified: 2016-11-30 19:29 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 743823 (view as bug list)
Last Closed: 2012-07-17 09:04:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Radek Novacek 2011-09-13 08:38:51 EDT
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 12:40:45 EDT

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 04:00:46 EDT

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 09:56:44 EDT
Try again, It just got pushed a few minutes ago.

hash is a6fcfb08cf32ce128c41caf85d578bf0ada4aea6
Comment 4 Devan Goodwin 2011-09-27 15:41:55 EDT
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)

Comment 5 Radek Novacek 2011-09-29 02:28:49 EDT
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 08:32:37 EDT
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 15:41:32 EDT
9fbbe091c23f35c7782cf31f892ed5ea0159ae11 master 0.97.2+
75c647a RHEL6.2 0.97.13+
Comment 8 Chris Duryee 2011-10-04 16:32:11 EDT
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 18:05:45 EDT
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 01:39:10 EDT
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 07:15:52 EDT
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?
$ 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);
+    }

 def updateConsumer(self, uuid, facts=None, installed_products=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 08:23:53 EDT
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 09:39:13 EDT
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 09:04:31 EDT
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.