Propagate ErrorCode from a specific Oozie action in subworkflow to main workflow - oozie

An action ends with a E1111 ErrorCode in an Oozie subworkflow. The main workflow (which launches the subworkflow) shows with that the subworkflow is in ERROR but the ErrorCode og the subworkflow is empty (with oozie job -info ...).
Example:
Workflow Name : my_spark_subworkflow
-----------------------------------------------------------------------------------------------------------------------
0001411-220916160325662-oozie-oozi-W#my_spark_app ERROR 11957 ERROR E1111
------------------------------------------------------------------------------------------------------------------------------------
0001411-220916160325662-oozie-oozi-W#fail OK - OK E0729
------------------------------------------------------------------------------------------------------------------------------------
Workflow Name : my_main_workflow
------------------------------------------------------------------------------------------------------------------------------------
0001410-220916160325662-oozie-oozi-W#my_spark_subworkflow ERROR 0001411-220916160325662-oozie-oozi-WKILLED -
------------------------------------------------------------------------------------------------------------------------------------
The my_spark_subworkflow line in my_main_workflow shows ERROR but lost the ErrorCode (- is printed instead). This might be due to the #fail action that ends with OK in my_spark_subworkflow, but I would like the ErrorCode of my_spark_subworkflow to be used instead as a global subworkflow ErrorCode.

Related

Apache Airflow: rerun for tasks with date parameters

I have a hourly shell script job that takes a date and hour as input params. The date and hour are used to construct the input path to fetch data for the logic contained in the job DAG. When a job fails and I need to rerun it (by clicking "Clear" for the failed task node to clean up the status to re-trigger a new run), how can I make sure the date and hour used for rerun are the same as the failed run since the rerun could happen in a different hour as the original run?
You have 3 options:
Hover to the failed task which is going to clear, in its displaying tag there will be a value with key Run:, it is its Execution date and time.
Click on the failed task which is going to clear, heading of its displaying popup which has the clear option will be [taskname] on [executiondatewithtime]
Open the task log, the first line after the attempts count will be included a string with format Executing <Task([TaskName]): task_id> on [ExecutionDate withTime]

SAFE template Elmish redux dev tools message always "UserMsg"

I'm quite new to Elmish. Did a sample template using dotnet new SAFE. When I open the app and use redux dev tools Chrome extension I always get message which is "UserMsg". Is there a way to make it "Increment" or "Decrement" when I click the button "-" or "+"?
The elmish-browser Navigation module wrap all messages in the Parser type which is a union of either Change (for a URL change) or UserMsg (for everything else).
This breaks the reflection in both withDebugger and withConsoleTrace... they are unable to grab the name of the underlying message, and hence display the wrapped name instead.
The work-around is to invoke toNavigable after withDebugger in the program initialization pipeline:
Program.mkProgram init update view
#if DEBUG
|> Program.withConsoleTrace
#endif
|> Program.withReactBatched "elmish-app"
#if DEBUG
|> Program.withDebugger
#endif
|> Program.toNavigable (parseHash route) urlUpdate
|> Program.run
However, by doing this the "Change" messages are no longer sent to the debugger. This could be a problem if your urlUpdate function is updating the model state directly. It may be better for your urlUpdate function to raise a new command with a message to be handled by the main update function.
See https://github.com/elmish/browser/issues/26

Oozie commandline filters

