fix: properly map config patch requests in the infra provision ctrl
Some checks are pending
default / default (push) Waiting to run
default / e2e-backups (push) Blocked by required conditions
default / e2e-forced-removal (push) Blocked by required conditions
default / e2e-scaling (push) Blocked by required conditions
default / e2e-short (push) Blocked by required conditions
default / e2e-short-secureboot (push) Blocked by required conditions
default / e2e-templates (push) Blocked by required conditions
default / e2e-upgrades (push) Blocked by required conditions
default / e2e-workload-proxy (push) Blocked by required conditions

The bug was causing missing reconciliations.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
This commit is contained in:
Artem Chernyshev 2024-11-12 18:42:14 +03:00
parent fe075b04b2
commit 05ab993d3d
No known key found for this signature in database
GPG Key ID: E084A2DF1143C14D

View File

@ -106,16 +106,41 @@ func (ctrl *ProvisionController[T]) Settings() controller.QSettings {
}
// MapInput implements controller.QController interface.
func (ctrl *ProvisionController[T]) MapInput(_ context.Context, _ *zap.Logger,
_ controller.QRuntime, ptr resource.Pointer,
func (ctrl *ProvisionController[T]) MapInput(ctx context.Context, _ *zap.Logger,
r controller.QRuntime, ptr resource.Pointer,
) ([]resource.Pointer, error) {
if ptr.Type() == siderolink.ConnectionParamsType {
var t T
switch ptr.Type() {
case siderolink.ConnectionParamsType:
return nil, nil
case infra.ConfigPatchRequestType:
configPatchRequest, err := safe.ReaderGetByID[*infra.ConfigPatchRequest](ctx, r, ptr.ID())
if err != nil {
if state.IsNotFoundError(err) {
return nil, nil
}
return nil, err
}
id, ok := configPatchRequest.Metadata().Labels().Get(omni.LabelMachineRequest)
if !ok {
return nil, err
}
return []resource.Pointer{
infra.NewMachineRequest(id).Metadata(),
}, nil
case infra.MachineRequestType,
infra.MachineRequestStatusType,
t.ResourceDefinition().Type:
return []resource.Pointer{
infra.NewMachineRequest(ptr.ID()).Metadata(),
}, nil
}
return []resource.Pointer{
infra.NewMachineRequest(ptr.ID()).Metadata(),
}, nil
return nil, fmt.Errorf("got unexpected type %s", ptr.Type())
}
// Reconcile implements controller.QController interface.