Skip to content

Commit 057eff1

Browse files
fix(conformance): decompress ResourceProperties in discovery responses
Fix compressed ResourceProperties being dropped when converting TrackedProgress to ProgressResult in create/delete paths.
1 parent 9360def commit 057eff1

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

pkg/plugin-conformance-tests/harness.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,18 +1233,23 @@ func (h *TestHarness) CreateAllUnmanagedResources(evaluatedJSON string) ([]Creat
12331233
// Strip Formae metadata tags from the resource properties
12341234
h.stripFormaeTags(res)
12351235

1236-
// Strip nested empty collections ({}/[]) that PKL renders for unset
1237-
// nullable Listing/Mapping fields. Without this, K8S rejects resources
1238-
// with empty probe objects (e.g. livenessProbe: {}).
1239-
h.stripNestedEmptyCollections(res)
1240-
1241-
// Resolve any resolvable references using previously created resources
1236+
// Resolve any resolvable references using previously created resources.
1237+
// This must happen BEFORE stripNestedEmptyCollections to match the
1238+
// agent's order of operations (resolver.ConvertToPluginFormat then
1239+
// patch.StripNestedEmptyCollections). The resolvable markers ($res,
1240+
// $label, etc.) must be intact when the resolver runs; stripping first
1241+
// can corrupt the resolvable objects through the json round-trip.
12421242
resolvedProps, err := h.resolveResolvablesInProperties(res.Properties, createdResources)
12431243
if err != nil {
12441244
return createdResources, fmt.Errorf("failed to resolve resolvables for %s: %w", res.Label, err)
12451245
}
12461246
res.Properties = resolvedProps
12471247

1248+
// Strip nested empty collections ({}/[]) that PKL renders for unset
1249+
// nullable Listing/Mapping fields. Without this, K8S rejects resources
1250+
// with empty probe objects (e.g. livenessProbe: {}).
1251+
h.stripNestedEmptyCollections(res)
1252+
12481253
// Create the resource with retry on recoverable errors
12491254
label := fmt.Sprintf("create %s", res.Label)
12501255
finalProgress, err := h.retryOnRecoverable(label, func() (*pluginOperationResult, error) {

pkg/plugin-conformance-tests/plugin_coordinator.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ func (c *TestPluginCoordinator) createResource(req CreateResourceRequest) Create
389389
"statusMessage", trackedProgress.StatusMessage,
390390
"nativeID", trackedProgress.NativeID)
391391

392+
// Decompress ResourceProperties if compressed for Ergo transport.
393+
// TrackedProgress compresses and nils ResourceProperties, but callers
394+
// expect it on the embedded ProgressResult.
395+
if len(trackedProgress.ResourceProperties) == 0 && len(trackedProgress.CompressedResourceProperties) > 0 {
396+
decompressed, err := plugin.DecompressJSON(trackedProgress.CompressedResourceProperties)
397+
if err == nil {
398+
trackedProgress.ResourceProperties = decompressed
399+
}
400+
}
401+
392402
// Return immediately with the operator PID and initial progress
393403
// The caller is responsible for polling via GetLatestProgressRequest if needed
394404
return CreateResourceResult{
@@ -444,6 +454,14 @@ func (c *TestPluginCoordinator) deleteResource(req DeleteResourceRequest) Delete
444454
"nativeID", req.NativeID,
445455
"status", trackedProgress.OperationStatus)
446456

457+
// Decompress ResourceProperties if compressed for Ergo transport
458+
if len(trackedProgress.ResourceProperties) == 0 && len(trackedProgress.CompressedResourceProperties) > 0 {
459+
decompressed, err := plugin.DecompressJSON(trackedProgress.CompressedResourceProperties)
460+
if err == nil {
461+
trackedProgress.ResourceProperties = decompressed
462+
}
463+
}
464+
447465
// Return immediately with the operator PID and initial progress
448466
// The caller is responsible for polling via GetLatestProgressRequest if needed
449467
return DeleteResourceResult{

0 commit comments

Comments
 (0)