This repository was archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
PMM-4013 SHOW TABLE Action. #207
Closed
Closed
Changes from all commits
Commits
Show all changes
118 commits
Select commit
Hold shift + click to select a range
33c42c4
PMM-3978 Update deps.
e8c00f9
PMM-3978 Actions is working.
0a1403c
PMM-3978 Fix CI errors.
6a5820a
Merge branch 'PMM-2.0' into PMM-3978-actions
eb26648
PMM-3978 Merge with pmm-2.0.
08e06ac
PMM-3978 Update deps.
df60a8f
PMM-3978 handle agent request.
da96430
PMM-3978 update deps.
6557ba2
PMM-3978 Small rename.
3363768
Merge branch 'PMM-2.0' into PMM-3978-actions
adcda94
PMM-3978 Update deps.
f091dff
PMM-3978 Working actions.
e955704
PMM-3978 Workarround 'RunAction'.
145fb8b
PMM-3978 fix CI.
baf7133
PMM-3978 update deps and API.
1d1342b
Merge branch 'PMM-2.0' into PMM-3978-actions
953d740
PMM-3978 update deps.
afc8575
PMM-3978 api fix.
e469e7f
PMM-3978 fix tests.
2d68558
PMM-3978 fix API and deps.
fceb156
Merge branch 'PMM-2.0' into PMM-3978-actions
0c031b5
PMM-3978 fix deps.
735a485
PMM-3978 fix IDs.
da5781a
PMM-3978 fix IDs.
528623d
PMM-3978 Moving to Aleksi API.
3bc56c9
PMM-3978 Fix stupid linter.
64ed920
Merge branch 'PMM-2.0' into PMM-3978-actions
3e81817
PMM-3978 Fix deps.
c58934d
PMM-3978 Disable not working linter.
1d5201a
PMM-3978 Make it works.
8375669
PMM-3978 Update deps.
8ec1eb3
Merge branch 'PMM-2.0' into PMM-3978-actions
3393b2d
PMM-3978 Update deps.
1169c53
PMM-3978 Fix pmm agent selection.
560fb9c
PMM-3978 Fix golang-ci lint suggestions.
8605426
Merge branch 'PMM-2.0' into PMM-3978-actions
AlekSi 55ecc30
PMM-3978 Fixing PR suggestions.
a85f90d
PMM-3978 Fixing PR suggestions.
aaa93d1
PMM-3978 Fixing PR suggestions (Generate mocks).
a8ec2a8
PMM-3978 revert prometheus config.
19ffc51
PMM-3978 fix pointers in storage.
db625e9
PMM-3978 fix PR suggestions.
f11d5d7
PMM-3978 fix PR suggestions.
183d98b
PMM-3978 fix PR SendRequest method.
4a3d01f
PMM-3978 remove dot.
ec7d149
PMM-3978 comment.
f98bbe4
PMM-3978 tests.
47ea099
Merge branch 'PMM-2.0' into PMM-3978-actions
bc909b2
PMM-3978 make init gen format.
e8363bf
PMM-3832 Start working on MySQL Explain Action.
daf25ee
PMM-3832 TODO Comment.
44af406
PMM-3832 Rethink actions implementation and dependency graph.
9d2101b
PMM-3832 Small refactoring.
946a79f
PMM-3832 Fix ids.
297de25
PMM-3832 Refactor interfaces.
3855e1e
PMM-3832 Fix error.
f9f6295
PMM-3832 Refactoring.
a34633e
PMM-3832 Abstract PMMAgentID resolving.
1644470
PMM-3832 Update deps.
7d9c2a1
PMM-3832 Add resolver to main.
3857949
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
a39da0c
PMM-3832 Create business layer.
1c253da
PMM-3832 PtSummary parameters.
0a7a2fa
PMM-3832 PtMysqlSummary remove parameter.
577f93a
PMM-3832 Add comments.
77d5993
PMM-3832 Fix PMM-agent ID extracting and nil pointer error.
BupycHuk 80d77cc
PMM-3832 Refactoring to simpler and idiomatic code.
0ee8eb4
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
dd21319
PMM-3832 Comment fix.
cd583e6
PMM-3832 linter errors fix.
5f504e8
PMM-3832 error messages.
1a6a0e3
PMM-3832 linter fix.
c4918ef
PMM-3832 move package because of test restrictions.
19a2e84
PMM-3832 move action result call to factory.
a1ca4ff
PMM-3832 fix linter.
ef01e91
PMM-3832 Remove all interfaces to "avoid indirection".
06e59aa
PMM-3832 "Simplify" code.
ef61d15
PMM-3832 comments.
b308082
PMM-3832 comments.
156ef58
PMM-3832 linter fix.
cea9bc8
PMM-3832 linter fix and moving functions.
6bcc507
PMM-3832 More "simplify" and move storage to Postgres.
642e662
PMM-3832 More "simplify" and move storage to Postgres.
ed6dfbb
PMM-3832 Fix table name.
2c33d38
PMM-3832 linter fix.
caac617
PMM-3832 linter fix.
30728b9
PMM-3832 Add database parameter to mysql dsn.
69ab029
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
e85dcda
PMM-3832 merge with pmm-2.0.
5cfc5ce
PMM-3832 Fix some suggestions.
15e27a0
PMM-3832 Fixing.
5209ff8
PMM-3832 Fix codereview suggestions.
735fcb5
PMM-3832 CodeReview suggestions.
1a9181a
PMM-3832 CodeReview fix.
a6d22b9
PMM-3832 codereview fix.
b5dc9b6
PMM-3832 Tests for helpers.
0acd8d4
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
7ebb1a7
PMM-3832 Tests.
105dd17
PMM-3832 Fix test.
34827b8
PMM-3832 Fix error types and linter warnings.
713e8f8
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
e2facd7
PMM-3832 Fix errors.
8af8689
PMM-3832 Fix suggestions.
1cbd33d
PMM-3832 Fix.
6ae3988
PMM-3832 fix.
ffaff82
PMM-3832 fix.
adce543
PMM-3832 dsn helper test.
9739e5c
PMM-3832 Test for wrong DSN.
BupycHuk 36a3b03
PMM-3832 fix test names.
b358afd
Merge branch 'PMM-3832-test-for-DSN' into PMM-3832-mysql-explain
e59cef3
PMM-3832 fix DSN algorithm.
727044d
PMM-3832 fix DSN algorithm.
f65cfe8
PMM-3832 fix.
04038e7
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
AlekSi 5799f03
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
AlekSi 93a78a2
PMM-3541 Remove dependency between inventory and management services …
AlekSi a05ffd8
Merge branch 'PMM-2.0' into PMM-3832-mysql-explain
8bed1a9
PMM-4013 show table action.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ | |
| /bin/ | ||
| cover.out | ||
| crosscover.out | ||
| packages.png | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // pmm-managed | ||
| // Copyright (C) 2017 Percona LLC | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| package models | ||
|
|
||
| import ( | ||
| "github.com/google/uuid" | ||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
| "gopkg.in/reform.v1" | ||
| ) | ||
|
|
||
| // CreateActionResult stores an action result in action results storage. | ||
| func CreateActionResult(q *reform.Querier, pmmAgentID string) (*ActionResult, error) { | ||
| result := &ActionResult{ID: "/action_id/" + uuid.New().String(), PmmAgentID: pmmAgentID} | ||
| if err := q.Insert(result); err != nil { | ||
| return result, status.Errorf(codes.FailedPrecondition, "Couldn't create ActionResult, reason: %v", err) | ||
| } | ||
|
|
||
| return result, nil | ||
| } | ||
|
|
||
| // ChangeActionResult updates an action result in action results storage. | ||
| func ChangeActionResult(q *reform.Querier, actionID, pmmAgentID, aError, output string, done bool) error { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. U1000: func |
||
| result := &ActionResult{ | ||
| ID: actionID, | ||
| PmmAgentID: pmmAgentID, | ||
| Done: done, | ||
| Error: aError, | ||
| Output: output, | ||
| } | ||
| if err := q.Update(result); err != nil { | ||
| return status.Errorf(codes.FailedPrecondition, "Couldn't update ActionResult, reason: %v", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // FindActionResultByID loads an action result from storage by action id. | ||
| func FindActionResultByID(q *reform.Querier, id string) (*ActionResult, error) { | ||
| if id == "" { | ||
| return nil, status.Errorf(codes.InvalidArgument, "Couldn't get AgentResult, as id is empty.") | ||
| } | ||
|
|
||
| row := &ActionResult{ID: id} | ||
| switch err := q.Reload(row); err { | ||
| case nil: | ||
| return row, nil | ||
| case reform.ErrNoRows: | ||
| return nil, status.Errorf(codes.NotFound, "ActionResult with ID %q not found.", id) | ||
| default: | ||
| return nil, status.Errorf(codes.FailedPrecondition, "Couldn't get AgentResult, reason: %v", err) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // pmm-managed | ||
| // Copyright (C) 2017 Percona LLC | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| package models_test | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "gopkg.in/reform.v1" | ||
| "gopkg.in/reform.v1/dialects/postgresql" | ||
|
|
||
| "github.com/percona/pmm-managed/models" | ||
| "github.com/percona/pmm-managed/utils/testdb" | ||
| ) | ||
|
|
||
| func TestActionHelpers(t *testing.T) { | ||
| now, origNowF := models.Now(), models.Now | ||
| models.Now = func() time.Time { | ||
| return now | ||
| } | ||
| sqlDB := testdb.Open(t) | ||
| defer func() { | ||
| models.Now = origNowF | ||
| require.NoError(t, sqlDB.Close()) | ||
| }() | ||
|
|
||
| setup := func(t *testing.T) (q *reform.Querier, teardown func(t *testing.T)) { | ||
| db := reform.NewDB(sqlDB, postgresql.Dialect, reform.NewPrintfLogger(t.Logf)) | ||
| tx, err := db.Begin() | ||
| require.NoError(t, err) | ||
| q = tx.Querier | ||
|
|
||
| for _, str := range []reform.Struct{ | ||
| &models.ActionResult{ | ||
| ID: "A1", | ||
| PmmAgentID: "A2", | ||
| }, | ||
| } { | ||
| require.NoError(t, q.Insert(str)) | ||
| } | ||
|
|
||
| teardown = func(t *testing.T) { | ||
| require.NoError(t, tx.Rollback()) | ||
| } | ||
| return | ||
| } | ||
|
|
||
| t.Run("FindActionResultByID", func(t *testing.T) { | ||
| q, teardown := setup(t) | ||
| defer teardown(t) | ||
|
|
||
| a, err := models.FindActionResultByID(q, "A1") | ||
| require.NoError(t, err) | ||
| assert.NotEmpty(t, a.ID) | ||
|
|
||
| _, err = models.FindActionResultByID(q, "A2") | ||
| require.Error(t, err) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // pmm-managed | ||
| // Copyright (C) 2017 Percona LLC | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| package models | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "gopkg.in/reform.v1" | ||
| ) | ||
|
|
||
| //go:generate reform | ||
|
|
||
| // ActionResult describes an action result which is storing in persistent storage. | ||
| //reform:action_results | ||
| type ActionResult struct { | ||
| ID string `reform:"id,pk"` | ||
| PmmAgentID string `reform:"pmm_agent_id"` | ||
| Done bool `reform:"done"` | ||
| Error string `reform:"error"` | ||
| Output string `reform:"output"` | ||
| CreatedAt time.Time `reform:"created_at"` | ||
| UpdatedAt time.Time `reform:"updated_at"` | ||
| } | ||
|
|
||
| // BeforeInsert implements reform.BeforeInserter interface. | ||
| func (s *ActionResult) BeforeInsert() error { | ||
| now := Now() | ||
| s.CreatedAt = now | ||
| s.UpdatedAt = now | ||
| return nil | ||
| } | ||
|
|
||
| // BeforeUpdate implements reform.BeforeUpdater interface. | ||
| func (s *ActionResult) BeforeUpdate() error { | ||
| s.UpdatedAt = Now() | ||
| return nil | ||
| } | ||
|
|
||
| // AfterFind implements reform.AfterFinder interface. | ||
| func (s *ActionResult) AfterFind() error { | ||
| s.CreatedAt = s.CreatedAt.UTC() | ||
| s.UpdatedAt = s.UpdatedAt.UTC() | ||
| return nil | ||
| } | ||
|
|
||
| // check interfaces | ||
| var ( | ||
| _ reform.BeforeInserter = (*ActionResult)(nil) | ||
| _ reform.BeforeUpdater = (*ActionResult)(nil) | ||
| _ reform.AfterFinder = (*ActionResult)(nil) | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error return value of
f.Closeis not checked (fromerrcheck)