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-13715: allow viewers/editors access limited PMM settings #3518

Merged
merged 13 commits into from
Mar 4, 2025

Conversation

idoqo
Copy link
Contributor

@idoqo idoqo commented Jan 29, 2025

PMM-13715
PMM-12356

Link to the Feature Build: SUBMODULES-3840

If this PR adds or removes or alters one or more API endpoints, please review and add or update the relevant API documents as well:

  • API Docs updated

If this PR is related to some other PRs in this or other repositories, please provide links to those PRs:

  • Links to related pull requests (optional).

Sorry, something went wrong.

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.

Project coverage is 43.76%. Comparing base (3112dea) to head (6c4520a).
Report is 3 commits behind head on v3.

Files with missing lines Patch % Lines
managed/services/server/server.go 0.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #3518      +/-   ##
==========================================
- Coverage   43.76%   43.76%   -0.01%     
==========================================
  Files         367      367              
  Lines       44514    44538      +24     
==========================================
+ Hits        19481    19491      +10     
- Misses      23350    23363      +13     
- Partials     1683     1684       +1     
Flag Coverage Δ
admin 11.51% <ø> (+0.04%) ⬆️
agent 52.32% <ø> (+0.04%) ⬆️
managed 45.36% <0.00%> (-0.03%) ⬇️
vmproxy 73.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@idoqo idoqo changed the title PMM-12356 allow editor for check results PMM-13715: allow viewers/editors access limited PMM settings Jan 29, 2025
@idoqo idoqo marked this pull request as ready for review January 29, 2025 11:17
@idoqo idoqo requested review from BupycHuk and a team as code owners January 29, 2025 11:17
@idoqo idoqo requested review from ademidoff and JiriCtvrtka and removed request for a team January 29, 2025 11:17
"details": {
"type": "array",
"items": {
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }",
Copy link
Member

Choose a reason for hiding this comment

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

I wonder, where does this come from? Does it have to be that lengthy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it's generated for all v1/server endpoints

@@ -181,12 +181,42 @@ message Settings {
uint32 default_role_id = 18;
}

// Settings represents a stripped-down version of PMM Server settings that can be accessed by users of all roles.
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
// Settings represents a stripped-down version of PMM Server settings that can be accessed by users of all roles.
// ReadOnlySettings represents a stripped-down version of PMM Server settings that can be accessed by users of all roles.

@@ -63,6 +63,7 @@ var rules = map[string]role{
"/v1/alerting": viewer,
"/v1/advisors": editor,
"/v1/advisors/checks:": editor,
"/v1/advisors/failedServices": editor,
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -494,6 +494,35 @@ func (s *Server) convertSettings(settings *models.Settings, connectedToPlatform
return res
}

// convertReadOnlySettings merges database settings and settings from environment variables into API response.
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
// convertReadOnlySettings merges database settings and settings from environment variables into API response.
// convertReadOnlySettings created a subset of database settings for the "viewer" role.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see the envvars involved here. :)

Comment on lines 194 to 195
// Percona Platform user's email, if this PMM instance is linked to the Platform.
string platform_email = 8;
Copy link
Member

Choose a reason for hiding this comment

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

do we really need this setting to be public?

Comment on lines 190 to 191
MetricsResolutions metrics_resolutions = 3;
google.protobuf.Duration data_retention = 4;
Copy link
Member

Choose a reason for hiding this comment

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

do we really need these settings to be public?

Copy link
Member

Choose a reason for hiding this comment

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

let's reserve these numbers, but not provide value yet until it's required

Comment on lines 199 to 201
string pmm_public_address = 11;
// Intervals between Advisor runs.
AdvisorRunIntervals advisor_run_intervals = 12;
Copy link
Member

Choose a reason for hiding this comment

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

do we really need these settings to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really - they are shown on the advanced settings page, but non-admin roles can't access that page anyway - we can reserve the number as in the other cases

// True if Azure Discover is enabled.
bool azurediscover_enabled = 14;
// True if Access Control is enabled.
bool enable_access_control = 17;
Copy link
Member

Choose a reason for hiding this comment

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

oh shit, it's inconsistent with other fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I saw too - will need to prep separate PR to update it

@idoqo idoqo force-pushed the PMM-12356-allow-editor-for-check-results branch from 81319bf to c88f399 Compare January 30, 2025 06:45
@idoqo idoqo requested a review from BupycHuk February 3, 2025 11:02
@ademidoff ademidoff temporarily deployed to PMM-12356-allow-editor-for-check-results - pmm-doc-3 PR #3518 March 3, 2025 09:29 — with Render Destroyed
@@ -288,6 +312,14 @@ service ServerService {
description: "Returns current PMM Server settings."
};
}
// GetReadOnlySettings returns a limited number of PMM settings that is opened to authenticated users of all roles.
rpc GetReadOnlySettings(GetSettingsRequest) returns (GetReadOnlySettingsResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

@idoqo please check CI linters

@idoqo idoqo merged commit 51d5ed3 into v3 Mar 4, 2025
32 checks passed
@idoqo idoqo deleted the PMM-12356-allow-editor-for-check-results branch March 4, 2025 07:33
idoqo added a commit that referenced this pull request Mar 5, 2025
* add new map for failed services

* add readonly settings endpoint

* update method comment

* drop retention data from readonly settings

* drop unused fields from settings proto

* use separate proto message
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.

None yet

3 participants