Skip to content

Commit 74b78a6

Browse files
authored
Set SchedulerHints in failover request and removed incorrect prefix (#626)
1 parent c3b2db6 commit 74b78a6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

api/external/nova/messages.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const (
138138
EvacuateIntent v1alpha1.SchedulingIntent = "evacuate"
139139
// CreateIntent indicates that the request is intended for creating a new VM.
140140
CreateIntent v1alpha1.SchedulingIntent = "create"
141+
// ReserveForFailoverIntent indicates that the request is for failover reservation scheduling.
142+
ReserveForFailoverIntent v1alpha1.SchedulingIntent = "reserve_for_failover"
141143
)
142144

143145
// GetIntent analyzes the request spec and determines the intent of the scheduling request.
@@ -160,6 +162,9 @@ func (req ExternalSchedulerRequest) GetIntent() (v1alpha1.SchedulingIntent, erro
160162
// See: https://github.com/sapcc/nova/blob/c88393/nova/compute/api.py#L5770
161163
case "evacuate":
162164
return EvacuateIntent, nil
165+
// Used by cortex failover reservation controller
166+
case "reserve_for_failover":
167+
return ReserveForFailoverIntent, nil
163168
default:
164169
return CreateIntent, nil
165170
}

internal/scheduling/reservations/failover/reservation_scheduling.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (c *FailoverReservationController) queryHypervisorsFromScheduler(ctx contex
7979
// Note: We pass all hypervisors (from all AZs) in EligibleHosts. The scheduler pipeline's
8080
// filter_correct_az filter will exclude hosts that are not in the VM's availability zone.
8181
scheduleReq := reservations.ScheduleReservationRequest{
82-
InstanceUUID: "failover-" + vm.UUID,
82+
InstanceUUID: vm.UUID,
8383
ProjectID: vm.ProjectID,
8484
FlavorName: vm.FlavorName,
8585
FlavorExtraSpecs: flavorExtraSpecs,
@@ -89,6 +89,7 @@ func (c *FailoverReservationController) queryHypervisorsFromScheduler(ctx contex
8989
IgnoreHosts: ignoreHypervisors,
9090
Pipeline: pipeline,
9191
AvailabilityZone: vm.AvailabilityZone,
92+
SchedulerHints: map[string]any{"_nova_check_type": string(api.ReserveForFailoverIntent)},
9293
}
9394

9495
logger.V(1).Info("scheduling failover reservation",
@@ -218,7 +219,7 @@ func (c *FailoverReservationController) validateVMViaSchedulerEvacuation(
218219
IgnoreHosts: []string{vm.CurrentHypervisor},
219220
Pipeline: PipelineAcknowledgeFailoverReservation,
220221
AvailabilityZone: vm.AvailabilityZone,
221-
SchedulerHints: map[string]any{"_nova_check_type": "evacuate"},
222+
SchedulerHints: map[string]any{"_nova_check_type": string(api.EvacuateIntent)},
222223
}
223224

224225
logger.V(1).Info("validating VM via scheduler evacuation",

0 commit comments

Comments
 (0)