switch-inject-lite

User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

switch-inject-lite

Post by gabrielp »

switch-inject-lite
The purpose of this script is to provide a low-risk and contextual alternative to the Inject configurator.

While the stock Inject configurator is extremely powerful, for many operations, it poses a significant risk. The ability to copy and remove a remote file (which may be a variable) is extremely dangerous. The target variable could resolve incorrectly causing the destruction of Switch's own backing files, or other sensative files. In some cases, users have reported using the "Job repository" method of Inject, where "Job name" property resolves to null, which results in the entire repository being injected (and removed).

The stock Inject configurator assumes that target jobs exist. If you aren't sure where the target job is, you have to send your incoming job into several incoming jobs, expecting all but one to fail. This results in routing out these non-failures from problem jobs, which is undesirable.

https://github.com/open-automation/switch-inject-lite

Use case: production file request system
This flow handles production file requests from our customer web portal. The web portal creates a simple XML file which Switch watches for. Then, Switch takes the job number from the XML file and attempts to find the file in one of 3 locations: live jobs, archive 1, or archive 2.

Image

1) The first problem is that we don't know where the backed up files actually are. That's because we dynamically move files from the live jobs folder to the archives 1 and 2 as work is completed. So with the stock Inject, we have to inject against all 3 directories every time, which is quite a bit of overhead.

2) The second problem is, since the files are in 1 location but we have to inject against all 3, we now expect at least 2 failures with every successful retrieval. That means we have to route jobs out of problem jobs (since they are not truly problems). This adds junk to our log and is generally confusing.

3) The third problem is, Inject assumes the target job exists, and it sends the file to problem jobs if it does not. Because of this, we cannot run the injects in sequence and we cannot tell if all of them had failed (if we could not find any production files). The only way to accomplish this would be to assemble the known failures out of problem jobs, then send an email if there were 3 that matched the same job number, which again is routing business logic out of problem jobs (a known anti-pattern).

4) Lastly, the Inject configurator has the ability to remove the target file if the option "Delete after injection" were set to "Yes". It's easy enough to set this to "No", but it is very easy to scroll on the mouse while hovering over injector properties which changes them. There have been cases where injecting a null job name on a job repository can inject the entire repository. So there is a minor risk of deleting our entire live jobs or archive volumes if that were to happen.

A redesigned flow using switch-inject-lite addresses these concerns (as well as relies on a functional flow to gather metadata).

Image

1) In this flow, we only inject against the next directory if the previous had failed, since we are making use of the traffic-light-style connector.

2) We are not sending any injection failures into problem jobs. Instead, they are routed via traffic light, keeping our business logic in the flow and our log and problem jobs folder reserved for true problems.

3) switch-inject-lite does not assume the target file exists, therefore we can route the injects in sequence. If the final inject in the sequence fails, we know that the files could not be found in any location and we can handle that business logic easily.

4) switch-inject-lite cannot delete files after injection, therefore there is no risk of any accidental deletes.

Scripts used:
- switch-portals
- switch-variable-assert
- switch-private-data-write
- switch-inject-lite
- switch-aws
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

Update today. Latest version now supports counting the target job and getting the size of the target job. This is helpful to see if you want to inject something, checking to see if its too large before you spend the resources copying it with inject.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

Now available as a free app in the Enfocus appstore. https://appstore.enfocus.com/product/InjectLite

Thanks Freddy!
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

Re: switch-inject-lite

Post by actionHero »

First off this is an awesome concept I love it. I'm having issues with the "read-only" inject, it's not injecting it. If I do the Assert Check, it can see the file. Is there an issue with the "read-only?

Thanks!
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

actionHero wrote:First off this is an awesome concept I love it. I'm having issues with the "read-only" inject, it's not injecting it. If I do the Assert Check, it can see the file. Is there an issue with the "read-only?

Thanks!
Any log messages when you try the read-only inject? Try to enable debug logging messages in your Switch preferences.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

