afdo: Fix assertion failure caused by crrev.com/2398783

Since the code is only used on branch, the failure was only
discover when it goes to the branch. It looks like the assertion
of len(target) == 3 no longer holds true as the function is also
called when the timestamp presents. So just compare them as tuples
for both len=3 and len=4 case.

BUG=chromium:1126172
TEST=unittest pass

Change-Id: I9bf05ec66c776131cd7f9f4a8e3012c3740ae3d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2405298
Tested-by: Tiancong Wang <tcwang@google.com>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Tiancong Wang <tcwang@google.com>
diff --git a/cbuildbot/afdo.py b/cbuildbot/afdo.py
index 4660b31..e3bdec0 100644
--- a/cbuildbot/afdo.py
+++ b/cbuildbot/afdo.py
@@ -1084,13 +1084,7 @@
   Returns:
     latest profile that is older than the target
   """
-  # Versions are sorted, and target doesn't have a timestamp. Since we just
-  # want to find out the newest profile that is older than the target, we
-  # just essentially want to find out the largest profile with smaller
-  # (milestone, build, patch) tuple.
-  assert len(target) == 3, 'target CWP version should have 3 parts'
-  candidates = [x for x in versions
-                if (x[0], x[1], x[2]) < tuple(target)]
+  candidates = [x for x in versions if tuple(x) < tuple(target)]
   if len(candidates) == 0:
     return None
   return candidates[-1]