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

Deprecate and remove api/v1/ #2970

Merged
merged 3 commits into from
Nov 24, 2023
Merged

Deprecate and remove api/v1/ #2970

merged 3 commits into from
Nov 24, 2023

Conversation

gotjosh
Copy link
Member

@gotjosh gotjosh commented Jun 29, 2022

This is intentionally incomplete and is open mostly as a guideline to see what breaks.

The description will be updated once the work is finished and serves as a checklist to give visibility of a plan for reviewers.

fixes #2469

The steps to take are:

  • Allow /api/v1/alerts to behave like /api/v2/alerts.
  • Update comments and resolve TODOs if applicable - I don't have any context on them yet but I'll find out.
  • Revise any configuration options to see if there are any applicable only to api/v1

Edit:

  • Instead of making api/v1/* redirect to the /api/v2 I opted for adding a deprecation notice in JSON to all of the v1 routes. On top of that, each time a v1 route is called it'll log a warning letting the operator know that something is not going right.
  • I checked, TODOs and the removed code to see if there was anything I was missing but I couldn't find anything.

@gotjosh gotjosh force-pushed the remove-api-v1 branch 2 times, most recently from e0d9502 to cac28d3 Compare June 29, 2022 12:29
Signed-off-by: gotjosh <josue.abreu@gmail.com>
uptime: time.Now(),
peer: peer,
logger: l,
m: metrics.NewAlerts("v1", r),
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically, we can remove this distinction now but it would be a rather critical breaking change - I would rather not risk it.

Copy link
Member Author

Choose a reason for hiding this comment

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

nvm, I made it permament.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
@gotjosh
Copy link
Member Author

gotjosh commented Nov 21, 2023

@simonpasquier I think this ready for review - this is currently blocking the progress on #3567 as making API v1 compatible with that work is a large endeavour for something we don't need.

Would appreciate a speedy review - I think the changes to the deprecation router are good enough to let users know that something that we deprecated back in 0.18 is now gone.

@gotjosh gotjosh marked this pull request as ready for review November 21, 2023 19:04
@gotjosh gotjosh requested a review from beorn7 November 21, 2023 19:04
Copy link
Contributor

@grobinson-grafana grobinson-grafana left a comment

Choose a reason for hiding this comment

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

Tested and LGTM! ❤️

Error string `json:"error"`
}{
"deprecated",
"The Alertmanager v1 API was deprecated in version 0.16.0 and entirely removed since version 0.28.0 - please use the equivalent route in the v2 API",
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, feel free to ignore 😄

Suggested change
"The Alertmanager v1 API was deprecated in version 0.16.0 and entirely removed since version 0.28.0 - please use the equivalent route in the v2 API",
"The Alertmanager v1 API was deprecated in version 0.16.0 and is removed as of version 0.28.0 - please use the equivalent route in the v2 API",

}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(410)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! ❤️

w.WriteHeader(410)

// We don't care about errors for this route.
b, _ := json.Marshal(resp)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to change this, but you can also use:

if err := json.NewEncoder(w).Encode(resp); err != nil {
    level.Error(dr.logger).Log("msg", "failed to write response", "err", err)
}

@beorn7
Copy link
Member

beorn7 commented Nov 23, 2023

Looks great in general, but you are so deep into the weeds here that I don't feel qualified to evaluate the details. :)

Signed-off-by: gotjosh <josue.abreu@gmail.com>
@gotjosh gotjosh merged commit b4f7027 into main Nov 24, 2023
11 checks passed
@gotjosh gotjosh deleted the remove-api-v1 branch November 24, 2023 09:06
@gotjosh
Copy link
Member Author

gotjosh commented Nov 24, 2023

Thanks @beorn7 - With the amount of context you have, you'll always be overqualified to review anything we throw at you.

@alanprot
Copy link

alanprot commented Apr 2, 2024

Should we follow up with a change on prometheus to now allow configuring v1 endpoints anymore?

https://github.com/prometheus/prometheus/blob/9b7de4778732ca2f2ab5028e9d1955109f440c4c/config/config.go#L910-L921

@grobinson-grafana
Copy link
Contributor

Should we follow up with a change on prometheus to now allow configuring v1 endpoints anymore?

https://github.com/prometheus/prometheus/blob/9b7de4778732ca2f2ab5028e9d1955109f440c4c/config/config.go#L910-L921

Yes please Alan! Would you be happy to open a PR for that?

@alanprot
Copy link

alanprot commented Apr 2, 2024

Np: prometheus/prometheus#13883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Alertmanager API v1
4 participants