Project

General

Profile

Actions

Bug #17193

open

Duplicated OS (CentOS) detection

Added by Davide Ferrari about 8 years ago. Updated over 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Facts
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

After upgrading to 1.13.1 from 1.13.0 and with #13104 applied, now we have duplicated CentOS OS versions.
Let me explain: before our OSes were:

- CentOS Linux 7.1.1503
- CentOS Linux 7.2.1511

now with 1.13.1, with this fix implemented, there are 2 more OSes in addition:

- CentOS 7.1.1503
- CentOS 7.2.1511

obviously with no template associated, no disk layout, nothing. And about half of our machines switched to this new OSes and the other half stayed with the old (maybe something related to LSB not being installed on the machines that remained with the original version)


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #13104: CentOS minor version numbering issue - preventing buildClosedTomer Brisker01/10/2016Actions
Actions #1

Updated by Davide Ferrari about 8 years ago

  • Related to Bug #13104: CentOS minor version numbering issue - preventing build added
Actions #2

Updated by Davide Ferrari about 8 years ago

Davide Ferrari wrote:

obviously with no template associated, no disk layout, nothing. And about half of our machines switched to this new OSes and the other half stayed with the old (maybe something related to LSB not being installed on the machines that remained with the original version)

Forget the LSB thing, it's probably related to the fact that we've not managed hosts (not provisioned with foreman) and they are the ones that stay with the original OS version

Actions #3

Updated by Dominic Cleal about 8 years ago

  • Translation missing: en.field_release set to 203
Actions #4

Updated by Dominic Cleal about 8 years ago

If you have the info, could you check exactly which fields are set to what on the new and old OSes (name, description, major, minor)? The name should probably only be "CentOS", which ought to have matched. The description may contain "CentOS Linux" however.

Actions #5

Updated by Dominic Cleal about 8 years ago

  • Translation missing: en.field_release changed from 203 to 207
Actions #6

Updated by Dominic Cleal almost 8 years ago

  • Status changed from New to Need more information
  • Translation missing: en.field_release deleted (207)
Actions #7

Updated by Davide Ferrari almost 8 years ago

Dominic Cleal wrote:

If you have the info, could you check exactly which fields are set to what on the new and old OSes (name, description, major, minor)? The name should probably only be "CentOS", which ought to have matched. The description may contain "CentOS Linux" however.

