<p>I tried to add a logic that will send slack notification when the pipeline terminated due to some error. I tried to implement this with <code>ExitHandler</code>. But, seems the <code>ExitHandler</code> can’t dependent on any op. Do you have any good idea?</p>

<p>I found a solution to which uses <code>ExitHandler</code>. I post my code below, hope it can help someone else.</p>
<pre class="lang-py prettyprint-override"><code>
def slack_notification(slack_channel: str, status: str, name: str, is_exit_handler: bool = False):
    &quot;&quot;&quot;
    performs slack notifications
    &quot;&quot;&quot;    
    send_slack_op = dsl.ContainerOp(
        name=name,
        image='wenmin.wu/slack-cli:latest',
        is_exit_handler=is_exit_handler,
        command=['sh', '-c'],
        arguments=[&quot;/send-message.sh -d {} '{}'&quot;.format(slack_channel, status)]
    )
    send_slack_op.add_env_variable(V1EnvVar(name = 'SLACK_CLI_TOKEN', value_from=V1EnvVarSource(config_map_key_ref=V1ConfigMapKeySelector(name='workspace-config', key='SLACK_CLI_TOKEN'))))
    return send_slack_op

@dsl.pipeline(
    name='forecasting-supply',
    description='forecasting supply ...'
)
def ml_pipeline(
    param1,
    param2,
    param3,
):
    exit_task = slack_notification(
        slack_channel = slack_channel,
        name = &quot;supply-forecasting&quot;,
        status = &quot;Kubeflow pipeline: {{workflow.name}} has {{workflow.status}}!&quot;,
        is_exit_handler = True
    )

    with dsl.ExitHandler(exit_task):
        # put other tasks here

</code></pre>
