AIOps

 View Only
  • 1.  TWS Conditional Dependency Question

    Posted Wed April 10, 2024 11:07 AM

    hello,

         we have a job that checks if the database backup is done... If the first attempt fails then we want to run the 2nd attempt an hour later... In the 2nd attempt job I have added a conditional dependency on the dependency to the first attempt job... Successor Job runs if the predecessor job completes with any of these statuses... i chose ABEND

    This works as expected.

    The issue is that we have the next job which should only run IF one of the dB check job is successful. If they both fail - the next job should not run BUT if one of the two DB check jobs is successul - then the next job should run. I thought I had this sorted by adding noth db check jobs as dependencies to the next job and adding conditional dependency on the db check jobs having a sucessor job... it looks like it suppressed the next job but it still show SUCC which is bad and will launch the predecessor job. we dont want to run any more jobs IF both DB check jobs fail BUT we want to run the next job IF one of the two DB check jobs complete SUCC

    How can I do this. Can I implement some type of OR condition... run the next job IF DB-CHECK1 = SUCC OR DB-CHECK2 = SUCC

    thanks in advance...



    ------------------------------
    armin pohl
    ------------------------------


  • 2.  RE: TWS Conditional Dependency Question

    Posted Thu April 11, 2024 09:15 AM
    Based on your description, you want the next job to run if at least one of the two database check jobs (DB-CHECK1 and DB-CHECK2) is successful. However, you want the next job to be suppressed if both DB check jobs fail. This requires a conditional dependency with an "OR" condition.
    Here's how you could implement this logic:
    - Use a wrapper script: Create a script that will control whether the next job should run. This script should check the exit status or result of DB-CHECK1 and DB-CHECK2. If either job is successful, the script will return success and allow the next job to proceed. If both jobs fail, the script will return failure, which will prevent the next job from running.
    - Set the next job to depend on the script: Instead of directly linking the next job to DB-CHECK1 and DB-CHECK2, make it depend on the wrapper script you just created. This way, the script will act as a decision-maker to decide if the next job should run.
    - Write the wrapper script: The script should check the status of DB-CHECK1 and DB-CHECK2 (possibly via exit codes or log files). If one of them is successful (has a successful exit code or the expected output in the logs), the script should exit with a success code (e.g., exit 0). If both fail, it should exit with a failure code (e.g., exit 1).
    Here's an example of how your wrapper script should look:
    #!/bin/bash
    # Check the status of DB-CHECK1
    check1_status=$?
    # Check the status of DB-CHECK2
    check2_status=$?
    # If either check is successful (exit code 0), return success (exit code 0)
    if [ $check1_status -eq 0 ] || [ $check2_status -eq 0 ]; then
        exit 0
    else
        # If both checks failed, return failure (exit code 1)
        exit 1
    fi
    - Schedule the script as the dependency: Instead of scheduling the next job to depend directly on the DB-CHECK jobs, make it depend on the wrapper script. The script's success or failure will dictate whether the next job runs.
    Using this approach should help you achieve the desired control over your jobs and their dependencies.


    ------------------------------
    Jude Ighomena
    Senior Manager, Core Network Operations
    Broadbased Communications Limited
    Lagos, Nigeria
    +2348163474613
    ------------------------------



  • 3.  RE: TWS Conditional Dependency Question

    Posted Thu April 11, 2024 12:05 PM

    Hello there are many ways to do this.  I personally like using the other output conditions with a contains statement to pull data out of the stdlist and combine that with a join dependency and you have exactly what yo uare looking for.  because you already have the jobs create you can skip the first part and just use the join dep for the 2 jobs.



    ------------------------------
    Leon Odenbrett
    ------------------------------