Re: switch-inject-lite

Post by actionHero »

Hello,
This is the only message, Read-only inject was unsuccessful.
Thanks!

If I use the same path on the actual inject confg, it works.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

Re: switch-inject-lite

Post by actionHero »

I just tried some things and it appears to be in the "Name Job After". If I name after injection job it fails. If I name after Incoming Job it works but is the wrong name.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

Please turn on debugging log messages and post or send me your log. I'm not sure what's happening here...
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

Re: switch-inject-lite

Post by actionHero »

I'm sorry but nothing different logs when debug is turned on.
Malcolm Mackenzie
Member
Posts: 121
Joined: Wed Mar 22, 2017 5:05 pm
Location: London, UK
Contact:

Re: switch-inject-lite

Post by Malcolm Mackenzie »

Hi

Got an issue with Inject Lite showing an error
Error in line 101 of script : Error. Trying to access undefined member '1'
I have the same setup on another PC with no issue.
Screenshot 2017-08-15 16.01.21.png
Screenshot 2017-08-15 16.01.21.png (11.53 KiB) Viewed 19185 times
Any ideas please

Thanks
Malcolm
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

Malcolm Mackenzie wrote:Hi

Got an issue with Inject Lite showing an error
Error in line 101 of script : Error. Trying to access undefined member '1'
I have the same setup on another PC with no issue.
Screenshot 2017-08-15 16.01.21.png
Any ideas please

Thanks
Malcolm
Could you turn on debug logging and post the log output when you run something through?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Malcolm Mackenzie
Member
Posts: 121
Joined: Wed Mar 22, 2017 5:05 pm
Location: London, UK
Contact:

Re: switch-inject-lite

Post by Malcolm Mackenzie »

Hi Gabriel
Sorry for the late response, thought I would get a notification of a posting.
I found the error is to do with the issue of mapped drives and Run as a Service/Watchdog.
The mapped drive drops if you run Switch as a service so Inject Light just sits unable to process the file.
Working on the best setup for the client now.
Thanks
Malcolm
Zoranj
Member
Posts: 107
Joined: Tue Sep 20, 2016 7:37 pm
Location: Canada

Re: switch-inject-lite

Post by Zoranj »

Gabriel, I am using Assert exist to check if file exist or not.
If file exist, everything is ok, however if the file does not exist, it fails and goes into "Problem Job" folder.
I have Error out connection to go to email, but it does not.
I can make workaround and take it from Problem job folder, however I am not sure if I did something wrong or if there is a bug.
This is log Debug or not it is same:
----7-08-31 16:53:58
error
Inject Lite
Pick layout
Inject Lite
00PUZ
CTP Replacement in STL.xlsx
Job '_00PUZ_CTP Replacement in STL.xlsx' was moved from folder 'E:/Enfocus App Data/backing/Pick layout/automanaged/Folder 1' to the problem jobs folder. Reason: see previous log message(s)
2017-08-31 16:53:58
error
Inject Lite
Pick layout
Inject Lite
00PUZ
CTP Replacement in STL.xlsx
Dynamic property 'JobPath' has invalid value '//ptr1/PTDATA/Impositions/8.375x10.875_PB1_HH.250_35.00x22.75_001_036pg_RO16X4RO4RO8RO16.jdf'
----
Attachments
Screen Shot 2017-08-31 at 5.00.55 PM.png
Screen Shot 2017-08-31 at 5.00.55 PM.png (154.27 KiB) Viewed 19087 times
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: switch-inject-lite

Post by gabrielp »

Zoranj wrote:Dynamic property 'JobPath' has invalid value
Try this version of the script: https://github.com/open-automation/swit ... -validator

Someone at Enfocus is working on an appstore fix for this.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Zoranj
Member
Posts: 107
Joined: Tue Sep 20, 2016 7:37 pm
Location: Canada

Re: switch-inject-lite

Post by Zoranj »

Script works as advertised, thanks
Post Reply