Skip to content

Resolver Cache Annotation Propagation. #9272

@twoGiants

Description

@twoGiants

Resolver Cache Annotation Propagation

IMPORTANT: This refactoring blocks e2e tests in section 2 below.

The resolver caching annotation mechanism needs full implementation to enable proper e2e testing and user-facing functionality.

Use metav1.Object interface for resource-agnostic annotation propagation. What I found as the best place to add the change is pkg/remote/resolution/resolver.go in the ResolvedRequest().

It will probably look like this:

func ResolvedRequest(resolved resolutioncommon.ResolvedResource, err error) (runtime.Object, *v1.RefSource, error) {
    // ... 
    
    data, err := resolved.Data()
    if err != nil {
        return nil, nil, &DataAccessError{Original: err}
    }
    codecs := serializer.NewCodecFactory(scheme.Scheme, serializer.EnableStrict)
    obj, _, err := codecs.UniversalDeserializer().Decode(data, nil, nil)
    if err != nil {
        return nil, nil, &InvalidRuntimeObjectError{Original: err}
    }
    
    // NEW CHANGE GOES HERE...
    if resolverAnnotations := resolved.Annotations(); resolverAnnotations != nil && len(resolverAnnotations) > 0 {
        if metaObj, ok := obj.(metav1.Object); ok {
            // Merge annotations: existing resource annotations take precedence
            metaObj.SetAnnotations(kmap.Union(
                kmap.ExcludeKeys(resolverAnnotations, tknreconciler.KubectlLastAppliedAnnotationKey),
                metaObj.GetAnnotations(),
            ))
        }
    }
    
    return obj, resolved.RefSource(), nil
}

Of course tests must be added to cover the new logic.

Metadata

Metadata

Assignees

Labels

area/resolutionIssues related to remote resolutionkind/featureCategorizes issue or PR as related to a new feature.kind/tepCategorizes issue or PR as related to a TEP (or needs a TEP).

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions