The argparse type of node-hold-expiration is int

Old code didn't specify a type so if you didn't use a default value the
value was a string. THis string then got serialized to json and put into
zk where nodepool read it back out against as a string and attempted to
use the expiration value as an integer which leads to this failure:

  2018-08-29 16:39:13,103 ERROR nodepool.CleanupWorker: Exception in CleanupWorker (max hold age cleanup)
  Traceback (most recent call last):
    File "/usr/local/lib/python3.5/dist-packages/nodepool/launcher.py", line 637, in _run
      task()
    File "/usr/local/lib/python3.5/dist-packages/nodepool/launcher.py", line 589, in _cleanupMaxHoldAge
      if node.hold_expiration is not None and node.hold_expiration > 0:
  TypeError: unorderable types: str() > int()

We can avoid this entirely if we tell argparse to coerce the expiration
value to an integer which will serialize as an integer in json and value
comparisons will work as expected.

This seems to have only been an issue if the user passed a non default
value in.

Change-Id: I5b28ef21ebe75a757852b26b3a8a6dd077afacb1
This commit is contained in:
Clark Boylan 2018-08-29 09:51:25 -07:00
parent 0d91a3d590
commit 897379ee73
1 changed files with 1 additions and 1 deletions

View File

@ -66,7 +66,7 @@ class Client(zuul.cmd.ZuulApp):
'node set be in HOLD status '
'(default: nodepool\'s max-hold-age '
'if set, or indefinitely)'),
required=False, default=0)
required=False, type=int, default=0)
cmd_autohold.set_defaults(func=self.autohold)
cmd_autohold_list = subparsers.add_parser(