Skip to content

Remove SupportsShouldProcess from Start-PSBootstrap in build.psm1 (closes #15490)#15491

Merged
rjmholt merged 4 commits intoPowerShell:masterfrom
schuelermine:fix-build-module-bootstrap-shouldprocess
Jun 11, 2021
Merged

Remove SupportsShouldProcess from Start-PSBootstrap in build.psm1 (closes #15490)#15491
rjmholt merged 4 commits intoPowerShell:masterfrom
schuelermine:fix-build-module-bootstrap-shouldprocess

Conversation

@schuelermine
Copy link
Copy Markdown
Contributor

@schuelermine schuelermine commented May 29, 2021

PR Summary

Removes SupportsShouldProcess from Start-PSBootstrap in build.psm1.
This addresses #15490.

PR Context

build.psm1 contains the function Start-PSBoostrap. The CmdletBinding in it stated that it supports ShouldProcess, but this isn’t the case.

PR Checklist

@schuelermine
Copy link
Copy Markdown
Contributor Author

I don’t think implementing ShouldProcess on this function is doable, as it downloads and executes an external script via Install-Dotnet.

@ghost ghost added the Review - Needed The PR is being reviewed label Jun 7, 2021
@ghost
Copy link
Copy Markdown

ghost commented Jun 7, 2021

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@vexx32
Copy link
Copy Markdown
Collaborator

vexx32 commented Jun 7, 2021

@schuelermine This function could simply gate the running of that script behind a ShouldProcess check itself, no?

@schuelermine
Copy link
Copy Markdown
Contributor Author

True, should I re-add SupportShouldProcess and only launch the script then?

@vexx32
Copy link
Copy Markdown
Collaborator

vexx32 commented Jun 8, 2021

Might be worth doing, yeah. Not sure if this function handles other things that would warrant a similar check for those parts as well?

@schuelermine
Copy link
Copy Markdown
Contributor Author

ok, I will write that when I'm back home (3hrs from now)

@rjmholt
Copy link
Copy Markdown
Collaborator

rjmholt commented Jun 8, 2021

/azp rerun

@ghost ghost removed the Review - Needed The PR is being reviewed label Jun 8, 2021
@azure-pipelines
Copy link
Copy Markdown

Command 'rerun' is not supported by Azure Pipelines.

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@rjmholt
Copy link
Copy Markdown
Collaborator

rjmholt commented Jun 8, 2021

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@schuelermine
Copy link
Copy Markdown
Contributor Author

@vexx32 While I am in support of this PR being merged, I have also opened another one w/ an attempt at implementing ShouldProcess. An alternate option, if you will.

@rjmholt
Copy link
Copy Markdown
Collaborator

rjmholt commented Jun 9, 2021

@schuelermine it looks like all the CIs are failing for this PR and not in the master branch, and I can't merge it until CI passes. I took a brief look and it's not entirely clear what's going on, but it does look possibly related to your change (Start-PSBootstrap isn't properly bootstrapping .NET 6)

@rjmholt
Copy link
Copy Markdown
Collaborator

rjmholt commented Jun 9, 2021

Alternately solved by #15548

Hopefully this will adress the issues in PR PowerShell#15491

I’m not sure why the build would fail — I hadn’t changed anything besides removing the CmdletBindingAttribute parameters…
I’ve checked if build.psm1 or ci.psm1 (which is where the errors semm to be happening) ever mention “WhatIf” or “ShouldProcess” — they don’t.

ci.psm1’s Invoke-CIBuild seems to be failing because Get-PSOptions (imported from build.psm1) returns $null.
However, this is because of a global variable set at the top of the script, which was there before my changes occurred.

I’m very confused.
@schuelermine
Copy link
Copy Markdown
Contributor Author

I don’t think the failing is caused by me—here’s a copy of my reasoning from the commit message:

I’m not sure why the build would fail — I hadn’t changed anything besides removing the CmdletBindingAttribute parameters…
I’ve checked if build.psm1 or ci.psm1 (which is where the errors semm to be happening) ever mention “WhatIf” or “ShouldProcess” — they don’t.

ci.psm1’s Invoke-CIBuild seems to be failing because Get-PSOptions (imported from build.psm1) returns $null.
However, this is because of a global variable set at the top of the script, which was there before my changes occurred.

Copy link
Copy Markdown
Collaborator

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rkeithhill
Copy link
Copy Markdown
Collaborator

OK this bothers me - why does the Bootstrap step show passed when it clearly failed. I just spent weeks fixing a similar issue with the Jenkins durable-task-plugin. 🤦‍♂️

image

Looks like someone will need to update the Action to tweak that -Confirm:$false parameter. Then again, the latest update to this PR put back the ConfirmImpact="High". Maybe there's an interaction between SupportsShouldProcess and ConfirmImpact?

@rkeithhill
Copy link
Copy Markdown
Collaborator

rkeithhill commented Jun 9, 2021

Well this would 'splain it:

image

This would be a better impl:

image

Not only does the current impl not fail on missing parameters, it will not fail on a missing command or invalid parameter values:

image

This is the exact same set of issues I went through with the pwsh step in the Jenkins plugin. Deja vu!

@schuelermine
Copy link
Copy Markdown
Contributor Author

I can't look through the code right now, I'm not at my computer right now - but it seems like some function might've called Start-PSBootstrap w/ -WhatIf:$WhatIfPreference or something, and then the rest of the code mishandled its failed execution.

@schuelermine
Copy link
Copy Markdown
Contributor Author

OK, yeah, that's definitely the case - Start-CIInstall has this line:

Start-PSBootstrap -Confirm:$false

(can't remove it now, will do soonish)

@schuelermine
Copy link
Copy Markdown
Contributor Author

Oh, I just read that you found that, too. Sorry for making that duplicate observation.

@schuelermine
Copy link
Copy Markdown
Contributor Author

I think removing ConfirmImpact in build.psm1 and adding a $ConfirmPreference declaration to ci.psm1 is a good solution - gonna do that when I'm home.

@schuelermine
Copy link
Copy Markdown
Contributor Author

Actually, $ConfirmPreference probably isn't even necessary, since Start-PSBootstrap never calls ShouldProcess or ShouldContinue.
It might've even been because of the incorrect SupportsShouldProcess declaration that the Confirm:$false parameter was added

@schuelermine
Copy link
Copy Markdown
Contributor Author

Weird
Screenshot from 2021-06-10 14-14-14

@rjmholt rjmholt marked this pull request as draft June 10, 2021 16:40
@rkeithhill
Copy link
Copy Markdown
Collaborator

Intermittent PSGallery glitch?

@iSazonov
Copy link
Copy Markdown
Collaborator

Intermittent PSGallery glitch?

Yes, I restarted CI 5 minutes later and it passed.

@schuelermine schuelermine marked this pull request as ready for review June 10, 2021 18:29
@rjmholt rjmholt merged commit 00ffe12 into PowerShell:master Jun 11, 2021
@rjmholt rjmholt added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Jun 16, 2021
@ghost
Copy link
Copy Markdown

ghost commented Jun 17, 2021

🎉v7.2.0-preview.7 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants