Skip to content

[IMP] [9.0] Allow configuring runner from config file - #213

Merged
lasley merged 3 commits into
OCA:9.0from
leorochael:configfile_enable_runner_9.0
Oct 19, 2016
Merged

[IMP] [9.0] Allow configuring runner from config file#213
lasley merged 3 commits into
OCA:9.0from
leorochael:configfile_enable_runner_9.0

Conversation

@leorochael

@leorochael leorochael commented Oct 6, 2016

Copy link
Copy Markdown

A forward port of #210.

It is slightly different from the 8.0 version since, AFAICS, the 9.0 connector always runs with a root:1 channel configuration if the connector module is --loaded server wide on Odoo and the environment variable is missing or set to empty.

Which means the only way to "disable" the jobrunner is not to load the connector module at all. Which is fine IMO.

So I moved the default channel configuration logic inside the Channel runner itself.

This could be considered a slightly backward incompatible change:

  • Previously, if the ChannelRunner was not invoked by --loading the connector module server wide, and someone decided to manually invoke the ChannelRunner without passing a channel configuration:
    • then, the default channel configuration would be root:1
    • and not whatever was specified by os.env['ODOO_CONNECTOR_CHANNELS'].

With this PR, if the ChannelRunner is invoked manually without passing a channel configuration, then instead of defaulting directly to root:1, the environment variable and the configuration file will be consulted instead, defaulting to root:1 only if both are missing.

In addition to the ODOO_CONNECTOR_CHANNELS environment variables, we can
configure the runner channels in the odoo configuration file like this:

    [options]
    connector_channels = root:4

As such we can configure the job runner entirely with config files and
command line arguments.

We still need to load the `connector` module on the command line, as
there is no way yet pass the `load` parameter through the config file.
Ignore whitespace around values, and tolerate missing entries that would
be caused by trailing commas or commented lines when the channel
configuration is provided through the Odoo configuration file.

Also, accept line breaks channel entry separators along with commas,
which make the configuration file more readable.
Specifying how to use the configuration file as an alternative to the
environment variable.
@leorochael

Copy link
Copy Markdown
Author

Any opinion on this? What is necessary to move this forward?

@lasley lasley added this to the 9.0 milestone Oct 11, 2016
@pedrobaeza

Copy link
Copy Markdown
Member

@guewen @sbidoul can you review this?

@lasley lasley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, non-blocking. Thanks for the forward porting the improvement 👍

_logger = logging.getLogger(__name__)


# Unfortunately, it is not possible to extend the Odoo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe be a DocBlock for _channels?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps... The first part of this comment was moved (and refrased) from jobrunner/__init__.py, so it didn't occur to me to change it into a docstring.

If I have to shave this yak some more due to @sbidoul's comments before merging this branch I'll take the opportunity to move this comment into a _channels() docstring as well. 😏

>>> ChannelManager.split_strip("foo: bar baz\\n: fred:", ":")
['foo', 'bar baz', 'fred', '']
"""
return [x.strip() for x in s.split(sep, maxsplit)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more a candidate for a simple function rather than a class method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already like this on the 8.0-branch version of this change.

I could easily fix this here, but I'm afraid it could impact future changes done to multiple branches.

Should I:

  • fix it just here (and on the future branch 10 version of this PR)?
  • leave it as is?
    • And perhaps in the future do another PR for fixing this in the three branches?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leorochael I approved the PR already. So you can leave as is.

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor remark, other wise looks very good to me (code review, no test). Thanks for this work and care to update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants