microsoft / omi

Open Management Infrastructure
Other
360 stars 114 forks source link

Size restriction of 'ConfigurationData' with an Invoke call to omicli #753

Closed svenschrader closed 7 months ago

svenschrader commented 7 months ago

I'm opening this issue here because it appears to affect the omicli binary.

When trying to pass a Desired State Configuration to omi (via Powershell DSC) using "iv" for Invoke, the configuration data is passed to omcli as follows:

/opt/omi/bin/omicli iv root/Microsoft/DesiredStateConfiguration { MSFT_DSCLocalConfigurationManager } SendMetaConfigurationApply { ConfigurationData '[ <very long array> ]}

Now this "ConfigurationData" is basically the provided MOF file, given to omicli as a set of command line arguments. It seems that this file may not exceed the size of around 20k. I don't think this is a restriction by the shell (max arguments, argument or stack size, or some other 'ulimit'). There isn't an error message or other log output I could provide.

If this issue is cased by the Powershell DSC for linux, feel free to close this issue.

JumpingYang001 commented 7 months ago

it is not related to omi, omi just query provider and post its outputs, and your message seems be this code in dsc: https://github.com/microsoft/PowerShell-DSC-for-Linux/blob/b98ac61824512fa2c8d9e99ce481573a6d427637/LCM/scripts/python3/SetDscLocalConfigurationManager.py#L105

svenschrader commented 7 months ago

Thanks for your reply! You are correct that the input is preprocessed and collected in the above mentioned Python script.

However, the problem indeed occurs during the call to omicli, which is done below in line 153. I can even call /opt/omi/bin/omicli directly with the data collected by the python script:

/opt/omi/bin/omicli iv root/Microsoft/DesiredStateConfiguration { MSFT_DSCLocalConfigurationManager } SendMetaConfigurationApply { ConfigurationData '[ <very long array> ]}

So with the script SetDscLocalConfigurationManager.py out of the way, I observe that this call does indeed fail when the given arguments exceed a certain size. Please consider looking into the OMI libraries and reopening this issue.

Thanks again and kind regards,

JumpingYang001 commented 7 months ago

@svenschrader can you share me how to repro your issue? run this command directly /opt/omi/bin/omicli iv root/Microsoft/DesiredStateConfiguration { MSFT_DSCLocalConfigurationManager } SendMetaConfigurationApply { ConfigurationData '[ <very long array> ]}?

can you also share me a command not exceed a certain size? and a command with exceed a certain size? what is the content or example of '[ <very long array> ]? is it part of the command or a command result?

In fact, I don't know what is your command and command execution result.

svenschrader commented 7 months ago

I can try to build an example, but I am sure I found the restriction in common.h There MAX_ENVELOPE_SIZE is set to 250*1024, any buffers exceeding that will lead to a silent error. Is there a way to have that larger (at least for local configurations), or even configurable?

JumpingYang001 commented 7 months ago

@svenschrader unfortunately, MAX_ENVELOPE_SIZE was added before first commit of this repo, it was by design, no configure way. https://github.com/microsoft/omi/blob/ffca75c734957596c3739601f0191f8bc0f1db81/Unix/common/common.h#L43

svenschrader commented 7 months ago

The question here is if the value for the maximum envelope size and this value alone is responsible for the size restriction, which I am not yet sure of.

If however this value is the one restricting configurations from being larger than 20k, and this limit is easily reached, then setting this value fixed because it was there "before first commit" is hardly an argument, let alone a design decision.

Splitting the configurations into smaller files is not an option, because all configurations need to be under the DSC "ApplyAndAutoCorrect"

JumpingYang001 commented 6 months ago

@svenschrader suggest you to file ticket or ICM to DSC team inner Microsoft, they will contact OMI team if require.

svenschrader commented 5 months ago

Locally, I could enable longer configurations by omitting the "return PRT_RETURN_FALSE;" in line 2112 in protocol.c So the question remains, what are possible drawbacks of this procedure? Where can I get a documentation of the value MAX_ENVELOPE_SIZE and its usage?

For Powershell DSC Linux there are already two issues open: https://github.com/microsoft/PowerShell-DSC-for-Linux/issues/307 https://github.com/microsoft/PowerShell-DSC-for-Linux/issues/174

However, the repo is already archived and does not accept tickets nor pull requests.

JumpingYang001 commented 5 months ago

@svenschrader WSMan protocol spec: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wsman/8a6b1967-ff8e-4756-9a3b-890b4b439847 https://www.dmtf.org/sites/default/files/standards/documents/DSP0226_1.0.0.pdf

If you are Azure customer, you should be able to create ticket based on your dsc service/vm.