A metric to measure the use of deprecated features in the code base
Motivation
We have a number of deprecated features.
As a user it will be hard to know if it is safe to upgrade beyond the point when the deprecated feature becomes removed.
In preparation for removing the features this metric can be monitored to ensure you're good to upgrade.
Modifications
There is a deliberate design decision to ensure the counting was simple. It would be worse for us to have a bug in the counting code which meant we didn't flag up a use when there was one. So each deprecated field is flagged at point of use by the code base.
This has problems:
We may not care in this case - for example the validator called from the CLI doesn't have telemetry, so this doesn't work here.
We will look at some fields multiple times in a single run of the reconciliation loop, so the number will go up faster than once per workflow run. I considered that attempting to get 'once per' behaviour would introduce more bugs, and this provides the necessary information
There are two new modules:
context
This is a general purpose module for reading and writing object metadata into context which is the canonical way of passing data around. This avoids us having to expose too much information in the wrong places.
deprecation
This is a separate module with no imports except context above which can be called from anywhere without anything other than a context. The context does not need to contain the desired information.
It holds an evil global variable specifying what to do when a deprecation is flagged. When this has been initialised by the controller to point to the metrics function which records deprecations we get the metric number going up. Otherwise it's silent.
If the namespace is available in context we report it. This will be the namespace of the running workflow or cronworkflow.
Overall
This means this modifies a lot of code paths to pass context, but I consider this a reasonable thing that we should want in general anyway.
NOT Implemented here
The validator does not flag up deprecated features. It should so I've raised #13736
We could log these too, including name which might help in hunting down stragglers. (Some of these come from WorkflowTemplates, so it's not immediately going to point the finger).
Verification
Unit tests have been added. e2e test for each deprecation added.
A metric to measure the use of deprecated features in the code base
Motivation
We have a number of deprecated features.
As a user it will be hard to know if it is safe to upgrade beyond the point when the deprecated feature becomes removed.
In preparation for removing the features this metric can be monitored to ensure you're good to upgrade.
Modifications
There is a deliberate design decision to ensure the counting was simple. It would be worse for us to have a bug in the counting code which meant we didn't flag up a use when there was one. So each deprecated field is flagged at point of use by the code base.
This has problems:
There are two new modules:
context
This is a general purpose module for reading and writing object metadata into context which is the canonical way of passing data around. This avoids us having to expose too much information in the wrong places.
deprecation
This is a separate module with no imports except
context
above which can be called from anywhere without anything other than a context. The context does not need to contain the desired information.It holds an evil global variable specifying what to do when a deprecation is flagged. When this has been initialised by the controller to point to the metrics function which records deprecations we get the metric number going up. Otherwise it's silent.
If the namespace is available in
context
we report it. This will be the namespace of the running workflow or cronworkflow.Overall
This means this modifies a lot of code paths to pass context, but I consider this a reasonable thing that we should want in general anyway.
NOT Implemented here
The validator does not flag up deprecated features. It should so I've raised #13736
We could log these too, including
name
which might help in hunting down stragglers. (Some of these come from WorkflowTemplates, so it's not immediately going to point the finger).Verification
Unit tests have been added. e2e test for each deprecation added.