switch-inject-lite

Post Reply
User avatar
gabrielp
Advanced member
Posts: 577
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
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
User avatar
gabrielp
Advanced member
Posts: 577
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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
User avatar
gabrielp
Advanced member
Posts: 577
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!
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
actionHero
Newbie
Posts: 15
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: 577
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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
actionHero
Newbie
Posts: 15
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
Newbie
Posts: 15
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: 577
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...
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
actionHero
Newbie
Posts: 15
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
Newbie
Posts: 1
Joined: Wed Mar 22, 2017 5:05 pm

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 32132 times
Any ideas please

Thanks
Malcolm
User avatar
gabrielp
Advanced member
Posts: 577
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?
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Post Reply