Repository navigation
Conversation
|
Note this PR is to get the conversation started, we can improve the error messaging etc. |
|
@xitij2000 It looks like you can't disable the plugin using the command line after running into this problem. I could try modifying the config, but I can't ask it for the config root, either. Is it possible to keep this a warning for configuration commands but an error for things like image building and launching? |
I'll look into that. For now I just wanted to get some feedback. Is there is a reason to not do this at all? Or move it to a separate command or plugin. |
|
The fail-fast goal makes sense, but raising at the plugin-loading layer is too low:
The commands you'd use to recover all trigger plugin loading first, so the user gets bricked into hand-editing Also worth noting: the raise lives inside the I'd suggest keeping loading (warn + record failures) and moving the hard failure up to deployment/build commands ( |
|
@ahmed-arb Thanks for having a look! I agree with all the points you have raised, I just wanted to start discussing this issue with this PR. I plan to make the solution more robust when I get back to this. |
9e3d63d to
a865182
Compare
| def test_check_plugin_errors_exits_with_code_1(self) -> None: | ||
| """_check_plugin_errors should exit with code 1 when errors exist.""" | ||
| self._add_plugin_error() | ||
| with self.assertRaises(SystemExit) as cm: |
There was a problem hiding this comment.
Oh, cool. I didn't know you could catch sys.exit like this.
|
@xitij2000 Thanks for these updates. Image building succeeds, though it should be one of the commands that fails if an enabled plugin is missing, in my opinion. Actually, launch also gets off the ground right now. Can you double-check that things are actually failing for you where they need to be? CI is also failing. You noted to me over our internal ticket that this set of errors would cause a freshly installed tutor launch to fail due to installing only tutor leaving out plugins like mfe and indigo. However, I actually think this is preferable-- if someone accidentally installs only tutor and launches a brand new install, they're not following the tutorial closely and have almost certainly made a mistake. Anyone who is deliberately only installing Tutor will know what to do about this because they'll be familiar, and it's very likely they already have a config.yml file without those entries in the plugin list. |
Now command should run but produce an error at the end and return a error code. While this is not ideal, raising an error first means that you can't even run a command to fix the error, as was the case before. This way if you apply a config change and that raises a plugin error it will raise immediately. While I agree about the missing plugins raising an error by default it is a breaking change and I'd want some upstream feedback on this. |
a865182 to
5c0994e
Compare
Kelketek
left a comment
There was a problem hiding this comment.
@xitij2000 It is indeed failing commands after running them if there is a plugin error. However, I'm still unhappy with it going all the way through commands like image building and launching. It greatly undermines the utility of the change, as the original reason we bothered with this at all was to avoid waiting hours just to find out that the build couldn't be correct.
Note also that if an image building succeeds, that image is saved, and so it will be the image rolled next restart. Someone could deploy an image they don't want to because they haven't fixed it and rebuilt. That shouldn't be possible-- if the configuration is bad and we're returning an error code, we don't want the state to be left worse than when we found it.
You mentioned needing input from upstream on this, bearing in mind that the default settings would break in the case that someone installed Tutor and initialized a new configuration while not following the tutorial and instead running the commands raw. I'm still of the mind that this is fine, given my reasoning above.
However, I want to ping @ahmed-arb and get his take. @ahmed-arb , what are your thoughts on my suggestions here?
| # Only exit with an error code if: | ||
| # - errors are not being ignored | ||
| # - the config file hasn't changed | ||
| # - no exception has already been raised that would return its own error codek |
There was a problem hiding this comment.
| # - no exception has already been raised that would return its own error codek | |
| # - no exception has already been raised that would return its own error code |
|
@Kelketek I think the only solution for this is to special case certain commands to run despite plugin errors, such as config editing, and enabling / disabling plugins. |
|
@xitij2000 Maybe it could be done by a special 'configuration_exempt' decorator which adds an attribute to the function which the preflight can check for? That way any other plugin that includes a command that should be able to run with broken plugins can use it. |
|
@Kelketek I think that approach makes sense. The decorator can simply add an attribute to the function which can be looked up and for functions that are marked this way we can skip the early exit. |
ahmed-arb
left a comment
There was a problem hiding this comment.
LGTM. Could you please update your branch?
|
@xitij2000 Can you please update your branch?, in case if you don't have capacity we can take care of it |
|
@Abdul-Muqadim-Arbisoft Sorry for the delay, this slipped off my mind. I'll aim to update the PR with the latest suggestions asap. |
fc8edb9 to
4716fde
Compare
|
@Abdul-Muqadim-Arbisoft @Kelketek I've made this into a decorator, do have a look. |
4716fde to
acd9946
Compare
Rather than continue and potentially deploy a broken instance, this change make commands fail early so issues can be detected sooner rather than later. A new `hooks.Filters.PLUGIN_ERRORS` filer gathers all plugin errors. In case of errors the Tutor will now abort listing these plugins errors. Commands that cane be helpful in resolving errors, such as plugin, config and help are exempt from this. Additionally, there is a global `--ignore-plugin-errors` flag to ignore all errors.
acd9946 to
1a1225e
Compare
When a plugin is missing or throws an error while loading, Tutor continues as normal. At times this has made us recognise issues far later than we'd like.
This change will raise an error causing the command to return an error and the break the CI flow rather than deploying a broken instance with missing plugins.
We've considered few alternatives.
--check, however this flag would need to be added in a lot of places that cause plugins to load.tutor doctorthis is a convention that many such tools follow that check the config and environment for errors and suggest fixes. This issue with this is that it will require updating existing usage of tutor to call tutor doctor first.