Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octocatalog-diff is missing diffs from some nested arrays of objects #223

Open
masterzen opened this issue May 14, 2020 · 0 comments · May be fixed by #224
Open

Octocatalog-diff is missing diffs from some nested arrays of objects #223

masterzen opened this issue May 14, 2020 · 0 comments · May be fixed by #224

Comments

@masterzen
Copy link
Contributor

Description of problem

When dealing with parameters that are contains arrays of objects, octocatalog-diff doesn't report any differences.

For instance the following Puppet resource:

testtype { 'test':
  'testparam' => {
     'another-one' => {
       'an-array' => [
          {
             'env' => [
               { 'name' => 'HOST', 'value' => 'localhost' },
             ] 
          },
       ]
     }
  } 

Modifying any object of the env nested array (that is the keys or the values), or adding or removing objects from it will not trigger any diff to be displayed.

Command used and debugging output

octocatalog-diff --debug --fact-file ci/facts/ubuntu.yaml --from-fact-override "role=k8s" --to-fact-override "role=k8s" --bootstrap-environment "V=1" --display-detail-add --from origin/production --master-cache-branch origin/production

The above commands just generate the following warning regarding the resource:

W, [2020-05-14T06:30:36.666653 #1771]  WARN -- : Resource key testtype[test] parameters => testparam => another-one => an-array[0] => env appears to depend on catalog compilation directory. Suppressed from results.

Note that there's no mention of the compilation directory in the parameters value, so there's no reason for it to be ignored.

Running with --display-datatype-changes still doesn't display the changes, but produces the following debug log:

D, [2020-05-13T12:03:46.273101 #1] DEBUG -- : Adjust display for testtype::test::parameters::testparam::another-one::an-array[0]::env: nil != nil DELETED

Interesting, apparently octocatalog-diff thinks both before and after parameters are nil.

After looking at the code and debugging, it appears that the values of those nested parameters are removed in hashdiff_nested_changes and more precisely in dig_out_key.
Indeed, dig_out_key doesn't seem to support array indices (like an-array[0]) as key names and thus bails out returning nil without descending into the pointed object.

Platform and version information

  • Your OS: ubuntu bionic 18.04
  • Your Ruby version: 2.5.1p57
  • Your version of Puppet: 5.5.17
  • Your version of octocatalog-diff: 1.6.0

Do the tests pass from a clean checkout?

Yes.

Anything else to add that you think will be helpful?

A PR will soon be published to fix this issue :)

masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue May 14, 2020
When using octocatalog-diff with puppet resources with deep
nested datastructures such as nested arrays of objects, octocatalog-
diff would not display diffs when array elements are modified,added or removed.

In fact, it turns out `dig_out_key` doesn't descend into arrays index
that hashdiff can produce, like for instance:
testtype::test::parameters::testparam::another-one::an-array[0]::env

`dig_out_key` would stop at `an-array` because it doesn't know that's
and array index it should try to descend into.

This patch adds the functionality for `dig_out_key` to follow array
index and descend into those nested structure.
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue May 14, 2020
When using octocatalog-diff with puppet resources with deep
nested datastructures such as nested arrays of objects, octocatalog-
diff would not display diffs when array elements are modified,added or removed.

In fact, it turns out `dig_out_key` doesn't descend into arrays index
that hashdiff can produce, like for instance:
testtype::test::parameters::testparam::another-one::an-array[0]::env

`dig_out_key` would stop at `an-array` because it doesn't know that's
and array index it should try to descend into.

This patch adds the functionality for `dig_out_key` to follow array
index and descend into those nested structure.
@masterzen masterzen linked a pull request May 14, 2020 that will close this issue
5 tasks
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue May 14, 2020
When using octocatalog-diff with puppet resources with deep
nested datastructures such as nested arrays of objects, octocatalog-
diff would not display diffs when array elements are modified,added or removed.

In fact, it turns out `dig_out_key` doesn't descend into arrays index
that hashdiff can produce, like for instance:
testtype::test::parameters::testparam::another-one::an-array[0]::env

`dig_out_key` would stop at `an-array` because it doesn't know that's
and array index it should try to descend into.

This patch adds the functionality for `dig_out_key` to follow array
index and descend into those nested structure.
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue May 14, 2020
When using octocatalog-diff with puppet resources with deep
nested datastructures such as nested arrays of objects, octocatalog-
diff would not display diffs when array elements are modified,added or removed.

In fact, it turns out `dig_out_key` doesn't descend into arrays index
that hashdiff can produce, like for instance:
testtype::test::parameters::testparam::another-one::an-array[0]::env

`dig_out_key` would stop at `an-array` because it doesn't know that's
and array index it should try to descend into.

This patch adds the functionality for `dig_out_key` to follow array
index and descend into those nested structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant