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

agent crashes if directory from agent.cfg OptDir doesn't exist #150

Open
namachieli opened this issue May 1, 2017 · 3 comments
Open

agent crashes if directory from agent.cfg OptDir doesn't exist #150

namachieli opened this issue May 1, 2017 · 3 comments

Comments

@namachieli
Copy link

Ran into an issue when running an agent for the first time, where the agent didn't run and compile everything itself. (I put an already compiled copy of todd and todd-agent into /usr/bin and manually made /etc/todd/agent.cfg)

When starting the agent I got

FATA[0000] "unable to open database file": 
                CREATE TABLE testruns (id INTEGER NOT NULL PRIMARY KEY, uuid TEXT, testlet TEXT, args TEXT, targets TEXT, results TEXT);
                CREATE TABLE keyvalue (id INTEGER NOT NULL PRIMARY KEY, key TEXT, value TEXT);

Looking into it, it seems that if the directory /opt/todd/agent/ doesn't exist, the agent dies when attempting to make /opt/todd/agent/agent_cache.db. If i make the directory manually, todd-agent then creates required sub-directories, creates the db file, and downloads both factcollector scripts.

toddagent@agent:~$ sudo mkdir -p /opt/todd/agent
toddagent@agent:~$ sudo todd-agent           
DEBU[0000] Writing keyvalue pair to agent cache - uuid:b6fe98b2411ce24e206682d3184fc3ad0da30278254660f1e471a4c81287ef54
 
INFO[0000] ToDD Agent Activated: b6fe98b2411ce24e206682d3184fc3ad0da30278254660f1e471a4c81287ef54 
DEBU[0000] Retrieving value of key - uuid
              
DEBU[0000] Retrieving value of key - group
             
DEBU[0000] Agent re-registering onto group queue - null 
INFO[0000] AGENTADV -- 2017-05-01 17:08:07.823829677 +0000 UTC 
INFO[0000]  [*] Waiting for messages. To exit press CTRL+C 
DEBU[0000] Agent task received: {"type":"DownloadAsset","assets":["http://10.17.9.159:8090/factcollectors/get_addresses","http://10.17.9.159:8090/factcollectors/get_hostname","http://10.17.9.159:8090/testlets/iperf","http://10.17.9.159:8090/testlets/http"]} 
INFO[0000] Downloading http://10.17.9.159:8090/factcollectors/get_addresses to /opt/todd/agent/assets/factcollectors/get_addresses 
INFO[0000] 425 bytes downloaded.                        
INFO[0000] Downloading http://10.17.9.159:8090/factcollectors/get_hostname to /opt/todd/agent/assets/factcollectors/get_hostname 
INFO[0000] 231 bytes downloaded.    
                    
toddagent@agent:~$ ls -LR /opt/todd/agent
/opt/todd/agent:
agent_cache.db  assets

/opt/todd/agent/assets:
factcollectors  testlets

/opt/todd/agent/assets/factcollectors:
get_addresses  get_hostname

/opt/todd/agent/assets/testlets:
http  iperf

@Mierdin
Copy link
Member

Mierdin commented May 1, 2017

When you say:

I put an already compiled copy of todd and todd-agent into /usr/bin and manually made /etc/todd/agent.cfg

That might be the problem. Did you follow the installation instructions? Note that in the makefile, which is referenced there, this directory is created for you

@namachieli
Copy link
Author

namachieli commented May 1, 2017

That's what im getting at, I didn't compile todd on the agent running it, i used an already pre-compiled bin.

I'm aware its created automatically through the stock installation, but If I'm going to deploy this to 50 raspberry Pi's, im not running make on every single one. I'm going to image the SD card with an out of the box image.

What this does mean is, if for any reason the opt dir is nuked (manually or otherwise), the agent will just panic.

I would think there should be some logic in the agent binary (and probably server too) to check for the directory, and if it isn't there, attempt to make it.

just my $0.02

@Mierdin
Copy link
Member

Mierdin commented May 2, 2017

I agree compiling from source on each node isn't always a great option. This has been discussed before and while I'm still generally open to the creation of these directories in the program, the first problem to tackle is add packaging so this is set up using APT and you don't have to compile. Been meaning to do that, just haven't gotten around to it. My thoughts generally are, yeah it's not hard to add the logic into ToDD, then again, if someone wants to go around deleting directories, that's kind of on them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants