VMware Cloud Community
ZakiSAMMANI
Contributor
Contributor
Jump to solution

workflow vmware orchestrator

Hello, i'm running a bash script on a redhat linux machine using vmware orchestrator workflow - "scriptable task", for some reason the script gets stuck in the first task even though the script has already an exit command and it works fine when i run it directly in the machine.

I was wondering if there is a way to skip the task after a certain time and start executing the next task in the workflow ?

0 Kudos
3 Solutions

Accepted Solutions
WhiteForEver
Enthusiast
Enthusiast
Jump to solution

If you need to wait for 10 minutes before you send an SSHCommand, and until you get the response from your RedHat server, I guess that's what you are looking for:

...
session.executeCommand( sshCommand, true );
System.sleep(600000) // 10 mins
session.output
...

There are a few problems with that "solution":

1. An SSH session timeout exists. It will disconnect you before you need it. (can be configured via `session.soTimeout = xxxx (in milliseconds);`

2. Using some ASYNC code is better than pausing the whole execution. 

3. If ASYNC is not an option, and you know for sure you will need to wait for 10 minutes, I would consider triggering the script execution, dumping the output of the ReadHat script to some temp file, and writing another Action Element, which will come directly after the Scriptable Task, which will run some `for` or `while` loop and check the status of the dump file and look for a specific value inside. By that, you can decide (using the Decision Maker) after 10 minutes what you will do if the output of parsing the dump file matches your expectations or not.



----------------------------------------------------------
Thank you for your feedback regarding my response.
If it has successfully resolved your issue, kindly mark it as RESOLVED

Take a look at my blog below.
https://www.clouddepth.com

View solution in original post

hcfede
Enthusiast
Enthusiast
Jump to solution

Hi @ZakiSAMMANI,

If your Scriptable Task runs for 10 minutes, it will definitely timeout. If I remember correctly, the timeout for a Scriptable Task is 180 seconds. By using an action, you have the ability to increase both the timeout and the maximum memory that can be utilized.

In your case, you might try creating an action that contains the code from your Scriptable Task which runs for 10 minutes. You will need to configure your inputs, outputs, and most importantly, the maximum execution duration.

Within the workflow, you should replace your Scriptable Task with the newly created action.

hcfede_0-1710346826246.png

 

_______________________________
I appreciate your feedback on my answer!
If it has solved your issue, please mark it as RESOLVED!

Check my blog for more contents!
https://www.immiblogghenicloud.cloud

View solution in original post

0 Kudos
WhiteForEver
Enthusiast
Enthusiast
Jump to solution

I’m glad to hear ☺️



----------------------------------------------------------
Thank you for your feedback regarding my response.
If it has successfully resolved your issue, kindly mark it as RESOLVED

Take a look at my blog below.
https://www.clouddepth.com

View solution in original post

0 Kudos
9 Replies
hcfede
Enthusiast
Enthusiast
Jump to solution

Hi,

To define a timeout on a scriptable task, you can convert it into an action that is then called by the workflow. In the action, you can set a custom timeout.

 

To understand the reason why your scriptable task is stalling, more details would be needed.

_______________________________
I appreciate your feedback on my answer!
If it has solved your issue, please mark it as RESOLVED!

Check my blog for more contents!
https://www.immiblogghenicloud.cloud
0 Kudos
ZakiSAMMANI
Contributor
Contributor
Jump to solution

Hello, thank you for your reply.

I've never used the "Actions" before so could you please tell me if the timeout is a parametre that i can set or i should use a command line?

0 Kudos
WhiteForEver
Enthusiast
Enthusiast
Jump to solution

Hey.

I am unsure if using the Action element to solve your issue is a mandatory requirement. Therefore, I will split my comment:

1. Following the VMware Orchestrator Coding Design Guide:

  • For short sleeps, you only need to do a System.sleep to avoid serializing and deserializing the workflow inputs, attributes, and so on.*
  • Sleeping for an extended period of time should be done with a workflow sleep, by using a Waiting Timer versus a sleep within a scriptable task.

A Waiting Timer is an element you can drag to the canvas and use whenever you need.

2. I definitely agree with @hcfede - in general, usage of Action Elements (technically a Function) is highly recommended almost everywhere and almost in all use cases. If you try to split your code into functions (to make it cleaner and testable), you can do it in Scriptable tasks or Action Elements. Creating an Action Element and dragging it to the canvas is always better.

From your initial post, it's unclear if you're using SSH to connect to the remote server. I guess that is the case. If so, please take a look at my post, which is related to vRO and SSH, here.

 



----------------------------------------------------------
Thank you for your feedback regarding my response.
If it has successfully resolved your issue, kindly mark it as RESOLVED

Take a look at my blog below.
https://www.clouddepth.com
0 Kudos
ZakiSAMMANI
Contributor
Contributor
Jump to solution

Hello, thank you for reply

I've already added a sleep time in the workflow but the problem is that my scriptable task runs a script that keeps showing the logs of the service (on a redhat machine) which causes vmware to get stuck in this task (it's important that the script keeps running in the background) so what i'm really searching for is a way that vmware run the scriptable task during 10 minutes only and then skip to the next task instead of being stuck in the scriptable task.
I'm not sur how can i do this using an "action" as proposed by @hcfede 

