Azure / azure-service-operator

Azure Service Operator allows you to create Azure resources using kubectl
https://azure.github.io/azure-service-operator/
MIT License
738 stars 194 forks source link

Fix spec initializing copying wrong property #4108

Closed theunrepentantgeek closed 3 months ago

theunrepentantgeek commented 3 months ago

What this PR does / why we need it:

In #3805, @nojnhuh noticed that asoctl was initializing the type field on an imported AgentPool with the wrong value.

Investigation leads to the observation that properties with the same name don't necessarily have the same providence - not every Type field can be copied into another Type field.

Special notes for your reviewer:

There are two fixes.

The first is to check the origin of each property, skipping the assign-identically-named-properties step if the properties came from different places

The second fix is to use the path-of-origin of the remaining properties to match things up. This is complicated by the possibility that the property may be configurable - so we would have both Type and TypeFromConfig as candidates. We disambiguate these by doing a fast and loose compatibility check on the types, which seems good enough.

How does this PR make you feel: gif

If applicable:

matthchr commented 3 months ago

Seems some unit test failures @theunrepentantgeek