BookmarkSubscribeRSS Feed
willi_m
Calcite | Level 5

Hello, 

 

I try to execute SAS code through the SAS Job Execution server (Version 2.2) on Viya  platform (V.03.05)

I call the API through shell script and curl command as follow:

#--- Execute SAS job
rc_curl=$(curl -k -X POST "https://${tenant}.${BASEAPIURL}/SASJobExecution/" \
   --connect-timeout 14400 \
   -H "Authorization: Bearer $ACCESS_TOKEN" \
   -H 'Content-Type: application/x-www-form-urlencoded' \
   -H 'Accept: *' \
   -d "_program=/Projects/my_program/&_log=${log}&_param=${param}&_timeout=14400&CSRF=\$CSRF\$" 
   )

I redirect the log in my SAS program in another location in order to parse it with my shell.

 

It works well when the program ran fast, but sometime the program can take a very long time (more than 1 hour).

The issue is that in this case,  the curl command exit, as if the Job is finished. But when I check in the Job Execution Interface, it is still running. 

 

I though that it was my access_token but the time validity is set to 14400 (approx 4h). 

I try the timeout option of curl with same value but it didn't work.

 

I don't know what is the issue. Does someone have an idea ? 

 

 

 

 

6 REPLIES 6
AllanBowe
Barite | Level 11

Hi @willi_m ,

 

We also observed shaky behaviour in long-running jobs in Viya 3.5 - and so we implemented a 'retries' feature in the SASjs CLI, which ultimately fixed the issue (the customer was running many long-running jobs, so was tested quite heavily)

 

You can find the docs here:  https://cli.sasjs.io/job/

 

Best,

Allan

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
willi_m
Calcite | Level 5

Hi @AllanBowe

thanks for your answer, i will see if it is possible to install and use this package on my company (as there is some restrictions for the installation of external tool).

 

Things that i noticed and forget in my issue description, is that the curl (rc_curl variable) return me that thing:.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Proxy Error</title>
</head><body>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request <em><a href="/SASJobExecution/">POST&nbsp;/SASJobExecution/</a        ></em>.<p>
Reason: <strong>Error reading from remote server</strong></p></p>
</body></html>

any idea ?

AllanBowe
Barite | Level 11

It happens sometimes.  Actually, quite frequently.  It's not necessarily a Viya issue, could be networking / system related. 

 

SASjs is MIT open source, there are no usage restrictions.  You can compile it directly from github:  https://github.com/sasjs/cli

 

Alternatively, you can build your own tool to poll the status and perform X number of retries for a non-200 response.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Vince_DelGobbo
Calcite | Level 5

You might be experiencing what's described here:

 

Job Execution Time-out

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/jobexecug/p1ct9uzl5c7omun1t2zy0gxhlqlc.htm#n1...

 

If so, then using _action=wait or _action=background might help.

 

Vince DelGobbo

Formerly SAS R&D

willi_m
Calcite | Level 5

After some search we found a solution, that i will explain here for other people in the same case.

We change the endpoint to trigger to not launch job directly but creating a JobRequest.

Then the JobRequest is launch and we parse the response to take the JobExecutionId.

Then in a loop we check the status of the job every 15-20sec until the Status is "COMPLETED".

 

Thanks all for you help.

AllanBowe
Barite | Level 11

That's pretty much what the SASjs CLI does (although it starts by polling fast, then polls more slowly).

 

Thanks for sharing your solution!

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2695 views
  • 1 like
  • 3 in conversation