oozie job -info $coordinator
the command gives you the details of workflows belong to the coordinator, print their ID, status, created time and nominal time.
I'm trying to print the workflows of the oozie coordinator which are executed after a specific date.
As per their documentation,
-filter <arg> <key><comparator><value>[;<key><comparator><value>]*
(All Coordinator actions satisfying the filters will be retrieved).
key: status or nominal time
comparator: =, !=, <, <=, >, >=. = is used as OR and others as AND
status: values are valid status like SUCCEEDED, KILLED etc. Only = and != apply for status.
nominaltime: time of format yyyy-MM-dd'T'HH:mm'Z'
From this, it's understandable that status key supports only "=" or "!=" whereas nominal time key supports all comparators.
But when I try to use it, I'm getting below error.
[hadoop#xx ~]$ oozie job -info $coord -filter status nominalTime>2018-09-01'T'08:00'Z'
Error: E0421 : E0421: Invalid job filter [nominalTime], filter should be of format <key><comparator><value> pairs
The same command works if I put "=" or "!=" but throws an error if you use other comparators. (>,<,>=,<=)
Kindly suggest how to fix this or any other alternatives for this use case.
-filter 'nominaltime>2019-11-01T01:00Z'

Robot Framework Getting Keyword failure reason

Trying to implement a listener interface for robot framework in order to collect information about keyword executions like time taken for execution, Pass/Fail status, failure message in case if status is fail. Sample code is given below
import os.path
import tempfile
class PythonListener:
ROBOT_LISTENER_API_VERSION = 2
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
def __init__(self, filename='listen.txt'):
outpath = os.path.join(tempfile.gettempdir(), filename)
self.outfile = open(outpath, 'w')
def end_keyword(self, name, attrs):
self.outfile.write(name + "\n")
self.outfile.write(str(attrs) + "\n")
def close(self):
self.outfile.close()
All the information apart from keyword failure message is available in the attributes which is passed to end_test method from robot framework.
Documentation can be found here. https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst#id36
The failure message is available in the attributes for end_test() method. But this will not have information if a keyword is run using RunKeywordAndIgnoreError.
I could see that there is a special variable ${KEYWORD MESSAGE} in robot framework, which contains the possible error message of the current keyword Is it possible to access this variable in the listener class.?
https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/Variables.rst#automatic-variables
Are there any other ways to collect the failure message information at the end of every keyword?
That's an interesting approach, indeed, end_test will ensure an attributes.message field containing the failure. (so it goes for end_suite if it fails during the suite setup/teardown)
With end_keyword you don't have such message, but at least you can filter for the FAIL status and detect which one failed. Then the message returned by Run Keyword And Ignore Error has to be logged explicitly by you so you can capture such triggering logs with the log_message hook. Otherwise nobody is aware of the message of the exception handled by the wrapper keyword which returns a tuple of (status, message).
There's also the message hook but couldn't manage to get it called from a normal breaking robot:
Called when the framework itself writes a syslog message.
message is a dictionary with the same contents as with log_message method.
Side note: To not expose these hooks as keywords, you can precede the method names with _. Examples:
def _end_test(self, name, attributes): ...
def _log_message(self, message): ...

How to write python function to test the matched strings (to use for Robot framework keyword)?

I am writing a custom library for robot framework in python. I don't want to use builtin library for some reasons.
My python code :
import os
import re
output = "IP address is 1.1.1.1"
def find_ip():
cmd = 'ipconfig'
output = os.popen(cmd).read()
match1 = re.findall('.* (1.1.1.1).*',output)
mat1 = ['1.1.1.1']
if match1 == mat1:
print "PASS"
In the above program I have written python function to :
Execute a windows command "ipconfig"
Written regular expression to match 1.1.1.1
create a list variable, mat1 = ['1.1.1.1']
Now I want to put condition like, if "match1" and "mat1" are equal my TEST should PASS. else it should fail in Robot framework.
Any one please give idea on how to write python function for this purpose?
Please note I dont want to use "Should Match Regexp" keyword in Robot Framework. Because I know it will do the same whatever I am asking.
To make a keyword pass, you don't need to do anything except return normally to the caller. To fail, you need to raise an exception:
def find_ip():
...
if match1 != mat1:
raise Exception('expected the matches to be similar; they are not")
This is documented in the robot user guide in the section Returning Keyword Status:
Reporting keyword status is done simply using exceptions. If an
executed method raises an exception, the keyword status is FAIL, and
if it returns normally, the status is PASS.
The error message shown in logs, reports and the console is created
from the exception type and its message. With generic exceptions (for
example, AssertionError, Exception, and RuntimeError), only the
exception message is used, and with others, the message is created in
the format ExceptionType: Actual message.

Resources