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

CompilationDir filter doesn't support string parameters with multiple compilation dir appearance #188

Open
masterzen opened this issue Jun 5, 2018 · 0 comments

Comments

@masterzen
Copy link
Contributor

Description of problem

When using parameters values that are strings containing multiple references to the compilation dir (ie using $::settings::codedir for instance), the CompilationDir filter is unable to detect that the parameters are strictly equivalent.

For instance the following resource:

exec { 'sign cert':
      command => "openssl x509 -req -in ${user}.csr -CA ${settings::localcacert} -CAkey ${settings::cakey} -CAcreateserial -out ${user}.pem -days ${days}",
  ...
}

will produce the following diff:

  Exec[sign cert] =>
   parameters =>
     command =>
      - openssl x509 -req -in user.csr -CA /tmp/ocd-ipc-20180605-856-t3sswg/ocd-builddir-20180605-858-e8z4wo/var/ssl/certs/ca.pem -CAkey /tmp/ocd-ipc-20180605-856-t3sswg/ocd-builddir-20180605-858-e8z4wo/var/ssl/ca/ca_key.pem -CAcreateserial -out user.pem -days 365
      + openssl x509 -req -in user.csr -CA /tmp/ocd-ipc-20180605-856-t3sswg/ocd-builddir-20180605-861-awzqbm/var/ssl/certs/ca.pem -CAkey /tmp/ocd-ipc-20180605-856-t3sswg/ocd-builddir-20180605-861-awzqbm/var/ssl/ca/ca_key.pem -CAcreateserial -out user.pem -days 365

Command used and debugging output

octocatalog-diff  --fact-file /repo/ci/facts/ubuntu.yaml --from-fact-override "role=tower" --to-fact-override "role=tower" --bootstrap-environment "V=0,SSH_AUTH_SOCK=/ssh-agent/ssh-agent.sock" --compare-file-text --filters CompilationDir --display-detail-add --debug

Platform and version information

  • Your OS: ubuntu 16.04
  • Your Ruby version: 2.3.1
  • Your version of Puppet: 5.5.0
  • Your version of octocatalog-diff: 1.5.3

The problem comes from the fact that the CompilationDir only checks for the presence of one compilation dir path in the parameter value.
I think this would be more effective to replace all from and to compilation dir in the string by a placeholder and then just do string equality comparison instead of trying to split the string around the presence of the compilation dir prefix as it is now.

@masterzen masterzen changed the title CompilationDir filter doesn't support string parameters with multiple compilation dir CompilationDir filter doesn't support string parameters with multiple compilation dir appearance Jun 5, 2018
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue Jun 6, 2018
…ltiple values

There were two cases where CompilationDir wasn't filtering out changes:
* if the parameter value is an arbitrary data structure (ie hash, array
or mix of both)
* if the parameter value is a string containing more than one occurence
of the compilation dir

It turns out that both can be fixed by just replacing the compilation
dirs in both the new and old values with empty strings and comparing
what's left.

It's probably much slower than the original string-only implementation
but covers much more cases as demonstrated by github#187 and github#188.
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue Jun 6, 2018
…ltiple values

There were two cases where CompilationDir wasn't filtering out changes:
* if the parameter value is an arbitrary data structure (ie hash, array
or mix of both)
* if the parameter value is a string containing more than one occurence
of the compilation dir

It turns out that both can be fixed by just replacing the compilation
dirs in both the new and old values with empty strings and comparing
what's left.

It's probably much slower than the original string-only implementation
but covers much more cases as demonstrated by github#187 and github#188.
masterzen pushed a commit to masterzen/octocatalog-diff that referenced this issue Jun 6, 2018
…ltiple values

There were two cases where CompilationDir wasn't filtering out changes:
* if the parameter value is an arbitrary data structure (ie hash, array
or mix of both)
* if the parameter value is a string containing more than one occurence
of the compilation dir

It turns out that both can be fixed by just replacing the compilation
dirs in both the new and old values with empty strings and comparing
what's left.

It's probably much slower than the original string-only implementation
but covers much more cases as demonstrated by github#187 and github#188.
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

No branches or pull requests

1 participant