Bug 1121986

Summary: Logging initialized too late
Product: Red Hat Satellite Reporter: Matej Kollar <mkollar>
Component: TransitionsAssignee: Grant Gainey <ggainey>
Status: CLOSED CURRENTRELEASE QA Contact: Lukas Pramuk <lpramuk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: UnspecifiedCC: bbuckingham, cperry, ggainey, jmontleo, mkollar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-11 12:21:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1125243    

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/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/bin/hammer:102
    /usr/bin/hammer:19:in `load'
    /usr/bin/hammer:19

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 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.