Sorry for the delay, I had almost no time lately :(
The "old" OS contains the following fields:
- Name: "CentOS"
- Major version: "7"
- Minor version: "2"
- Description: "CentOS Linux 7.2.1511"

The "new" OSes that appeared after upgrading to 1.13.1 contains:

- Name: "CentOS"
- Major version: "7"
- Minor version: "2.1511"
- Description: empty

As a side note, I've upgraded some already existing hosts to CentOS 7.3 with yum upgrade and they are now labelled following the 1st (old) scheme.

Actions #8

Updated by Dominic Cleal almost 8 years ago

  • Status changed from Need more information to New
Actions #9

Updated by Martin Schurz over 7 years ago

We had the same problem in our environment after updating. This also affects fact import and creation of new hosts (all facts after os fact are ignored, because of an ActiveRecord error)

Error message from Foreman Logs:

2017-06-23 03:31:17 e1b36a18 [app] [I]   Parameters: {"facts"=>"[FILTERED]", "name"=>"...", "certname"=>"...", "apiv"=>"v2", :host=>{"certname"=>"...", "name"=>" 
..."}}
2017-06-23 03:31:17 e1b36a18 [app] [I] Import facts for '...' completed. Added: 0, Updated: 0, Deleted 0 facts
2017-06-23 03:31:17 e1b36a18 [app] [W] Action failed
 | ActiveRecord::RecordInvalid: Validation failed: Description has already been taken, Title has already been taken
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:79:in `raise_record_invalid'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:43:in `save!'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:291:in `block in save!'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:220:in `transaction'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:291:in `save!'
 | /usr/share/foreman/app/services/puppet_fact_parser.rb:49:in `operatingsystem'
 | /usr/share/foreman/app/models/host/base.rb:157:in `block in set_non_empty_values'
 | /usr/share/foreman/app/models/host/base.rb:156:in `each'
 | /usr/share/foreman/app/models/host/base.rb:156:in `set_non_empty_values'
 | /usr/share/foreman/app/models/host/base.rb:149:in `populate_fields_from_facts'
 | /usr/share/foreman/app/models/host/managed.rb:465:in `populate_fields_from_facts'
 | /usr/share/foreman/app/models/host/base.rb:127:in `import_facts'
 | /usr/share/foreman/app/models/host/managed.rb:306:in `import_facts'
 | /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:240:in `facts'

After some investigation we found a possible fix/workaround. But we are not sure what would be a good solution.

Our fix
There was a change in how Foreman saves OS Version numbers ("2" vs. "2.1511") but the table/model has also an unique constraint for description. Since the description for both records would be the same, an Exception is generated.

This is the Status prior to our fix:

MariaDB [foreman]> select id, name, major, minor, description, title from operatingsystems order by name,major,minor;
+----+--------+-------+--------+-----------------------+-----------------------+
| id | name   | major | minor  | description           | title                 |
+----+--------+-------+--------+-----------------------+-----------------------+
|  5 | CentOS | 7     | 2      | CentOS Linux 7.2.1511 | CentOS Linux 7.2.1511 |
| 29 | CentOS | 7     | 2.1511 | NULL                  | CentOS 7.2.1511       |
| 26 | CentOS | 7     | 3      | CentOS Linux 7.3.1611 | CentOS Linux 7.3.1611 |
| 34 | CentOS | 7     | 3.1611 | NULL                  | CentOS 7.3.1611       |
+----+--------+-------+--------+-----------------------+-----------------------+

We changed the old description and title to match the reduced version number saved in the record.

MariaDB [foreman]> update operatingsystems set description="CentOS Linux 7.2", title="CentOS Linux 7.2" where id=5;
MariaDB [foreman]> update operatingsystems set description="CentOS Linux 7.3", title="CentOS Linux 7.3" where id=26;

MariaDB [foreman]> select id, name, major, minor, description, title from operatingsystems order by name,major,minor;
+----+--------+-------+--------+-----------------------+-----------------------+
| id | name   | major | minor  | description           | title                 |
+----+--------+-------+--------+-----------------------+-----------------------+
|  5 | CentOS | 7     | 2      | CentOS Linux 7.2      | CentOS Linux 7.2      |
| 29 | CentOS | 7     | 2.1511 | NULL                  | CentOS Linux 7.2.1511 |
| 26 | CentOS | 7     | 3      | CentOS Linux 7.3      | CentOS Linux 7.3      |
| 34 | CentOS | 7     | 3.1611 | NULL                  | CentOS Linux 7.3.1611 |
+----+--------+-------+--------+-----------------------+-----------------------+

After the first hosts reported successfully, Foreman did fill the fields correctly and tere were no errors anymore

MariaDB [foreman]> select id, name, major, minor, description, title from operatingsystems order by name,major,minor;
+----+--------+-------+--------+-----------------------+-----------------------+
| id | name   | major | minor  | description           | title                 |
+----+--------+-------+--------+-----------------------+-----------------------+
|  5 | CentOS | 7     | 2      | CentOS Linux 7.2      | CentOS Linux 7.2      |
| 29 | CentOS | 7     | 2.1511 | CentOS Linux 7.2.1511 | CentOS Linux 7.2.1511 |
| 26 | CentOS | 7     | 3      | CentOS Linux 7.3      | CentOS Linux 7.3      |
| 34 | CentOS | 7     | 3.1611 | CentOS Linux 7.3.1611 | CentOS Linux 7.3.1611 |
+----+--------+-------+--------+-----------------------+-----------------------+

possible solution
Since the problem is triggeren by differences in saved data, this is no "real bug" in the code. To solve the problem it should be enough to allow for dupplicate description/title values.

Actions

Also available in: Atom PDF