salt master "minion did not get response" while executing custom modules for oracle
Very strange issue:-
i have a custom module (using sqlalchemy) for databases. (supporting mysql,oracle,postgres,msql) now the custom module works. "salt-call modulename" and "salt master modulename" is working for mysql. salt-call is working for oracle as well. but when i use "salt master for oracle ..it says minion did not response. salt master test.ping is true salt-call works fine everytime. i have checked with debug mode and logs. Nothing relevant i could see to troubleshoot further. i don't understand why salt-call works and why salt master fails. salt --version Nitrogen i have restarted..did each and every thing but still no luck. Any idea how to dig further. The manual module(python script) is also working fine. but its just the salt master and only when am targeting a oracle DB. The only diff with other databases is an env variable which is set.
root@cri-dev-postgres:/srv/salt/testingcode/jinja# salt master db.db_create_user user="suman" password="set4now" ci_id="sub-1504158985538" dbname="GGG" -l debug
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf'
[DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] Configuration file path: /etc/salt/master
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf'
[DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear')
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] LazyLoaded local_cache.get_load
[DEBUG ] Reading minion list from /var/cache/salt/master/jobs/81/f53d0f0e2eb135c591ac20a2bd8f927bedb8b4925830d1902db4f19fa09bd3/.minions.p
[DEBUG ] get_iter_returns for jid 20170908065212085735 sent to set(['master']) will timeout at 06:53:52.121871
[DEBUG ] Checking whether jid 20170908065212085735 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear')
[DEBUG ] retcode missing from client return
[DEBUG ] return event: {'master': {'failed': True}}
[DEBUG ] LazyLoaded localfs.init_kwargs
[DEBUG ] LazyLoaded localfs.init_kwargs
[DEBUG ] LazyLoaded no_return.output
master:
Minion did not return. [No response]
Can you set log_level: debug on the minion, and then restart the salt-minion process, and provide the debug output while the custom module attempts to run, and is triggered from the salt-master?
Thanks, Daniel
I did it and here is the same response. root@cri-dev-postgres:~# salt master db.db_create_user user="suman" password="set4now" ci_id="sub-1504158985538" dbname="GGG" -l debug [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] Configuration file path: /etc/salt/master [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc [DEBUG ] LazyLoaded local_cache.get_load [DEBUG ] Reading minion list from /var/cache/salt/master/jobs/aa/bf1a85cc6d9eb934fde7403621c725c9d962dc20651bb4d565ea0079e02b4b/.minions.p [DEBUG ] get_iter_returns for jid 20170908075614728303 sent to set(['master']) will timeout at 07:57:54.744932 [DEBUG ] Checking whether jid 20170908075614728303 is still running [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] retcode missing from client return [DEBUG ] return event: {'master': {'failed': True}} [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded no_return.output master: Minion did not return. [No response]
That is the log message from the master, I want the log messages from /var/log/salt/minion on the minion with log_level: debug set on the minion
we are running this on the master it self. There is no minion on which we are running this. salt master db.db_create_user user="suman" password="set4now" ci_id="sub-1504158985538" dbname="GGG" -l debug
db.py takes the database server as arg (which is an RDS instance)..the module will take this ci_id, forms an api url, fetch data (ip,user,pass,port etc) of the database,use sqlalchemy to connect to db, and runs query)
So ci_id variates as per DB type. everything else works but fails in case of salt master if i select a oracle ci_id.
You are targeting a minion called master so you need to check the /var/log/salt/minion file after you run the command. Also set log_level: debug in /etc/salt/minion.
i already did that...here is the latest run command and the log
root@cri-dev-postgres:/etc/salt/pki/minion# salt master db.db_create_user user="suman" password="set4now" ci_id="sub-1504158985538" dbname="GGG" -l debug [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] Configuration file path: /etc/salt/master [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc [DEBUG ] LazyLoaded local_cache.get_load [DEBUG ] Reading minion list from /var/cache/salt/master/jobs/bd/f736a62d2e4b6dd397c38dba5e34d6a28eb5fa4e24c3bade005de73dad506a/.minions.p [DEBUG ] get_iter_returns for jid 20170908085203361462 sent to set(['master']) will timeout at 08:53:43.380792 [DEBUG ] Checking whether jid 20170908085203361462 is still running [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] retcode missing from client return [DEBUG ] return event: {'master': {'failed': True}} [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded no_return.output master: Minion did not return. [No response]
tail -f /var/log/salt/minion 2017-09-08 08:53:43,402 [salt.minion ][INFO ][1913] User root Executing command saltutil.find_job with jid 20170908085343388677 2017-09-08 08:53:43,403 [salt.minion ][DEBUG ][1913] Command details {'tgt_type': 'list', 'jid': '20170908085343388677', 'tgt': ['master'], 'ret': '', 'user': 'root', 'arg': ['20170908085203361462'], 'fun': 'saltutil.find_job'} 2017-09-08 08:53:43,431 [salt.minion ][INFO ][2398] Starting a new job with PID 2398 2017-09-08 08:53:43,451 [salt.utils.lazy ][DEBUG ][2398] LazyLoaded saltutil.find_job 2017-09-08 08:53:43,454 [salt.utils.lazy ][DEBUG ][2398] LazyLoaded direct_call.get 2017-09-08 08:53:43,455 [salt.minion ][DEBUG ][2398] Minion return retry timer set to 8 seconds (randomized) 2017-09-08 08:53:43,455 [salt.minion ][INFO ][2398] Returning information for job: 20170908085343388677 2017-09-08 08:53:43,456 [salt.transport.zeromq][DEBUG ][2398] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506', 'aes') 2017-09-08 08:53:43,457 [salt.crypt ][DEBUG ][2398] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506') 2017-09-08 08:53:43,469 [salt.minion ][DEBUG ][2398] minion return: {'fun_args': ['20170908085203361462'], 'jid': '20170908085343388677', 'return': {}, 'retcode': 0, 'success': True, 'fun': 'saltutil.find_job'}
The debug log is quite chatty, your log snippet does not include any messages about the db module.
Can you put the whole minion log in a gist at http://gist.github.com?
Thanks, Daniel
https://gist.github.com/Set4now/0c3ad101aede9804be22447c90dde7aa
update...salt master with custom modules (db.py) now returning error. (same error) but salt-call works... where as if i do salt master cmd.run ifconfig it works..
Part of what you are seeing is it looks like it is taking so long for the db function to return that the master is timing out.
can you provide me with what the module looks like so that I can replicate this?
How long does it take to run the command with salt-call?
see the date time diff (50 secs) for salt-call root@cri-dev-postgres:~# date;salt-call db.run_query template="oracle_show_client_version" ci_id="sub-1504158985538";date Fri Sep 8 11:27:04 PDT 2017 [DEBUG ] Configuration file path: /etc/salt/minion [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] Reading configuration from /etc/salt/minion [DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf' [DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf [DEBUG ] Please install 'virt-what' to improve results of the 'virtual' grain. [DEBUG ] Connecting to master. Attempt 1 of 1 [DEBUG ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506') [DEBUG ] Generated random reconnect delay between '1000ms' and '11000ms' (4117) [DEBUG ] Setting zmq_reconnect_ivl to '4117ms' [DEBUG ] Setting zmq_reconnect_ivl_max to '11000ms' [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] Decrypting the current master AES key [DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem [DEBUG ] SaltEvent PUB socket URI: /var/run/salt/minion/minion_event_fc613b4dfd_pub.ipc [DEBUG ] SaltEvent PULL socket URI: /var/run/salt/minion/minion_event_fc613b4dfd_pull.ipc [DEBUG ] Initializing new IPCClient for path: /var/run/salt/minion/minion_event_fc613b4dfd_pull.ipc [DEBUG ] Sending event: tag = salt/auth/creds; data = {'_stamp': '2017-09-08T18:27:16.219445', 'creds': {'publish_port': 4505, 'aes': 'UGWYv74GVGuIEnxsue8TbEQzgbmrq+cxvtfTgQkwrIsOPS4To9AYr2gahfSr0SngPGLdju9tLpY=', 'master_uri': 'tcp://10.236.220.165:4506'}, 'key': ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506')} [DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem [DEBUG ] Determining pillar cache [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506', 'aes') [DEBUG ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506') [DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] LazyLoaded db.run_query [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Starting new HTTP connection (1): 10.236.220.121 [DEBUG ] http://10.236.220.121:5000 "GET /api/v1/viewentities?where=%7B%22entityid%22:%22sub-1504158985538%22%7D HTTP/1.1" 200 1028 "Fatal Error: A valid dbname paramater required for the program to connect to an ORACLE DATABASE." Fri Sep 8 11:27:53 PDT 2017
ignore the fatal error..
def __connection(ci_id, query = None, template = None, dbname = None, pillar = None):
#ci_details = salt.utils.cridbconnect.get_ci(ci_id)
if template != None:
query = salt.utils.cridbconnect.read_template(template, pillar)
if query == False:
msg="'Error: Template does not exist!!'"
sys.exit(json.dumps(msg))
ci_details = salt.utils.cridbconnect.get_ci(ci_id)
if ci_details == False:
msg="Error: Unable To Fetch Entity Data. Either API URL is Down or Invalid CI!!"
sys.exit(json.dumps(msg))
db_url = salt.utils.cridbconnect.get_dburl(ci_details['dbtype'].lower(), ci_details['user'],ci_details['password'], ci_details['host'], ci_details['port'], dbname)
if db_url == False:
msg="Error: Unsupported DataBase"
sys.exit(json.dumps(msg))
engine = create_engine(db_url, pool_recycle=3600)
try:
connection = engine.connect()
except Exception as e:
msg="Error: Unable to connect to Database. Message: {}".format(e.message)
sys.exit(json.dumps(msg))
return (query, db_url, engine, ci_details, connection)
def run_query(ci_id, query = None, template = None, dbname = None, pillar = None):
query, db_url, engine, ci_details, connection = __connection(ci_id=ci_id, query = query, template = template, dbname = dbname, pillar = pillar)
try:
results = engine.execute(query)
if results.returns_rows:
output = []
for result in results:
output.append(dict(result))
try:
return json.dumps(output, indent=3)
except:
return output
else:
if results.rowcount == 0:
return 'Rows Effected: {}'.format(results.rowcount)
return 'Success, {} row updated'.format(results.rowcount)
except Exception as e:
return "Invalid Query" + "\n" + "Error: " + json.dumps(e.message) + "\n" + "Actual Formated Query:" + query
this module use one more modules inside /salt/utils directory.. i have increased gather_job_timeout: 20 timeout: 100 as well... it above my head that if the same module works with salt-call, why its not working with salt master
It could possibly still work with the master calling it. WHat you are probably seeing is the minion is not responding in time, but eventually sends the data back.
You can always run the salt master command with --async, that will give you the job id, then you can use the job id to look in the job cache for the minion response.
If you can give me a salt-vagrant-demo setup that can make this easy to replicate, I would appreciate it.
Or just another way to replicate this issue.
root@cri-dev-postgres:~# salt master db.run_query template="oracle_show_client_version" ci_id="sub-1504158985538" -l debug [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] Configuration file path: /etc/salt/master [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/integration.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/integration.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc [DEBUG ] LazyLoaded local_cache.get_load [DEBUG ] Reading minion list from /var/cache/salt/master/jobs/48/ce75051898d963f1e1f7eaaf516fc724c062c6debde002567c060a7bfb5b85/.minions.p [DEBUG ] get_iter_returns for jid 20170908115044177817 sent to set(['master']) will timeout at 11:53:44.192489 [DEBUG ] Checking whether jid 20170908115044177817 is still running [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'cri-dev-postgres_master', 'tcp://10.236.220.165:4506', 'clear') [DEBUG ] retcode missing from client return [DEBUG ] return event: {'master': {'failed': True}} [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded localfs.init_kwargs [DEBUG ] LazyLoaded no_return.output master: Minion did not return. [No response]
====================== tail -f /var/log/salt/minion
2017-09-08 11:50:44,280 [salt.minion ][INFO ][11161] Starting a new job with PID 11161 2017-09-08 11:50:44,368 [salt.utils.lazy ][DEBUG ][11161] LazyLoaded db.run_query 2017-09-08 11:50:44,370 [salt.utils.lazy ][DEBUG ][11161] LazyLoaded direct_call.get 2017-09-08 11:50:44,371 [salt.config ][DEBUG ][11161] Reading configuration from /etc/salt/master.d/integration.conf 2017-09-08 11:50:44,386 [salt.config ][DEBUG ][11161] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres 2017-09-08 11:50:44,388 [salt.config ][DEBUG ][11161] Reading configuration from /etc/salt/master.d/integration.conf 2017-09-08 11:50:44,400 [salt.config ][DEBUG ][11161] Using cached minion ID from /etc/salt/minion_id: cri-dev-postgres 2017-09-08 11:50:44,406 [urllib3.connectionpool][DEBUG ][11161] Starting new HTTP connection (1): 10.236.220.121 2017-09-08 11:50:44,426 [urllib3.connectionpool][DEBUG ][11161] http://10.236.220.121:5000 "GET /api/v1/viewentities?where=%7B%22entityid%22:%22sub-1504158985538%22%7D HTTP/1.1" 200 1028 2017-09-08 11:53:44,209 [salt.minion ][INFO ][7161] User root Executing command saltutil.find_job with jid 20170908115344201012 2017-09-08 11:53:44,209 [salt.minion ][DEBUG ][7161] Command details {'tgt_type': 'list', 'jid': '20170908115344201012', 'tgt': ['master'], 'ret': '', 'user': 'root', 'arg': ['20170908115044177817'], 'fun': 'saltutil.find_job'} 2017-09-08 11:53:44,236 [salt.minion ][INFO ][11375] Starting a new job with PID 11375 2017-09-08 11:53:44,254 [salt.utils.lazy ][DEBUG ][11375] LazyLoaded saltutil.find_job 2017-09-08 11:53:44,256 [salt.utils.lazy ][DEBUG ][11375] LazyLoaded direct_call.get 2017-09-08 11:53:44,257 [salt.minion ][DEBUG ][11375] Minion return retry timer set to 6 seconds (randomized) 2017-09-08 11:53:44,258 [salt.minion ][INFO ][11375] Returning information for job: 20170908115344201012 2017-09-08 11:53:44,259 [salt.transport.zeromq][DEBUG ][11375] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506', 'aes') 2017-09-08 11:53:44,259 [salt.crypt ][DEBUG ][11375] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'master', 'tcp://10.236.220.165:4506') 2017-09-08 11:53:44,272 [salt.minion ][DEBUG ][11375] minion return: {'fun_args': ['20170908115044177817'], 'jid': '20170908115344201012', 'return': {}, 'retcode': 0, 'success': True, 'fun': 'saltutil.find_job'}
You can always run the salt master command with --async, that will give you the job id, then you can use the job id to look in the job cache for the minion response.
can you tell me the steps to look into the job cache for minion response.
You can pass the jid from the job using job.lookup_jid
https://docs.saltstack.com/en/latest/ref/runners/all/salt.runners.jobs.html#salt.runners.jobs.lookup_jid
root@cri-dev-postgres:~# salt master db.run_query template="oracle_show_client_version" ci_id="sub-1504158985538" --async Executed command with job ID: 20170908120015158089
unfortunately no output.
root@cri-dev-postgres:~# salt-run jobs.lookup_jid 20170908120015158089 root@cri-dev-postgres:~# salt-run jobs.lookup_jid 20170908120015158089 root@cri-dev-postgres:~#