Man,
Not sure how I got so messed up on this post. I started going over the post again from the top to make sure I was not missing a piece of the issue and found that my troubleshooting and support were flip flopping between App Genie and Chocolatey for Automate. So as i made requests and examples of SQL this was only accurate half the time. My brain was popping back and forth across different plugins.
So let's start over here with a common issue.
App Genie has a script error during updates to agents.
As of
P4A - App Genie Maintenance script version 1.0.20
When the Update command is sent via the automation to this script it will start in the else section at line #63.
The script starts off by requesting SQL data from the database and is expecting back 1 or more rows of data.
Here is that SQL request: (make sure to replace = '%computerid%' with '123' or whatever agent ID your testing against.)
Code: Select all
SELECT b.ID As AppAssocID,s.Name, b.RepoName, s.version, a.LastUpdate, b.version as RepoVersion
FROM plugin_p4a_app_genie_agent_apps a
LEFT JOIN plugin_p4a_app_genie_assoc b ON a.AppAssocID = b.ID
LEFT JOIN software s ON a.ComputerID = s.ComputerID and s.Name like b.AppName
WHERE a.ComputerID = '%computerid%'
and s.version <> b.version
and DATE(a.LastUpdate) <> DATE(NOW());
The request ask for by AgentID all installed software shown for agent, that is shown to not match version and that has not already been updated today.
This should return data on the first run of the day (if software changes) but not again if "Lastupdate" has today's date. Otherwise the request returns 0 rows. This is where the error pops up. we have not tested for zero rows so a Loop error is generated when we try to loop through zero rows of data. We are fixing this in the next build of App Genie.
If you modify the SQL query and run it in SQL yog you can see that if software shows installed that it will return data. Lets remove a piece of the first query. The time clause... Lets just see if we have software installed updated anytime...
Here is that SQL request: (make sure to replace = '%computerid%' with '123' or whatever agent ID your testing against.)
Code: Select all
SELECT b.ID As AppAssocID,s.Name, b.RepoName, s.version, a.LastUpdate, b.version as RepoVersion
FROM plugin_p4a_app_genie_agent_apps a
LEFT JOIN plugin_p4a_app_genie_assoc b ON a.AppAssocID = b.ID
LEFT JOIN software s ON a.ComputerID = s.ComputerID and s.Name like b.AppName
WHERE a.ComputerID = '%computerid%'
and s.version <> b.version;
The return data should look like this. This is my agentID #2 shown in image below. When I remove the data part of the where clause I get all the apps installed on the agent and their versions tested.
- Capture.PNG (55.77 KiB) Viewed 8759 times
This should give you an understanding of what is taking place with script errors. If we look at the logs and the timeline we should be able to see when the first updates of the day ran. That is where Chocolatey was told to update some softwares if they existed and showed out of date. At that point Chocolatey would of returned some response to the update command sent. This is where errors at the framework level would show up if they appeared. This data would help explain why a update may have failed.
I will add 2 changes to the update functions in the script.
#1 I will test for zero rows returned and exit out nicely if no rows returned.
#2 I will setup a logger that will capture the output of the update command and store that in the database so we can retrieve it in the plugin to display to you when you select a particular installed software from plugin.
This log will be the last know status of the update command. It should provide you the data needed to better determine why a failure is happening.
I will have the update out later today.