Project

General

Profile

Actions

Bug #23581

closed

Upgrade to Foreman 1.17 converts YAML to JSON Hash

Added by Frederik Weber almost 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
DB migrations
Target version:
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

We have Puppet parameters with the type hash and a YAML hash as content (this is valid per Foreman documentation).
After the run of db:migrate the content gets migrated to a JSON hash.

If I extract an example value from the DB:

Before db:migrate

---             
frequency: daily

After db:migrate

 --- '{"frequency"=>"daily"}'

I see two solutions:
1. Change the db:migrate task that migrates valid YAML hashes to JSON hashes.
2. Update the documentation that YAML hashes are no longer valid.


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #23382: Editing Smart Class Parameter of type YAML creates malformed value in release 1.17.0ClosedDaniel Lobato Garcia04/24/2018Actions
Related to Foreman - Bug #24640: 1.17 migration causes array/hash values for parameters to turn into strings with escaped quotesClosedTomer BriskerActions
Actions #1

Updated by Frederik Weber almost 6 years ago

Just verified that an upgrade from 1.16.0 to 1.16.1 doesn't convert hashes.
Therefore it is likely that the issue was introduced in the version 1.17.

Actions #2

Updated by Frederik Weber almost 6 years ago

It is likely that this "bug" was introduced by PR #5403 (https://github.com/theforeman/foreman/pull/5403).
Should all YAML lookup_values become JSON hashes? Especially since it is possible to change the values back to YAML hashes (through the UI) and they get written like that to the DB.

Actions #3

Updated by The Foreman Bot almost 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5556 added
Actions #4

Updated by Frederik Weber almost 6 years ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/5556)
Actions #5

Updated by The Foreman Bot almost 6 years ago

  • Pull request https://github.com/theforeman/foreman/pull/5559 added
Actions #6

Updated by Tomer Brisker over 5 years ago

  • translation missing: en.field_release set to 360
  • Triaged set to No
Actions #7

Updated by Tomer Brisker over 5 years ago

  • Related to Bug #23382: Editing Smart Class Parameter of type YAML creates malformed value in release 1.17.0 added
Actions #8

Updated by Tomer Brisker over 5 years ago

  • Target version changed from 1.17.2 to 1.18.2

1.17.3 has been released, pushing out to 1.18.2

Actions #9

Updated by Thomas BAERT over 5 years ago

Hello,

https://github.com/theforeman/foreman/blob/1.17-stable/db/migrate/20170112175131_migrate_template_to_parameters_macros.rb#L34

parameter.value is a ruby Hash when Lookup_value type is Yaml/Hash in Foreman.
You convert it in String with to.s.
But you don't convert this String in Hash before update_attribute.
So YAML content is replaced by the String 'ruby Hash'.

Same problem with Array in Foreman (it's a ruby Array).
And same problem for LookupKey.default_value (https://github.com/theforeman/foreman/blob/1.17-stable/db/migrate/20170112175131_migrate_template_to_parameters_macros.rb#L25).

Actions #10

Updated by Tomer Brisker over 5 years ago

  • Status changed from Ready For Testing to Resolved

This issue has been resolved by #24640.

Actions #11

Updated by Tomer Brisker over 5 years ago

  • Related to Bug #24640: 1.17 migration causes array/hash values for parameters to turn into strings with escaped quotes added
Actions

Also available in: Atom PDF