fix(spotinst): rolling-update workaround

This commit is contained in:
liranp 2019-07-15 19:20:44 +03:00
parent dd6b0314fc
commit ff58f4aac9
No known key found for this signature in database
GPG Key ID: 22E8BBE0841BC3BA
1 changed files with 19 additions and 0 deletions

View File

@ -337,6 +337,25 @@ func buildCloudInstanceGroupFromLaunchSpec(cloud Cloud, ig *kops.InstanceGroup,
func registerCloudInstanceGroupMembers(instanceGroup *cloudinstances.CloudInstanceGroup, nodeMap map[string]*v1.Node, func registerCloudInstanceGroupMembers(instanceGroup *cloudinstances.CloudInstanceGroup, nodeMap map[string]*v1.Node,
instances []Instance, currentInstanceGroupName string, instanceGroupUpdatedAt time.Time) error { instances []Instance, currentInstanceGroupName string, instanceGroupUpdatedAt time.Time) error {
// The instance registration below registers all active instances with
// their instance group. In addition, it looks for outdated instances by
// comparing each instance creation timestamp against the modification
// timestamp of its instance group.
//
// In a rolling-update operation, one or more detach operations are
// performed to replace existing instances. This is done by updating the
// instance group and results in updating the modification timestamp to the
// current time.
//
// The update of the modification timestamp occurs only after the detach
// operation is completed, meaning that new instances have already been
// created, so our comparison may be incorrect.
//
// In order to work around this issue, we assume that the detach operation
// will take up to two minutes, and therefore we subtract this duration from
// the modification timestamp of the instance group before the comparison.
instanceGroupUpdatedAt = instanceGroupUpdatedAt.Add(-2 * time.Minute)
for _, instance := range instances { for _, instance := range instances {
if instance.Id() == "" { if instance.Id() == "" {
klog.Warningf("Ignoring instance with no ID: %v", instance) klog.Warningf("Ignoring instance with no ID: %v", instance)