Skip to content

Commit a3b0f5e

Browse files
committed
fix: fallback OD drift check
1 parent 74040ed commit a3b0f5e

File tree

1 file changed

+14
-3
lines changed
  • pkg/controllers/nodeclaim/disruption

1 file changed

+14
-3
lines changed

pkg/controllers/nodeclaim/disruption/drift.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,20 @@ func instanceTypeNotFound(its []*cloudprovider.InstanceType, nodeClaim *v1.NodeC
115115
it, ok := lo.Find(its, func(it *cloudprovider.InstanceType) bool {
116116
return it.Name == nodeClaim.Labels[corev1.LabelInstanceTypeStable]
117117
})
118-
// Offerings should in most cases only have zone and capacity type. This likely shouldn't differ
119-
// across cloud providers.
120-
if !ok || !it.Offerings.HasCompatible(scheduling.NewLabelRequirements(nodeClaim.Labels)) {
118+
if !ok {
119+
return InstanceTypeNotFound
120+
}
121+
reqs := scheduling.NewLabelRequirements(nodeClaim.Labels)
122+
// The reserved capacity type is special because a NodeClaim can be demoted from reserved to on-demand after creation.
123+
// For this reason, when evaluating drift due to unavailable offerings, we should check both reserved and on-demand for
124+
// reserved nodeclaims. This ensures we don't drift a nodeclaim whoes label hasn't been updated yet. If the NodePool
125+
// isn't compatible with on-demand, this will be caught in subsequent iterations by requirements drift. For a similar
126+
// reason we don't compare against the reservation ID and leave that to the provider to implement.
127+
if nodeClaim.Labels[v1.CapacityTypeLabelKey] == v1.CapacityTypeReserved {
128+
reqs[v1.CapacityTypeLabelKey] = scheduling.NewRequirement(v1.CapacityTypeLabelKey, corev1.NodeSelectorOpIn, v1.CapacityTypeReserved, v1.CapacityTypeOnDemand)
129+
delete(reqs, cloudprovider.ReservationIDLabel)
130+
}
131+
if !it.Offerings.HasCompatible(reqs) {
121132
return InstanceTypeNotFound
122133
}
123134
return ""

0 commit comments

Comments
 (0)