2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

103 Commits

Author SHA1 Message Date
Ben Pfaff
4fdfe5ccf8 ovsdb-idl: Prevent occasional hang when multiple database clients race.
When a client of the IDL tries to commit a read-modify-write transaction
but the database has changed in the meantime, the IDL tells its client to
wait for the IDL to change and then try the transaction again by returning
TXN_TRY_AGAIN.  The "wait for the IDL to change" part is important because
there's no point in retrying the transaction before the IDL has received
the database updates (the transaction would fail in the same way all over
again).

However, the logic was incomplete: the database update can be received
*before* the reply to the transaction RPC (I think that in the current
ovsdb-server implementation this will always happen, in fact).  When this
happens, the right thing to do is to retry the transaction immediately;
if we wait, then we're waiting for an additional change to the database
that may never come, causing an indefinite hang.

This commit therefore breaks the "try again" IDL commit status code
into two, one that means "try again immediately" and another that means
"wait for a change then try again".  When an update is processed after a
transaction is committed but before the reply is received, the "try again
now" tells the IDL client not to wait for another database change before
retrying its transaction.

Bug #5980.
Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
Reproduced-by: Alex Yip <alex@nicira.com>
2011-10-31 09:15:14 -07:00
Ben Pfaff
dae57238bc ovs.db.types: Consistently use commas in formatting large numbers.
Suggested-by: Justin Pettit <jpettit@nicira.com>
2011-10-12 10:20:37 -07:00
Ben Pfaff
e44a6fe503 ovs.daemon: Fix bug introduced by "pychecker" warning fixes.
Commit 591c20651f1 "daemon.py: Don't shadow built-in 'file' variable"
changed most instances of "file" to "file_handle" but missed this one.

I'm not certain that this solves a real problem, but it still seems wrong.

Bug #7533.
2011-09-29 07:30:51 -07:00
Ben Pfaff
723a8d23f5 ovs.daemon: Fix semantics of --pidfile option.
The --pidfile option is supposed to work like this:

   * Without --pidfile, you don't get a pidfile.
   * With --pidfile, you get the default pidfile.
   * With --pidfile=FILE, you get FILE as your pidfile.

However, it actually worked like this:

   * Without --pidfile, you got the default pidfile.
   * With --pidfile, you got no pidfile at all.
   * With --pidfile=FILE, you got FILE as your pidfile.

This is because of the semantics of "default" in argparse.  It is
documented as:

    The default keyword argument of add_argument(), whose value defaults to
    None, specifies what value should be used if the command-line argument
    is not present.  For optional arguments, the default value is used when
    the option string was not present at the command line.

We actually want "const", which is documented under the description of
nargs="?" as:

    If no command-line argument is present, the value from default will be
    produced.  Note that for optional arguments, there is an additional
    case - the option string is present but not followed by a command-line
    argument.  In this case the value from const will be produced.

Bug #7533.
2011-09-29 07:30:51 -07:00
Ethan Jackson
3a656eafb9 python: Upgrade to vlog.
This patch upgrades the library code in the python/ovs directory to
the new vlog module.
2011-09-27 14:51:49 -07:00
Ethan Jackson
b153e66790 python: Upgrade daemon module to argparse.
This patch also updates it's callers.
2011-09-27 14:51:49 -07:00
Ethan Jackson
ec394dad53 stream.py: Make usage() function return a string.
This will marginally simplify a future patch.
2011-09-27 14:50:26 -07:00
Ethan Jackson
8ed182d80e python: Create new vlog module.
Currently, each python daemon has to come up with it's own logging
solution.  These logging strategies are not consistent across the
python code or with the C vlog module.  This patch adds a new
logging module which hopes to solve the problem.  This new module
generates log messages in a manner consistent with the C code.
Furthermore, it can easily be extended to support things like rate
limiters in the future.

