Azure / nxtools

Azure Automanage Machine Configuration Linux DSC resources
Other
13 stars 11 forks source link

nxPackage - Crashes on RHEL ; recent commit to add support for Force parameter seems to be culprit #41

Closed eehret closed 8 months ago

eehret commented 1 year ago

Details of the scenario you tried and the problem that is occurring

I have a RHEL machine on which I'm trying to use nxPackage to install a package. This no longer works in 1.2.0. This pull request several weeks ago seems to be the reason: https://github.com/Azure/nxtools/pull/20 It did not include the changes that would have been required to support the Force parameter in https://github.com/Azure/nxtools/blob/main/source/Public/Packages/yum/Install-nxYumPackage.ps1

Verbose logs showing the problem

A parameter cannot be found that matches parameter name 'Force'.
The PowerShell DSC resource with className:nxPackage moduleName:nxtools moduleVersion:1.2.0 threw an exception: System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'Force'.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
   at System.Management.Automation.CommandProcessorBase.Complete(), while running the Get-DscResource functionality
The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually.

Suggested solution to the issue

I believe https://github.com/Azure/nxtools/blob/main/source/Public/Packages/yum/Install-nxYumPackage.ps1 needs to be modified to handle the Force parameter.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

    nxPackage recode_installed
    {
      Name = "recode"
      Ensure = "Present"
    }

The operating system the target node is running

RHEL 7.9

Version and build of PowerShell the target node is running

7.3.6

Version of the DSC module that was used

1.2.0

MutemwaRMasheke commented 1 year ago

We are looking into this issue alongside the other open issues with nxPackage. Thank you for raising this with us @eehret !

eehret commented 11 months ago

The above also appears to happen on RHEL 8. Here's the error dump (which, incidentally gets output in the guest configuration assignment overview page in Azure portal) None of the rest of the configuration compliance results are visible because it's crashing badly.


 InvokeDscResource() failed. errorMessage:PowerShell DSC resource nxScript  failed to execute Test functionality with error message:The TestScript script block returned an error: Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Enforcement'  Key being added: 'Enforcement'".
PowerShell DSC resource nxScript  failed to execute Test functionality with error message:The TestScript script block returned an error: Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Enforcement'  Key being added: 'Enforcement'".
A parameter cannot be found that matches parameter name 'Force'.
The PowerShell DSC resource with className:nxPackage moduleName:nxtools moduleVersion:1.3.0 threw an exception: System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'Force'.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
   at System.Management.Automation.CommandProcessorBase.Complete(), while running the Get-DscResource functionality
The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually.
MutemwaRMasheke commented 11 months ago

Thanks for the additional context. We'll get back to you on this once we have an update.

MutemwaRMasheke commented 8 months ago

Hello @eerhet! We just closed on this so you should be good to go!

eehret commented 8 months ago

@MutemwaRMasheke

Hi. Thanks, that sounds promising. Unfortunately we are still waiting for Microsoft to publish the updated module to PowerShell Gallery. When can we expect that? I will not be able to test and confirm how well this fix resolves our problem until that is done.

MutemwaRMasheke commented 8 months ago

Just published a new nxtools release with fixes for this and other Github issues. https://www.powershellgallery.com/packages/nxtools/1.4.0

Thank you for your feedback!