Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

fixes #16455 - parser cache for capsule-certs-generate #393

Merged
merged 1 commit into from
Sep 8, 2016
Merged

fixes #16455 - parser cache for capsule-certs-generate #393

merged 1 commit into from
Sep 8, 2016

Conversation

komidore64
Copy link
Contributor

No description provided.

@@ -45,11 +45,20 @@ CONFIG_CONTENT = <<EOF
EOF

config_file = temp_file('capsule-certs', CONFIG_CONTENT)

# generate our parser cache and add it to the config file
parser_cache = temp_file('capsule-certs.parser_cache', `kafo-export-params -c #{config_file.path} -f parsercache --no-parser-cache`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this on a production box? I assume it would require us to package puppet-strings which we were trying to avoid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you asking if we should? because i know we can ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct -- given our previous reasons we were avoiding packaging puppet-strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i understand your roundabout question. yeah, this wouldn't work on a production machine because there would be no puppet strings to generate the parser cache. dunno why i didn't catch that. reworking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tough one due to the inlined configuration. We didn't during the scenario work because capsule-certs-generate is unique in that it is not an installer scenario but uses kafo and our modules. So its more like a script than anything. We could:

Option 1:
a) change this to lay down a config file
b) have that separate from the bin file and not inlined anymore
c) generate parser cache by pointing at the config file

Option 2:
a) see if there is some way to load the file via a script
b) pass the contents of the CONFIG_CONTENT constant to kafo-export-params in the Rakefile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like Option 1/ more. But it would require not to mix the real scenarios with capsule-certs-generate configuration. How about to move the current content of config to scenarios.d and capsule-certs-generate.yaml keep in a config. Then scenarios.d would be installed to /etc/foreman-installer/scenarios.d and config to /etc/foreman-installer-katello/ or better to /usr/share/foreman-installer-katello/config/.

@komidore64
Copy link
Contributor Author

@ehelms, @mbacovsky updated!

)
end

def initialize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick - I generally think to look for this at the top since its a special function that tells you how a class is setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up top

@ehelms
Copy link
Member

ehelms commented Sep 7, 2016

Some code nitpicks - going to test this now.

@komidore64
Copy link
Contributor Author

nitpicks addressed :)

@komidore64
Copy link
Contributor Author

updated again (sorry).

probably should ensure that cleanup() is run.

Kafo::KafoConfigure.exit_code == 2 ? exit(0) : exit(Kafo::KafoConfigure.exit_code)
if __FILE__ == $0
gen = CapsuleCertsGenerate.new
CONFIG_FILE = gen.config_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be gen.config_file.path

@ehelms
Copy link
Member

ehelms commented Sep 7, 2016

EDIT: Ignore the below, this is due to the parser cache file date being different (aka this -- https://github.com/theforeman/kafo/blob/master/lib/kafo/parser_cache_reader.rb#L52) and not the most obvious thing when testing.

I applied this on my test environment, but still getting:

[root@centos7-katello-p4-nightly vagrant]# capsule-certs-generate --capsule-fqdn centos7-capsule-p4-nightly.example.com --certs-tar /root/centos7-capsule-p4-nightly.example.com.tar.gz
/usr/share/gems/gems/kafo-0.9.5/lib/kafo/puppet_module.rb:69:in `parse': No Puppet module parser is installed and no cache of the file /usr/share/katello-installer-base/modules/certs/manifests/init.pp is available. Please check debug logs and install optional dependencies for the parser. (Kafo::ParserError)
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/configuration.rb:88:in `block in modules'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/configuration.rb:88:in `map'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/configuration.rb:88:in `modules'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/configuration.rb:188:in `params'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/configuration.rb:198:in `preset_defaults_from_puppet'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/kafo_configure.rb:251:in `set_parameters'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/kafo_configure.rb:97:in `initialize'
        from /usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `new'
        from /usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
        from /usr/share/gems/gems/kafo-0.9.5/lib/kafo/kafo_configure.rb:148:in `run'
        from /sbin/capsule-certs-generate:74:in `<main>'

Not sure if it doesn't like the cache I generated or something with kafo is occurring here.

@ehelms
Copy link
Member

ehelms commented Sep 7, 2016

Just #393 (comment) needs handling for me, @mbacovsky if you have time tomorrow morning can you take a glance? We'd like to get things merged up before branching but I appreciate your thoughts.

@komidore64
Copy link
Contributor Author

updated

@mbacovsky
Copy link
Contributor

@ehelms, @komidore64 Option 2/ makes the capsule-certs-generate even more special in my eyes but the code looks good. I appreciate the refactorings and the cleanup. +1 from me, I didn't have time to test it though.

@ehelms
Copy link
Member

ehelms commented Sep 8, 2016

@mbacovsky it's a special beast all around, one that I would love to re-design in general

ACK - thanks @komidore64 !

@ehelms ehelms merged commit 95eea44 into Katello:master Sep 8, 2016
@komidore64 komidore64 deleted the capsule-certs-generate-parser-cache branch September 8, 2016 13:49
zjhuntin pushed a commit to zjhuntin/katello-installer that referenced this pull request Oct 30, 2018
Coveralls will make comments on PRs once the coverage report is
generated. Local coverage can be found at coverage/index.html
once the test suite is run.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants