Split runtime from static configuration and use it for request context.#467
Conversation
|
@rasmunk this is what came of our discussion of the concept the other day :) |
20a5865 to
7b0193b
Compare
d668a66 to
497886e
Compare
5fc0d43 to
58f2dd8
Compare
|
Looks good with the added changes. Since it changes a core piece that almost everything touches I think it is prudent that you checkout and test the branch on either dev or test ERDA before we merge it into next |
1898891 to
6e35a47
Compare
6e35a47 to
be373c8
Compare
This contents of the branch have been running on dev-erda as part of the ui branch for the last couple of months and I've not seen any regressions in that time. At the start of the coming week I'll make a point of using the other functionality, and in particular try to get some emails being sent - but otherwise I think this has now baked long enough. |
Martin-Rehr
left a comment
There was a problem hiding this comment.
I think this email change commit deserves a PR of it's own.
| # --- BEGIN_HEADER --- | ||
| # | ||
| # test_mig_shared_configuration - unit test of configuration | ||
| # Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH |
There was a problem hiding this comment.
We are in 2026 by now :)
Will do. Two quick notes:
|
be373c8 to
09bee5a
Compare
This change paves the way adding further runtime specific data to configuration objects. An instance of a configuration already contains such data, such as the mig_server_id property when in use by daemons and a reference to the logger. With needs arising for further runtime data, make a clear separation between runtime attributes and the static configuration data clear. Opt to do this by making an object which internally keeps a reference to an underlying configuration object, proxies attribute access to it and can then be used as a drop-in substitute in ay call stack of logic. Name this RuntimeConfiguration. Stop short of moving existing runtime properties as of this commit.
ce87442 to
c73c542
Compare
|
I've corrected the typos. I do not have permission to land changes, eve with approval, so if you are happy with this it requires someone with merge privileges to move forward. |
It's pretty hard to review the changes when they are force pushed along with a bunch of other changes.
Just a few notes:
|
I'm sorry for the force-push, was certainly not trying to complicate life. I'll avoid doing that while a review is ongoing from this point forward. Regarding __setattr__, yes unfortunately it is. There is code in various places that dynamically sets properties on the configuration. In order to allow RuntimeConfiguration to be drop in for the original, it mimics that behaviour until such time as we are able to track all of that down. It's actually the same problem as was hit in the tests when ting to establish FakeConfiguration. |
All good, thanks for the clarification, I'll merge it. |
The purpose of this change is twofold: first, firm up the notion of a runtime configuration as distinct from the static configuration loaded on disk and second, with this separation enforced, to prepare for further uses of the runtime side.
Note that the need to do this originated with the needs of templates - consider that a user may need a specific locale to be reflected in the ui for example. An observation was made that we already attach runtime properties to configuration (see mig_server_id, the logger) and must be additional work in various places to sidestep those additions.
Opt to do this by making an object which internally keeps a reference
to an underlying configuration object, proxies attribute access to and can thus be used as a substitute in any call stack of logic. Name this RuntimeConfiguration.
Use the split to add a the notion of a context. This idea was independently arrived at by myself and others on the team. With the support in hand, rework email sending to be context aware - that is, one can simply make use of send_email as before. Internally it will check whether sending was previously done (by consulting the context) and skip any construction steps if so.
As a result of this small change, we become able to centrally intercept email sending without threading arguments through multiple levels of the call stack of logic code purely to override email sending and we can do useful general enforcement.
Add a means for tests to check the the number of emails sent and whether an email was sent to a particular recipient. By default, enforce disallowing unexpected outgoing emails. This has the effect of nudging test writers to account for emails as a covered side effect of the logic being exercised. For cases where the email send is not relevant t, there is an escape hatch.