Skip to content

pmanager defaultActivityContext.VpaProperties returns nil before scanning all VPA entries #120

@thomasrutger

Description

@thomasrutger

pmanager defaultActivityContext.VpaProperties currently returns nil, nil inside the loop as soon as it encounters a VPA entry whose vpaType does not match the requested type. This means lookups only work when the requested VPA type is the first valid entry in cfm.vpa.data.

This for example creates a problem for the registration agent, which looks for cfm.issuer data. If another VPA, for example cfm.connector, is encountered first, VpaProperties returns before scanning the later cfm.issuer entry.

Fix: remove the return nil, nil from inside the loop and return nil, nil only after the full list has been scanned.
See:

// VpaProperties retrieves the properties for a specific VPA type from the activity context. If the `cfm.vpa.data` object is not present,
// if it does not contain an entry for the specified VPA type, nil is returned. The contents of the `cfm.vpa.data`.`<vpatype>` entry are
// returned
// if the `cfm.vpa.data` object is not a slice, an error is returned
func (d defaultActivityContext) VpaProperties(vpaType model.VPAType) (map[string]any, error) {
vpaData, ok := d.processingData[model.VPAData]
if !ok || vpaData == nil {
return nil, nil
}
vpaList, ok := vpaData.([]any)
if !ok {
return nil, fmt.Errorf("vpa data is not a slice")
}
for _, item := range vpaList {
vpaEntry, ok := item.(map[string]any)
if !ok {
continue
}
if entryType, exists := vpaEntry["vpaType"]; exists && entryType == vpaType.String() {
if properties, ok := vpaEntry["properties"].(map[string]any); ok {
return properties, nil
}
return make(map[string]any), nil
}
return nil, nil
}
return nil, nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions