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

PMM-13633 Improve API Key migration to service accounts #796

Merged
merged 13 commits into from
Jan 14, 2025

Conversation

JiriCtvrtka
Copy link

@JiriCtvrtka JiriCtvrtka commented Dec 27, 2024

@matejkubinec matejkubinec changed the title PMM-13633 Nil response instead error in case of it is not SA. PMM-13633 Improve API Key migration to service accounts Jan 9, 2025
@JiriCtvrtka
Copy link
Author

Changes on BE:

  1. Do not return an error when the authentication method is not a service account/token. Instead, return a nil response to allow a warning to be displayed on the PMM side. This prevents unnecessary noise in the Grafana logs.
  2. Sanitize the name and login for the service account, as well as the name for the service token.

@JiriCtvrtka JiriCtvrtka marked this pull request as ready for review January 9, 2025 08:13
Copy link

@YashSartanpara1 YashSartanpara1 left a comment

Choose a reason for hiding this comment

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

LGTM

return response.Error(http.StatusBadRequest, "Auth method is not service account token", errors.New("failed to get service account info"))
return response.JSON(http.StatusOK, nil)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's good idea

Copy link
Author

Choose a reason for hiding this comment

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

Any suggestions? Like reserve -1 ID for SA? In case it is not service account? Because in case of returning error it is logged in Grafana log.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's ok to log it in grafana log as API key is deprecated.

Copy link
Author

Choose a reason for hiding this comment

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

Reverted and right now it will be error in logs again. Changes related to this change in PMM PR: percona/pmm@e519d45. Ticket also adjusted.

@@ -23,6 +20,8 @@ import (
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Copy link
Member

Choose a reason for hiding this comment

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

please revert this change

Copy link
Author

Choose a reason for hiding this comment

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

When I ran "go fmt ./..." even on v3 branch this change appear. It is moved from top to here. Same if I save in my IDE.

Copy link

Choose a reason for hiding this comment

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

Same with make format?

Copy link
Author

Choose a reason for hiding this comment

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

I dont see make format in Makefile. Only something called format-drone. Not related.

Copy link
Member

Choose a reason for hiding this comment

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

please revert manually if there is no command for that.

"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/org/orgtest"
"github.com/grafana/grafana/pkg/services/team/teamtest"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Copy link
Member

Choose a reason for hiding this comment

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

please revert this change

Copy link
Author

Choose a reason for hiding this comment

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

Same here like above. If needed I can do it manually.

@JiriCtvrtka JiriCtvrtka requested a review from BupycHuk January 13, 2025 10:28
@BupycHuk BupycHuk merged commit 4708bc8 into v3 Jan 14, 2025
3 checks passed
@BupycHuk BupycHuk deleted the PMM-13633-migrate-to-service-accounts branch January 14, 2025 08:55
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.

6 participants