This patch does not update any python code to use the new module.
2011-09-27 14:50:26 -07:00
Ethan Jackson
6c88547dd0 python: Backport argparse to older platforms.
Argparse has some convenient advantages over optparse including the
ability to handle optional arguments to flags.  It also supports
parsing arguments as well as options.

This patch copies argparse.py from Python 2.7 into a newly created
compat directory.  It made some very minor syntactic updates in the
process.  Platforms which have a Python version too old to include
argparse by default will have this compat version installed as a
workaround.
2011-09-27 11:38:30 -07:00
Ben Pfaff
cd1b3f63f3 json.py: Typo in parsing code. 2011-09-26 11:43:25 -07:00
Ethan Jackson
26bb0f3129 python: Style cleanup.
This patch does minor style cleanups to the code in the python and
tests directory.  There's other code floating around that could use
similar treatment, but updating it is not convenient at the moment.
2011-09-24 16:32:54 -07:00
Ethan Jackson
4ad07e6063 ovsuuid.py: Fix use of undefined symbol.
Found by pychecker.
2011-09-24 00:16:06 -07:00
Ben Pfaff
8cdf034974 python: Implement write support in Python IDL for OVSDB.
Until now, the Python bindings for OVSDB have not supported writing to the
database.  Instead, writes had to be done with "ovs-vsctl" subprocesses.
This commit adds write support and brings the Python bindings in line with
the C bindings.

This commit deletes the Python-specific IDL tests in favor of using the
same tests as the C version of the IDL, which now pass with both
implementations.

This commit updates the two users of the Python IDL to use the new write
support.  I tested this updates only by writing unit tests for them,
which appear in upcoming commits.
2011-09-23 14:23:16 -07:00
Ben Pfaff
7cba02e442 ovs.db.types: Add table reference to ovs.db.types.BaseType.
Until now ovs.db.types.BaseType has kept track of the name of the
referenced table but not a reference to it.  This commit renames the
ref_table attribute to ref_table_name and adds a new ref_table attribute
whose value is a reference to the named table.

This will be useful in an upcoming commit where table references are
actually followed.
2011-09-23 09:10:45 -07:00
Ben Pfaff
5c3a4660c0 python: Accept multiple forms of strings and lists when parsing JSON.
The JSON parser in OVS always yields unicode strings and lists, never
non-unicode strings or tuples, but it's easy to create them when building
JSON elsewhere, so accept both forms.
2011-09-23 09:10:45 -07:00
Ben Pfaff
843fb01b61 python: Change 'clone' function names to 'copy'.
It seems that 'copy' is the proper name for this kind of function in
Python, based on the existence of dict.copy().
2011-09-23 09:10:45 -07:00
Ben Pfaff
49c541dc11 ovs.ovsuuid: Get rid of ovs.ovsuuid.UUID class.
This class only caused unnecessary confusion.  This commit changes all of
its methods into top-level functions.
2011-09-23 09:10:45 -07:00
Ben Pfaff
b2edc4e7d8 ovs.jsonrpc: Include result in Message.__str__() output.
This was overlooked in the initial implementation.  Including the result
member makes logging output more useful.
2011-09-23 09:10:44 -07:00
Ben Pfaff
9e4f0157ec ovs.db.data: Make Datum.check_constraints() work.
This code never got tested and so didn't work.

This does not fix an actual bug because Datum.check_constraints() does not
have any existing users.
2011-09-23 09:10:44 -07:00
Ben Pfaff
cf5404f67d ovs.db.data: Fix Atom.new()'s handling of Boolean values.
Boolean values have Boolean type, not real type.

