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

Issues with Start-SleepProgress #402

Closed
master135 opened this issue Nov 4, 2021 · 7 comments
Closed

Issues with Start-SleepProgress #402

master135 opened this issue Nov 4, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@master135
Copy link

Hi,
I'm running Posh-ACME module on Azure's Automation Account Hybrid Worker (Oracle Linux 7.9). It works everything good when I run my New-PACertificate from SSH session. However on Automation accout it always hangs on Start-SleepProgress private function. Guess this behaviour is because Automation Account is not friendly to Write-Progress cmdlet.
Since primary usage of this module is automation of getting certificates I would expect there is no need to display progress bar for end user, rather logging information that script execution will be paused for some time.
I would override Start-SleepProgress with my own function, however since its in private, nothing works for me at the moment..

@rmbolger
Copy link
Owner

rmbolger commented Nov 4, 2021

Hi @master135. Thanks for reaching out. Are you sure the process hangs indefinitely? Whether or not you're running New-PACertificate interactively, there's still a default sleep time (2 minutes) that happens while the module waits for published DNS changes to propagate. But that sleep time can vary if you've overridden the default using -DnsSleep in New-PAOrder or New-PACertificate.

I haven't heard about issues with Write-Progress in Azure Automation accounts before. And I'm pretty sure there are existing users using Posh-ACME with Automation runbooks successfully.

@rmbolger rmbolger self-assigned this Nov 4, 2021
@rmbolger rmbolger added the bug Something isn't working label Nov 4, 2021
@rmbolger
Copy link
Owner

rmbolger commented Nov 5, 2021

Nevermind. Apparently, it's a documented limitation I was unaware of. https://docs.microsoft.com/en-us/azure/automation/automation-runbook-output-and-messages#handle-progress-records

The Write-Progress cmdlet is not valid in a runbook, since this cmdlet is intended for use with an interactive user.

I'm curious whether the the $ProgressPreference would work to workaround the problem. Could you possible try setting $ProgressPreference = 'SilentlyContinue' prior to running New-PACertificate?

If that doesn't work, the easiest fix would probably be adding support for an environment variable to disable calling Write-Progress. Something like POSHACME_DISABLE_WRITEPROGRESS.

@master135
Copy link
Author

master135 commented Nov 5, 2021

Hi @rmbolger
Thanks for getting back so quick.
I'm pretty sure the issue here is with Write-Progress. I've set whatever timeouts with DNSSleep and ValidationTimeOut and this does not help. Output always stucks on.
Waiting for DNS to propagate Sleeping... [ooooooooooooooooooooooooooo ] 00:01:11 remaining. Waiting for DNS to propagate Sleeping... [ooooooooooooooooooooooooooo ] 00:01:11 remaining. Waiting for DNS to propagate Sleeping... [oooooooooooooooooooo

Unfortunately $ProgressPreference is not supported on Azure Automation Account
https://docs.microsoft.com/en-us/azure/automation/automation-runbook-output-and-messages#work-with-preference-variables

If that doesn't work, the easiest fix would probably be adding support for an environment variable to disable calling Write-Progress. Something like POSHACME_DISABLE_WRITEPROGRESS.

Yes, this will work, or replace Write-Progress with custom messages, I don't think it brings much value, since people will not run scripts interactively.

@rmbolger
Copy link
Owner

rmbolger commented Nov 5, 2021

In retrospect, you're right. This is a tool for automation and progress bars are intended for interactive use. I'm going to push a change to the main branch in a sec that disables Write-Progress by default in place of a once per minute verbose message describing the sleep time remaining. If users want the progress bar back, it will respect an environment variable called POSHACME_SHOW_PROGRESS that can be set to anything not null or an empty string.

rmbolger added a commit that referenced this issue Nov 5, 2021
…s a POSHACME_SHOW_PROGRESS environment variable is defined. (#402)
@master135
Copy link
Author

master135 commented Nov 5, 2021

In retrospect, you're right. This is a tool for automation and progress bars are intended for interactive use. I'm going to push a change to the main branch in a sec that disables Write-Progress by default in place of a once per minute verbose message describing the sleep time remaining. If users want the progress bar back, it will respect an environment variable called POSHACME_SHOW_PROGRESS that can be set to anything not null or an empty string.

Wow, thanks for such quick actions!
Now i feel sorry that i spent time making workarouns)

@rmbolger
Copy link
Owner

rmbolger commented Nov 5, 2021

You're very welcome. I appreciate the poke to re-evaluate past decisions. It may be a week or two until a I push a new release with this change included because I'm actively working on a new feature I'm hoping to include in the next release.

@rmbolger
Copy link
Owner

This is now live in 4.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants