Skip to content

Fix SSA managed-fields type converter for scanner group#61

Open
ArnobKumarSaha wants to merge 2 commits into
masterfrom
arnob/ssa-conv
Open

Fix SSA managed-fields type converter for scanner group#61
ArnobKumarSaha wants to merge 2 commits into
masterfrom
arnob/ssa-conv

Conversation

@ArnobKumarSaha

Copy link
Copy Markdown
Member

Problem

Every write to a scanner.appscode.com/v1alpha1 object logs:

[SHOULD NOT HAPPEN] failed to update managedFields ... no corresponding type for
scanner.appscode.com/v1alpha1, Kind=ImageScanRequest

and metadata.managedFields is never populated.

Root cause

start.go built one ignore list for the OpenAPI v2 config — which excludes the scanner group prefix /apis/scanner.appscode.com/v1alpha1 — and then reused it for OpenAPIV3Config.

Server-side apply (GA) builds its managed-fields type converter from the v3 config: GenericAPIServer.getOpenAPIModelsgetResourceNamesForGroup skips any resource whose path is under an IgnorePrefixes entry. Since api.SchemeGroupVersion.String() is scanner.appscode.com/v1alpha1, that prefix matches every scanner resource, so all of them are dropped from the converter's GVK→schema map → no corresponding type on every write.

Fix

Give the v3 config its own IgnorePrefixes = []string{"/swaggerapi"} instead of reusing the v2 ignore list. The scanner resources now reach the converter; the v2 published-spec behavior is unchanged.

Verification

go build ./... green. On a cluster running this build, an Update/Apply populates metadata.managedFields and the [SHOULD NOT HAPPEN] line is gone.

The OpenAPI v2 `ignore` list, which excludes the scanner group prefix
(/apis/scanner.appscode.com/v1alpha1), was reused for OpenAPIV3Config.
Since server-side apply builds its managed-fields type converter from the
v3 config (getOpenAPIModels -> getResourceNamesForGroup skips any resource
under an IgnorePrefixes entry), every scanner resource was dropped from the
converter, causing "no corresponding type for scanner.appscode.com/v1alpha1"
on every write and leaving managedFields unpopulated.

Give the v3 config its own IgnorePrefixes of just /swaggerapi so the scanner
resources reach the converter. The v2 published-spec behavior is unchanged.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
`type Time metav1.Time` strips metav1.Time's OpenAPISchema* methods, so
openapi-gen emitted an object schema (a map with a "Time" property) while
Time marshals as a scalar RFC3339 string. The SSA managed-fields type
converter then rejected every ImageScanReport with "expected map, got
<timestamp>" on .status.report.metadata.imageConfig.created and history[].

Re-add OpenAPISchemaType/OpenAPISchemaFormat mirroring metav1.Time so the
generated schema is a scalar date-time string, and regenerate.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant