<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>The Wombelix Post - Exception</title><link href="https://dominik.wombacher.cc/" rel="alternate"/><link href="/feeds/tag_exception.atom.xml" rel="self"/><id>https://dominik.wombacher.cc/</id><updated>2021-03-02T00:00:00+01:00</updated><entry><title>SUSE Manager / Uyuni - Salt SSH Push: Thin package corrupted</title><link href="https://dominik.wombacher.cc/posts/suse-manager-uyuni-salt-ssh-push-thin-package-corrupted.html" rel="alternate"/><published>2021-03-02T00:00:00+01:00</published><updated>2021-03-02T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2021-03-02:/posts/suse-manager-uyuni-salt-ssh-push-thin-package-corrupted.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;At work we had issues with almost all Salt-SSH / SSH-Push connected Clients for months due to an unhandled exception &lt;code&gt;ImportError: No module named 'salt.exceptions'&lt;/code&gt; that occurred regularly. It took  ... &lt;a class="read-more" href="/posts/suse-manager-uyuni-salt-ssh-push-thin-package-corrupted.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;At work we had issues with almost all Salt-SSH / SSH-Push connected Clients for months due to an unhandled exception &lt;code&gt;ImportError: No module named 'salt.exceptions'&lt;/code&gt; that occurred regularly. It took me a lot of time to track the issue down together with SUSE so I want to share my Experience.&lt;/p&gt;
&lt;div class="section" id="error"&gt;
&lt;h2&gt;Error&lt;/h2&gt;
&lt;pre class="code text literal-block"&gt;
[...]
&amp;quot;stderr&amp;quot;: &amp;quot;Traceback (most recent call last):\n File
\&amp;quot;/var/tmp/.user_a567dc_salt/salt-call\&amp;quot;, line 26, in \n from
salt.scripts import salt_call\n File
\&amp;quot;/var/tmp/.user_a567dc_salt/pyall/salt/scripts.py\&amp;quot;, line 21, in \n
from salt.exceptions import SaltSystemExit, SaltClientError,
SaltReqTimeoutError\nImportError: No module named 'salt.exceptions'&amp;quot;
[...]

&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="background"&gt;
&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;Normally Salt is using an Agent (Salt-Minion) but also supports an Agentless approach called Salt-SSH.
A package (&lt;em&gt;&amp;quot;thin.tgz&amp;quot;&lt;/em&gt;), which contains all python code and files that Salt need to run Jobs on a server, will be uploaded and extracted to &lt;strong&gt;/var/tmp/.&amp;lt;user&amp;gt;_&amp;lt;id&amp;gt;_salt/&lt;/strong&gt; on the target Server.
The &amp;quot;&lt;em&gt;id&lt;/em&gt;&amp;quot; is related to the used Salt Version, the &amp;quot;&lt;em&gt;user&lt;/em&gt;&amp;quot; is the one configured on the Salt Master - in our Case SUSE Manager - which has full sudo permissions and is allowed to login via SSH on the target.&lt;/p&gt;
&lt;p&gt;Everytime Salt connect to run a Job, some checks will performed to verify that state of the thin package:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Does the Folder for the specified user with the matching id exist in &lt;em&gt;/var/tmp/&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Is the file &lt;em&gt;&amp;quot;code-checksum&amp;quot;&lt;/em&gt; available and does the containing checksum matches with the thin.tgz package on the Salt Master&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As long both checks are successful, the Salt Master will _not_ upload a new &lt;em&gt;thin.tgz&lt;/em&gt; - that's important to understand.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="troubleshooting"&gt;
&lt;h2&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;First it was totally unclear were the issue was coming from, it could occur with every job type, on different server at a different time.
The thin package was always corrupted at some point what caused the unhandled exception.
The Workaround was to manually delete the whole folder of the Salt thin package on the target Server so the Salt Master uploaded a fresh copy next time.&lt;/p&gt;
&lt;p&gt;SUSE helped to go through tons of logs and to visualize a timeline were I could see that the issue seem to occur every 7 days.&lt;/p&gt;
&lt;p&gt;Further investigation confirmed, in this case the problem was self-made. Someone from the Team configured systemd to automatically cleanup the tmp folder on a lot of server and neither tested nor documented it well.
Removing the thin package folder wouldn't be a problem, it would be just newly uploaded, as long it's done right but it wasn't.&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
/etc/tmpfiles.d/clean_tmp.conf

D /tmp 1777 root root 7d
D /var/tmp 1777 root root 7d

&lt;/pre&gt;
&lt;p&gt;The tmpfiles config removed only files and folder owned by user &lt;em&gt;root&lt;/em&gt;, but a few files, like &amp;quot;&lt;em&gt;code-checksum&lt;/em&gt;&amp;quot;, of the thin package folder are owned by salt.
So every 7 days almost all files were removed and therefore corrupted Salt thin, but the Salt Master found the folder and the &amp;quot;&lt;em&gt;code-checksum&lt;/em&gt;&amp;quot; file with the correct hash and thought the thin state is healthy.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="solution"&gt;
&lt;h2&gt;Solution&lt;/h2&gt;
&lt;p&gt;At the end I just removed the custom tmpfiles config and once again the thin folder manually on all affected server.&lt;/p&gt;
&lt;p&gt;For us there wasn't much benefit in deleting the thin package weekly and generate high load and consume bandwith to re-upload it. In case you prefer the regular cleanup of your tmp folders, just ensure that the whole thin folder and all files are covered and either removed ore kept untouched by your ruleset.&lt;/p&gt;
&lt;p&gt;Even though it was a human error and not directly related to SUSE Manager / Uyuni or Salt it demonstrated how fragile such components can be.
From a technical point of view I understand why there are just a few checks and validation of the hash in a file.
Doing that for the whole folder content on every job run would horrible slow and increase the load.
But as we can see, it comes with a price and can be affected by something you wouldn't expect.&lt;/p&gt;
&lt;/div&gt;
</content><category term="Linux"/><category term="Uyuni"/><category term="SUSE Manager"/><category term="SSH"/><category term="Salt"/><category term="Exception"/></entry></feed>