This does not fix an actual bug because Atom.new() does not have existing
users.
2011-09-23 09:10:44 -07:00
Ben Pfaff
169390eed0 ovs.json: Remove commented-out debug code.
This must have slipped into an old commit by accident.
2011-09-23 09:10:44 -07:00
Ben Pfaff
cba641035b ovs.json: Actually implement the "pretty" option for serialization. 2011-09-23 09:10:44 -07:00
Ben Pfaff
9b46cccc33 python: Avoid shadowing standard or global names.
Found by pychecker.
2011-09-23 09:10:44 -07:00
Ben Pfaff
28c781df8a python: Avoid "unused parameter" warnings from pychecker.
pychecker ignores parameters named "_" or prefixed with "unused_".
2011-09-23 09:10:43 -07:00
Ben Pfaff
14cd095f26 ovs.db.types: Always initialize ref_type attribute.
The ref_type attribute was initialized on some paths but not others.

Found by pychecker.
2011-09-23 09:10:43 -07:00
Ethan Jackson
2a8859b0a4 daemon.py: Silence return warning.
Pychecker complains about __read_pidfile() having too may returns.
I personally think the function is fine, but it's easy enough to
reduce them.

python/ovs/daemon.py:395: Function (__read_pidfile) has too many
returns (12)
2011-09-16 18:27:33 -07:00
Ethan Jackson
591c20651f daemon.py: Don't shadow built-in 'file' variable.
Pychecker considers it bad style.
2011-09-16 18:27:33 -07:00
Ethan Jackson
cadc9871c2 daemon.py: Whitespace cleanup.
The python style guide requires two newlines between top level
definitions.  This patch also removes some trailing whitespace.
2011-09-16 16:03:31 -07:00
Ben Pfaff
44852fdf63 Mark "uninstall-local" targets phony. 2011-09-15 11:19:59 -07:00
Ben Pfaff
54658e6169 ovs.db.types: Remove write-only variable from constraintsToEnglish().
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
973d7411d6 python: Remove unused imports.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
1f00acd0bc ovs.stream: Remove unused parameter from usage().
This function has no callers.  We could delete it entirely, instead.
2011-08-25 11:07:23 -07:00
Ben Pfaff
fecf78c237 ovs.ovsuuid: Fix UUID.cInitUUID invocation of re.match with too few params.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
4071e24db4 ovs.jsonrpc: Fix static method Session.open() reference to 'self'.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
b2a5856fef ovs.jsonrpc: Fix static method Message.__validate_arg reference to 'self'.
This method needs to be an instance method because it refers to 'self'.

Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
6732237bee ovs.json: Use Exception, which exists, instead of Error, which doesn't.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
7550c333d3 ovs.db.idl: Fix error message format arguments.
There's no variable table_name.

Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
c6b24dd7cd ovs.daemon: Add missing format string argument.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
0003748f58 ovs.daemon: Fix name of EALREADY error.
Found by pychecker.
2011-08-25 11:07:22 -07:00
Ben Pfaff
dbad9de126 ovs.daemon: Add missing 'global' when setting _pidfile_dev, _pidfile_ino.
Found by pychecker.
2011-08-25 11:07:22 -07:00
Ben Pfaff
af1eba26c3 ovs.db.idl: Fix call to ovs.db.parser.Parser constructor.
This bug was introduced by commit 4c0f62718f "ovs.db.idl: Improve error
reporting for bad <row-update>s."

Found by pychecker.
Bug #7006.
2011-08-25 11:06:53 -07:00
Ben Pfaff
367da73833 python: Use enumerate() builtin function to simplify counted iteration.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
8ba31bf16d ovs.stream: Simplify logic in Stream.wait().
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
63b1a52133 ovs.stream: Drop Stream.get_name() since clients can use 'name' directly.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
1f9dd59cf1 ovs.stream: Use %d in place of %ld since the two are equivalent in Python.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
90d9dcfc12 ovs.reconnect: Fix typo in documentation.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
0a61b042a5 ovs.reconnect: Make Reconnect.Reconnect inherit from object.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
2ad4ef8920 ovs.jsonrpc: Use "not X" in place of "len(X) == 0" for testing strings.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
22bb61e9ee ovs.jsonrpc: Remove Connection.get_name()--clients can use 'name' directly.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
17af143600 ovs.jsonrpc: Remove dead class variable Message.__next_id.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00