Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to poll for task availability after install #189

Open
charleszipp opened this issue Mar 2, 2021 · 4 comments
Open

Add ability to poll for task availability after install #189

charleszipp opened this issue Mar 2, 2021 · 4 comments

Comments

@charleszipp
Copy link
Member

For my extension, i run several tests after install a pre-release version to testing org. I have noticed that there is a delay after installing an extension before it can actually be used. I have found that polling the tfx build tasks list for my task id allows my pipeline to know when the task is ready for use. Having either the install task or a new task perform this check may be helpful to others that are experiencing the same. Here is the bash I use to poll for task availability from my pipeline. I think the same could be done from node much easier

#/bin/bash
set -e

task_id=
token=
service_url=
attempts=0
max=25

while getopts t:s:c: flag; do
    case "${flag}" in
        t) token="${OPTARG}";;
        s) service_url="${OPTARG}";;
        c) task_id="${OPTARG}";;
    esac
done

until $(npx tfx build tasks list --service-url $service_url -t $token --no-color --json |  jq -r --arg t "$task_id" '.[] | select(.id == $t) | .id' | grep -q "$task_id");
do
    if [ $attempts -gt $max ]
    then
        echo "wait limit reached! exiting..."
        return 1;
    else
        echo "waiting for task to become available..."        
        sleep $(( attempts++ ));
    fi
done

echo "task is available!"
@charleszipp
Copy link
Member Author

Here is the error I get if i try to use the tasks too quickly after install. If I rerun the jobs a few minutes later, they work fine

##[error]A task is missing. The pipeline references a task called '<my-task-id>'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com.

@jessehouwing
Copy link
Collaborator

Yeah, this is frustrating. Richard Fennel has a release gate that waits for the availability.

In order for this to be really useful, you probably also want the exact same version to be available.

I currently don't have the bandwidth to add this though. I'll keep it in mind for future enhancements.

@charleszipp
Copy link
Member Author

Thanks @jessehouwing for the additional solution and the feedback about the version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants