Bug 811382 - Can't run StickShift SDK based command in sudo or cron
Can't run StickShift SDK based command in sudo or cron
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Pod (Show other bugs)
2.x
Unspecified Unspecified
high Severity low
: ---
: ---
Assigned To: Krishna Raman
libra bugs
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-10 16:58 EDT by Thomas Wiest
Modified: 2015-05-14 21:50 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-31 20:24:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Thomas Wiest 2012-04-10 16:58:17 EDT
Description of problem:
If you try to run StickShift SDK based commands in either sudo or cron you get the error below.

This significantly hampers our ability to write monitoring scripts around StickShift sdk itself, or around any commands that use it.


Version-Release number of selected component (if applicable):
rubygem-stickshift-common-0.7.2-1.el6_2.noarch


How reproducible:
every time


Steps to Reproduce:
1. sudo rhc-admin-ctl-district
2. wait for the command to run (takes about 1 minute)
3. notice the error as below


Actual results:
# sudo rhc-admin-ctl-district
/usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:282:in `get_valid_seed_node': Cannot connect to a replica set using seeds localhost:27017, : (Mongo::ConnectionFailure)
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:158:in `connect_to_members'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:30:in `connect'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:160:in `connect'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:500:in `setup'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:144:in `initialize'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.7.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:121:in `new'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.7.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:121:in `db'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:114:in `district_collection'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:22:in `find_all_districts'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.7.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:168:in `rescue_con_failure'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:21:in `find_all_districts'
	from /var/www/stickshift/broker/app/models/district.rb:37:in `find_all'
	from /usr/bin/rhc-admin-ctl-district:180


Expected results:
The command should run as it runs normally
Comment 1 Krishna Raman 2012-05-04 21:27:09 EDT
Unable to reproduce on dev.
Comment 2 Xiaoli Tian 2012-05-07 03:07:24 EDT
I've tried to test this on devenv_1757.

Since only root user have sudo permission, create another user and try to sudo will get "bash: /usr/bin/sudo: Permission denied"

[root@ip-10-100-211-171 ~]# ls -lh /usr/bin/sudo
---x--x---. 2 root wheel 208K Jul 21  2011 /usr/bin/sudo

And sudo with root user itself, can not reproduce it  as well


#sudo rhc-admin-ctl-district -h
== Synopsis

rhc-admin-ctl-district: Control districts

== Usage

rhc-admin-ctl-district OPTIONS

Options:
-u|--uuid     <district uuid>
    District uuid  (alphanumeric)
-c|--command <command>
    (add-node|remove-node|deactivate-node|activate-node|add-capacity|remove-capacity|create|destroy)
-n|--name <district name>
    District name (Used on create or in place of uuid on other commands)
-p|--node_profile <profile_size>
    (small(default)|jumbo|exlarge|large|medium|micro) Only needed for create
-i|--server_identity

Hi, Thomas

Can you help to check if that's what you want and if it works for you now?
 

Thanks
Comment 3 Thomas Wiest 2012-05-07 10:22:14 EDT
Yeah, I tried this out on Krishna's devenv on Friday and it seems to be working now.

I believe whoever fixed the ruby CONST errors also fixed this problem.

NOTE: this still fails in STG and PROD right now, so I'll double check this once we push the next release to STG.
Comment 4 Xiaoli Tian 2012-05-15 05:52:35 EDT
Hi, Thomas

Does this work for you on STG and PROD?

Thanks
Comment 5 Thomas Wiest 2012-05-15 10:17:46 EDT
Unfortunately it still doesn't work in STG and PROD.

I worked with Krishna on this, and I tested it in his devenv and it worked fine. So there is something different between STG/PROD and the devenvs.

Note: Another difference is that when we run commands in STG and PROD, we still get those annoying "warning: already initialized constant" messages from the rhc-admin-* commands. We don't get those in the devenv anymore. So whatever fixed those messages in the devenv might be what fixed this problem too.

Moving back to assigned.


[root@REDACTED ~]# sudo rhc-admin-ctl-district
/usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:282:in `get_valid_seed_node': Cannot connect to a replica set using seeds localhost:27017, : (Mongo::ConnectionFailure)
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:158:in `connect_to_members'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:30:in `connect'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:160:in `connect'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:500:in `setup'
	from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:144:in `initialize'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.10.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:121:in `new'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.10.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:121:in `db'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:114:in `district_collection'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:22:in `find_all_districts'
	from /usr/lib/ruby/gems/1.8/gems/stickshift-controller-0.10.8/lib/stickshift-controller/lib/stickshift/mongo_data_store.rb:168:in `rescue_con_failure'
	from /var/www/stickshift/broker/lib/express/broker/mongo_data_store.rb:21:in `find_all_districts'
	from /var/www/stickshift/broker/app/models/district.rb:37:in `find_all'
	from /usr/bin/rhc-admin-ctl-district:180
[root@REDACTED ~]#
Comment 6 Anderson Silva 2012-06-22 10:35:36 EDT
FYI,

if I edit the /etc/sudoers

and change:

Defaults    env_reset

to

Defaults    !env_reset

It seems the command starts working fine.
Comment 7 Mike McGrath 2012-08-29 14:47:52 EDT
(In reply to comment #6)

> 
> It seems the command starts working fine.

Moving to On_QA
Comment 8 Meng Bo 2012-08-30 05:17:13 EDT
Hi Thomas,

Since the issue occurs on STG and PROD only, and for QE, we do not have permission to test the bug. Could you help test this on STG and PROD.

Thanks.
Comment 9 Thomas Wiest 2012-08-31 20:24:31 EDT
Yep, this is working now.

Closing bug.

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