Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecations metric #13735

Merged
merged 1 commit into from
Oct 11, 2024
Merged

feat: deprecations metric #13735

merged 1 commit into from
Oct 11, 2024

Conversation

Joibel
Copy link
Member

@Joibel Joibel commented Oct 10, 2024

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.

@Joibel Joibel force-pushed the deprecation-metric branch 2 times, most recently from ba4f1a1 to b0af5bb Compare October 10, 2024 13:26
@Joibel Joibel marked this pull request as ready for review October 10, 2024 15:34
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

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

Minor comment, will leave up to you to decide.

Comment on lines +23 to +28
func ObjectName(ctx context.Context) string {
if n, ok := ctx.Value(name).(string); ok {
return n
}
return ""
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd personally prefer returning a boolean as well.
Exactly like how maps work.

I know this is guaranteed to have this key though.

But we do check the ok in the cast, continuing on with this lack of assuming things, we should also return an ok bool.

Copy link
Member Author

Choose a reason for hiding this comment

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

When someone needs it we can add that, right now it wouldn't be used, so not adding in this commit.

func ObjectNamespace(ctx context.Context) string {
if n, ok := ctx.Value(namespace).(string); ok {
return n
}
Copy link
Member

Choose a reason for hiding this comment

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

same here

A metric to measure the use of deprecated features in the code base

Signed-off-by: Alan Clucas <[email protected]>
@Joibel Joibel merged commit 91765fa into argoproj:main Oct 11, 2024
28 checks passed
@Joibel Joibel deleted the deprecation-metric branch October 11, 2024 09:26
@agilgur5 agilgur5 added this to the v3.6.0 milestone Oct 11, 2024
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

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

Had some WIP comments here too

@@ -248,6 +248,7 @@ nav:
- offloading-large-workflows.md
- workflow-archive.md
- metrics.md
- deprecations.md
Copy link
Member

@agilgur5 agilgur5 Oct 11, 2024

Choose a reason for hiding this comment

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

I'd put this next to upgrading.md and link to it from there too.

Same as the "New features" page we discussed in the Contributor Meeting, having it per version and matching up with the upgrading guide will make it easier to follow. EDIT: See also #13739 (comment)

Although arguably deprecations should be part of the upgrading guide.

Copy link
Member

Choose a reason for hiding this comment

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

Although arguably deprecations should be part of the upgrading guide.

I see this has been done in #13757 now

Copy link
Member

@agilgur5 agilgur5 Oct 18, 2024

Choose a reason for hiding this comment

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

Similarly to above, I would put all the H2 headings here a under a 3.6 version heading so that the upgrading guide could reference it per version. With no versions on this page, it's hard to understand when something was deprecated, and some of these also reference features that are only available in newer versions

As we have already had users attempt to use 3.5 and 3.6 features in older versions when there were no version annotations (#13645 as one example), I could definitely see users reading this, seeing the deprecation, trying the new syntax, and then getting a syntax error and raising an issue.

Sometimes a feature of Argo Workflows is deprecated.
You should stop using a deprecated feature as it may be removed in a future minor or major release of Argo Workflows.

To determine if you are using a deprecated feature the [`deprecated_feature`](metrics.md#deprecated_feature) metric can help.
Copy link
Member

Choose a reason for hiding this comment

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

It would definitely be good to have a version annotation for this metric too, as people will see this page, try to use it, and not realize that it's not available in older versions, and perhaps even think they're in the clear because of that.

If the number is going up the feature is still in use by your system.
If the metric is not present or no longer increasing are no longer using the monitored deprecated features.

## `cronworkflow schedule`
Copy link
Member

Choose a reason for hiding this comment

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

I would name these for their respective features so that they are easily correlated, and then perhaps have a "> cronworkflow schedule attribute" to indicate that this is what the metric displays. I think it's difficult to tell that this is referring to those specific names unless you have specifically came from the metric's page and read it in detail.

This page isn't specific to the metric though, it's just named "Deprecations" in general as well, so it can reference it but should be its own independent page as well

Copy link
Member

Choose a reason for hiding this comment

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

It would also be good to link to the feature page for each of these which will have more details and examples

Comment on lines +19 to +27
schedule: "30 1 * * *"
```
is replaced with
```yaml
spec:
schedules:
- "30 1 * * *"
Copy link
Member

Choose a reason for hiding this comment

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

These examples would likely be easier to understand quickly with a ```diff, i.e.:

-   schedule: "30 1 * * *"
+   schedules:
+     - "30 1 * * *"

## `cronworkflow schedule`

The spec field `schedule` which takes a single value is replaced by `schedules` which takes a list.
To update this replace the `schedule` with `schedules` as in the following example
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To update this replace the `schedule` with `schedules` as in the following example
To update this replace the `schedule` with `schedules` as in the following example:

Colons are also missing in prior to all the examples, which are conventionally (and gramatically) used when describing an example in the docs

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.

3 participants