0 Kudos
WhiteForEver
Enthusiast
Enthusiast
Jump to solution

If you need to wait for 10 minutes before you send an SSHCommand, and until you get the response from your RedHat server, I guess that's what you are looking for:

...
session.executeCommand( sshCommand, true );
System.sleep(600000) // 10 mins
session.output
...

There are a few problems with that "solution":

1. An SSH session timeout exists. It will disconnect you before you need it. (can be configured via `session.soTimeout = xxxx (in milliseconds);`

2. Using some ASYNC code is better than pausing the whole execution. 

3. If ASYNC is not an option, and you know for sure you will need to wait for 10 minutes, I would consider triggering the script execution, dumping the output of the ReadHat script to some temp file, and writing another Action Element, which will come directly after the Scriptable Task, which will run some `for` or `while` loop and check the status of the dump file and look for a specific value inside. By that, you can decide (using the Decision Maker) after 10 minutes what you will do if the output of parsing the dump file matches your expectations or not.



----------------------------------------------------------
Thank you for your feedback regarding my response.
If it has successfully resolved your issue, kindly mark it as RESOLVED

Take a look at my blog below.
https://www.clouddepth.com
hcfede
Enthusiast
Enthusiast
Jump to solution

Hi @ZakiSAMMANI,

If your Scriptable Task runs for 10 minutes, it will definitely timeout. If I remember correctly, the timeout for a Scriptable Task is 180 seconds. By using an action, you have the ability to increase both the timeout and the maximum memory that can be utilized.

In your case, you might try creating an action that contains the code from your Scriptable Task which runs for 10 minutes. You will need to configure your inputs, outputs, and most importantly, the maximum execution duration.

Within the workflow, you should replace your Scriptable Task with the newly created action.

hcfede_0-1710346826246.png

 

_______________________________
I appreciate your feedback on my answer!
If it has solved your issue, please mark it as RESOLVED!

Check my blog for more contents!
https://www.immiblogghenicloud.cloud
0 Kudos
hcfede
Enthusiast
Enthusiast
Jump to solution


@WhiteForEver  I believe the option you proposed, to dump the log files into a temp file and use another script to verify that the script on the VM has been executed successfully by adding a Decision Maker, is a great option!

_______________________________
I appreciate your feedback on my answer!
If it has solved your issue, please mark it as RESOLVED!

Check my blog for more contents!
https://www.immiblogghenicloud.cloud
0 Kudos
WhiteForEver
Enthusiast
Enthusiast
Jump to solution

I’m glad to hear ☺️



----------------------------------------------------------
Thank you for your feedback regarding my response.
If it has successfully resolved your issue, kindly mark it as RESOLVED

Take a look at my blog below.
https://www.clouddepth.com
0 Kudos
ZakiSAMMANI
Contributor
Contributor
Jump to solution

Hello again, @WhiteForEver @hcfede  i thank both of you for your kind reply, i'm defently gonna try those options.

have a great day.