in pkg/interruptionevent/asg/launch/handler.go [87:109]
func (h *Handler) isNodeReady(instanceID string) (bool, error) {
nodes, err := h.getNodesWithInstanceID(instanceID)
if err != nil {
return false, fmt.Errorf("find node(s) with instanceId=%s: %w", instanceID, err)
}
if len(nodes) == 0 {
log.Info().Str("instanceID", instanceID).Msg("EC2 instance not found")
return false, nil
}
for _, node := range nodes {
conditions := node.Status.Conditions
for _, condition := range conditions {
if condition.Type == "Ready" && condition.Status != "True" {
log.Info().Str("instanceID", instanceID).Msg("EC2 instance found, but not ready")
return false, nil
}
}
}
log.Info().Str("instanceID", instanceID).Msg("EC2 instance is found and ready")
return true, nil
}