Project

General

Profile

Bug #12623

CRs with integer UUIDs cause DB error on VM association: operator does not exist: character varying = integer

Added by Dominic Cleal over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compute resources
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Compute resources that return integers from the #identity method of Fog server objects throw an error during VM/host association as Rails tries to compare an integer to a string column.

PGError: ERROR: operator does not exist: character varying = integer LINE 1: ..."hosts"."compute_resource_id" = 1 AND "hosts"."uuid" IN (21) ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT COUNT(*) FROM "hosts" WHERE "hosts"."organization_id" IN (1) AND "hosts"."location_id" IN (2) AND "hosts"."type" IN ('Host::Managed') AND "hosts"."compute_resource_id" = 1 AND "hosts"."uuid" IN (21)

This is called from the Host::Managed.for_vm scope.

Reported at https://github.com/theforeman/foreman-one/issues/8 and I suspect it may also affect foreman-digitalocean whose Fog server does the same.

Associated revisions

Revision 3ef29ca2 (diff)
Added by Dominic Cleal over 3 years ago

fixes #12623 - convert VM IDs to strings for DB lookup

Some CR types return the VM identities as integers, but the `uuid`
column is a string type. Convert all VM IDs to strings before
comparing to prevent SQL errors on PostgreSQL.

Replaced skip_callback in test factories to prevent it leaking into
other tests and permanently skipping the callback.

Revision ecc88e47 (diff)
Added by Dominic Cleal over 3 years ago

fixes #12623 - convert VM IDs to strings for DB lookup

Some CR types return the VM identities as integers, but the `uuid`
column is a string type. Convert all VM IDs to strings before
comparing to prevent SQL errors on PostgreSQL.

Replaced skip_callback in test factories to prevent it leaking into
other tests and permanently skipping the callback.

(cherry picked from commit 3ef29ca2220ee77f77ec50326e330e0c671341e5)

History

#1 Updated by The Foreman Bot over 3 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2940 added

#2 Updated by Dominic Cleal over 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) set to 104

Also available in: Atom PDF