Bug 1121986 - Logging initialized too late
Summary: Logging initialized too late
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Transitions
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
medium vote
Target Milestone: Unspecified
Assignee: Grant Gainey
QA Contact: Lukas Pramuk
Depends On:
Blocks: stargate-GA-tracker
TreeView+ depends on / blocked
Reported: 2014-07-22 09:28 UTC by Matej Kollar
Modified: 2014-09-11 12:21 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-09-11 12:21:57 UTC

Attachments (Terms of Use)

Description Matej Kollar 2014-07-22 09:28:25 UTC
Description of problem: When importing users (with no role-mapping file), import subcommand wants to log message "Role-mapping file ... not found, no roles will be assigned". This causes following traceback

NoMethodError (undefined method `log' for nil:NilClass):
    ./lib/hammer_cli_import/importtools.rb:220:in `log'
    ./lib/hammer_cli_import/importtools.rb:208:in `warn'
    ./lib/hammer_cli_import/user.rb:54:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
    /usr/bin/hammer:19:in `load'

How reproducible: always/deterministic

Steps to Reproduce:
  1. either run subcommand without installation
     (RUBYOPT=-Ilib hammer ....) or remove  mapping file.
    RUBYOPT=-Ilib hammer -v import user --debug --csv-file /tmp/exports/users.csv --new-passwords newpws.csv

Actual results: program terminates with mentioned traceback.

Expected results: ...

Additional info: 

@logger is initialized in execute method. However, loading mapping file/checking stuff
is done in execute as well, and super is called only after this test.

Proposed solutions

  * move logger initialization into init (probably preferred as otherwise
    we would need to check other places where we override exec and this
    might cause complications in the future)
  * move mapping file checking/loading somewhere else

Comment 1 RHEL Product and Program Management 2014-07-22 09:53:41 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Grant Gainey 2014-07-22 19:56:57 UTC
commit 54d9abcb3026718870c9623c279912906d84a0e2

Comment 4 Grant Gainey 2014-08-05 11:59:28 UTC
Moving logging-setup into init is a non-starter, because it relies on knowing the setting of the --debug option, and options aren't processed until after init :(

However, we fixed the issues that caused this BZ to be opened, by deciding to stop overriding execute().

See commit 610fc67318ba2501c531fbedec2b54be1ea6cd98 for 'removing execute overrides'

See commit 16d4cd6d68ad62c42b0981a05eefa83af9057471 for 'putting setup_logging back where it belongs'

Comment 7 Matej Kollar 2014-09-03 09:50:14 UTC
verified with rubygem-hammer_cli_import-0.10.3-1

Comment 8 Bryan Kearney 2014-09-11 12:21:57 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.

Note You need to log in before you can comment on or make changes to this bug.