Skip to content

Adds TryCatch to StopTrigger, continuing if fails #404

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

henriquebrisola
Copy link

Hello,
I am having an issue sometimes that if one of the triggers fails to be stopped, the whole deploy operation fails.
Can we please add this simple try/catch to solve this issue?
We might even add a number of tries in the future.

image

@NowinskiK
Copy link
Member

In the first instance, I would like to understand why you are experiencing this error ("concurrent operations")?
This should have never happened as #adftools does disable triggers one by one synchronously.

@henriquebrisola
Copy link
Author

Unfortunately I don't know why this happens, no one should be changing anything directly in production, more than one deploy on master could happen, but I guess it is rare. Maybe some api is changing the trigger status. I not aware of all other projects happening wihtin the company that might influence on this, so my choice is to solve by code.

@NowinskiK
Copy link
Member

Did you try to set $ErrorActionPreference = 'Continue' before running the Publish?

@henriquebrisola
Copy link
Author

No, but continue is the default value and there is no other value set for it.
Woundn't that also make everything else continue even when somethings should report the error?
I created workaround, I added the $opt.TriggerStopMethod = 'DeployableOnly' (which starting back is not working due to #386) and then created a method to read all trigger files with runtimeState Started, so I was able to make sure they start back again after the deploy is done.

$triggersEnabledInRepo = ( # Get all triggers enabled in the Repo
    Get-ChildItem -Path (
        Join-Path -Path $fullRootPath -ChildPath '\trigger'
    ) -Recurse |
    Select-String '"runtimeState": "Started"' |
    Get-Item
).Basename


$triggersEnabledInRepo | ForEach-Object { # Start all triggers enabled in the Repo
    try{
        Write-Host "Starting" $_
        Start-AzDataFactoryV2Trigger `
        -ResourceGroupName "$ResourceGroupName" `
        -DataFactoryName "$DataFactoryName" `
        -TriggerName $_ `
        -Force | out-null
    }
    catch{
        Write-Host "Faile to start" $_
    }
}

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

Successfully merging this pull request may close these issues.

2 participants