Help debugging fixlet

I have a fixlet that I know works. I send it down to hundreds of clients and it downloads the file, then check for the file existence and checking the sha1 value of the file. On some clients, it is failing on that file and sha1 check. After the fixlet fails, I can log onto the client and check the sha1 and all checks out fine.

My question is, is there a way to set the logs in a debug mode that would show me the exact line it’s running during the check? As far as I can tell, it should work, qunning qna with: exists file (parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action) whose (sha1 of it as lowercase = (parameter "_file_sha1") as lowercase) should work. (replacing parameters respectively of course)

I set the debug mode to 10000 and I don’t see the detail I’m looking for. Sort of useless actually.

This is a weird one I may have seen before (repeatedly).
Are you downloading the file in a Prefetch Block? If not…the client parses all of the Relevance Substitutions in the ActionScript before anything happens, which may include before downloading the file. So, before the file downloads, something like
sha1 of download file "myfile.txt" can give a “file does not exist” error. The particular piece you quote doesn’t look like a problem to me…but when I come across this, I get the error logged on all kinds of wrong line numbers (sometimes even logging an error against the wrong baseline component!)

Couple of things you could do -

  1. Put your downloads into a Prefetch Block. With a Prefetch Block, only the prefetch block itself is evaluated before the action starts.
  2. Otherwise, you could wrap your evaluations in a block to only evaluate during execution, like

if {active of action}

continue if { exists file (parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action) whose (sha1 of it as lowercase = (parameter "_file_sha1") as lowercase) }

endif

It is in a prefetch block.

begin prefetch block
	action parameter query "_file_name" with description "Please enter the file name of the script (must be less than 32 characters in length)."
	action parameter query "_file_sha1" with description "Please enter SHA1 value of script."
	action parameter query "_file_bytes" with description "Please enter size of script in bytes."
	action parameter query "_file_URL" with description "Please enter URL to script location. For example, http://server.domain.com/<repo-name>/<folders>/ and make sure to include final slash."
	action parameter query "rTarDestPath" with description "Please enter the destination path for the file on the endpoint(s). For example, /opt/<project-name>/<project-version>/files/ and make sure to include final slash."
	
	add prefetch item {"name=" & parameter "_file_name" of action & " sha1=" & parameter "_file_sha1" of action & " size=" & parameter "_file_bytes" of action & " url=" & parameter "_file_URL" of action &  "/"& parameter "_file_name" of action}
	collect prefetch items
end prefetch block

action parameter query "rTarExtract" with description "extract package Y/N"
action parameter query "rTarExtrPath" with description "extract Path"
action parameter query "rTarExtDel" with description "Delete archive post extraction Y/N"

action parameter query "rTarExc" with description "execute script post extraction Y/N"
action parameter query "rTarExcID" with description "user to run under"
action parameter query "rTarExcPath" with description "path to script"
action parameter query "rTarExcParm" with description "parameter to script"
action parameter query "rTarExtChNum" with description "change number associated to this deploy"

if {exists folder (parameter "rTarDestPath" of action)}
	// Delete any previous instances of payload.
	delete {parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action}
else
	wait mkdir -p "{parameter "rTarDestPath"}"
endif

// Move script to desired location.
move __Download/{parameter "_file_name" of action} {parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action}

if {exists file (parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action) whose (sha1 of it as lowercase = (parameter "_file_sha1") as lowercase)}

	if {(parameter "rTarExtract") as string as uppercase = "Y"}
	// Verify the SHA1SUM of the file on the VMA
		//ensure extracton path exists
		wait mkdir -p "{parameter "rTarExtrPath"}"
		//extract files
		wait tar xvf "{parameter "rTarDestPath"}/{parameter "_file_name"}" -C {parameter "rTarExtrPath"}
		parameter "__ExitCode" = "{if exist exit code of action then exit code of action as string else "997"}"
		if {parameter "__ExitCode" != "0"}
			exit {parameter "__ExitCode"}
		endif

		if {(parameter "rTarExtDel") as string as uppercase = "Y" }
			delete {parameter "rTarDestPath"}/{parameter "_file_name"}
		endif
	endif

	//run script post extraction
	if {(parameter "rTarExc") as string as uppercase = "Y"}
		if { exists file (parameter "rTarExcPath") }
			wait chmod +x {parameter "rTarExcPath"}
			wait runuser -l {parameter "rTarExcID"} -c "{parameter "rTarExcPath"} {parameter "rTarExcParm"}"

			parameter "__ExitCode3" = "{if exist exit code of action then exit code of action as string else "997"}"
			if {parameter "__ExitCode3" != "0"}
				exit {parameter "__ExitCode3"}
			endif
		else
			// script not found
			exit 2
		endif
	endif
else
	//file not found
	exit 1
endif

The download and extraction worked for 98 machines, but failed for 11. All the ones that failed, did so at the same if {exists file (parameter "rTarDestPath" of action & "/" & parameter "_file_name" of action) whose (sha1 of it as lowercase = (parameter "_file_sha1") as lowercase)} line. All I get is a relevance substitution error in the logs.

Command failed (Relevance substitution error.) if {exists file (parameter “rTarDestPath” of action & “/” & parameter “_file_name” of action) whose (sha1 of it as lowercase = (parameter “_file_sha1”) as lowercase)} (action:334466)

Not sure where to go from there. It downloaded with the proper sha1 and worked on most of the others.

This is all part of some automation I’m building. Deploying files to endpoints via a request process. The workflow does well except for this last mile on the relays themselves. I really need to get this more reliable otherwise I’m going to be babysitting this way to much.

Any thoughts on this Jason?

More than likely the “error” you are getting is that the file inspector is giving you an error because the file doesn’t exist on the endpoint. On the machines that fail, what did the “move” command say right before that?

At 15:59:36 -0400 - actionsite (http://root.domain.com:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded delete /var/opt/tmp/Office_06012016.tar.gz (action:336334)
Command succeeded move __Download/Office_06012016.tar.gz /var/opt/tmp/Office_06012016.tar.gz (action:336334)
At 16:00:36 -0400 - actionsite (http://root.domain.com:52311/cgi-bin/bfgather.exe/actionsite)
Command failed (Relevance substitution error.) if {exists file (parameter “rTarDestPath” of action & “/” & parameter “_file_name” of action) whose (sha1 of it as lowercase = (parameter “_file_sha1”) as lowercase)} (action:336334)
At 16:00:36 -0400 -
ActionLogMessage: (action:336334) ending action

Looked good. Like I said, the file exists. I can run /opt/BESClient/bin/qna and run my own relevances on the file exists and sha1 and it comes back true.

Just in general why are you even doing this? You are pretty guaranteed by the download that the file is the same sha1 as mentioned (as you put the sha1 in the prefetch item) so this is a redundant check. It is possible that on some systems there is a delay or a virus scanner or an indexer that is locking the file for a moment as you literally just moved it.

I’ll be honest, it’s sort of part of a standard fixlet set up we do… and it’s the way we have always done it. Doesn’t mean I’m not open to the idea of change.

That said, would it show up as a “Relevance substitution error” if the file wasn’t ready yet?

Yes, if the file wasn’t there then you would get that error trying to do a "file <name of file>" but the action also shouldn’t begin if it doesn’t have the downloads ready for it.

I’m not so sure - this is wrapped up with “exists” so I’d expect it to just return a False, not a relevance substitution error?

q: exists file ("c:\thisfolderdoesnotexist\" & "test.txt") whose (sha1 of it as lowercase = "ABC" as lowercase)
A: False
T: 0.163 ms
I: singular boolean

Is there maybe an error with the parameter value substitutions? Any odd characters in the filenames, sha1, or size? Any difference in the client versions between the clients that work and those that do not?

Good questions. Like I said, I could run this on a large number of clients but something like 90% successful execution, but and 10% failure with the client substitution errors. Client and Relay agent versions are all the same.

Going back to my original question. Is there a way to get more specific errors in the logs other than (more or less) “Relevance substitution error” on that line. Would love to see something like ‘Relevance substitution error while converting parameter “filesha1”’. Let me know where to start troubleshooting.

Oh and @AlanM, I have tried adding in a 60 second pause and it doesn’t fix things.