Skip to content

Commit

Permalink
PMM-8641 PMM v3 API breaking changes (#2635)
Browse files Browse the repository at this point in the history
* PMM-12624 Single inventory service add endpoint (#2591)

* PMM-12529 provide one AddService for all types of services

* PMM-12529 use context in transactions

* PMM-12529 remove rpc AddMySQLService

* PMM-12624 remove rpc AddMongoDBService

* PMM-12624 remove rpc AddPostgreSQLService

* PMM-12624 remove rpc AddProxySQLService

* PMM-12624 remove rpc AddHAProxyService

* PMM-12624 remove rpc AddExternalService

* PMM-12624 final cleanup

* PMM-12624 fix the API tests

* PMM-12624 add and update the API docs

* PMM-12624 fix duplicate entry in the sample payload

* PMM-12624 return straight away

* PMM-12624 rename the messages to ...Params

* PMM-12624 reorder the message fields

* Update docs/api/inventory/add-node.md

Co-authored-by: Nurlan Moldomurov <[email protected]>

---------

Co-authored-by: Nurlan Moldomurov <[email protected]>

* PMM-12681 remove deprecated node add endpoints (#2632)

* PMM-12681 remove deprecated Node/Add... endpoints

* PMM-12681 restore the Makefile

* PMM-12681 trigger CI

* PMM-12681 fix the test

* PMM-12681 rename NodeRequest to NodeParams

* PMM-12681 fix the error messages in tests

* PMM-12529 regen descriptors

* PMM-12529 take descriptors from the parent branch

* PMM-12529 regen descriptors

* PMM-12529 regen descriptors

* PMM-12673 Protobuf linters (#2612)

* PMM-12673 Replace _INVALID suffix in enums with _UNSPECIFIED

* PMM-12673 Remove unused imports

* Refactor all protobuf enums

* PMM-12673 Fix

* PMM-12673 Fix qan tests

* PMM-12673 Add service suffix to all grpc service names

* PMM-12673 Fix QAN GetReport request/response naming

* PMM-12673 Fix

* PMM-12673 Fix

* PMM-12673 Fix tests

* PMM-12673 Fix tests

* PMM-12673 Fix test

* PMM-12673 Refactor user API requests and responses

* PMM-12673 Fix tests

* PMM-12673 Fix tests

* PMM-12673 Refactor requests/responses names

* PMM-12673 Refactoring

* PMM-12673 Fix

* PMM-12673 Fix

* PMM-12673 Fix

* PMM-12673 Refactoring

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Fix

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Restructure

* PMM-12673 Fix

* PMM-12673 Configure buf lint, setup CI action

* PMM-12673 Cleanup

* PMM-12673 Fix CI

* PMM-12673 Rename

* PMM-12673 Trigger API lint warning

* PMM-12673 Remove redundant go_package option

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Refactoring

* PMM-12673 Fix buf lint in CI

* PMM-12673 Fix

* PMM-12673 add debug data

* PMM-12673 Add debug data [skip ci]

* PMM-12673 Trigger CI

* PMM-12673 Debug

* PMM-12673 Remove debug data

* PMM-12673 Refactoring

* PMM-12673 Fix some linter warnings

* PMM-12673 Fix test

* Update docs/managed/update-process.md

* Update api/buf.yaml

Co-authored-by: Alex Demidoff <[email protected]>

* PMM-12673 Fix API tests

* Fix import allias

* PMM-12673 Post-merge fix

---------

Co-authored-by: Alex Demidoff <[email protected]>

* PMM-12646 Exclude inventory API from public spec (#2644)

* PMM-12646 Exclude inventory API from public API spec

* PMM-12646 Trigger CI

* PMM-6722 Preserve empty JSON fields in API responses (#2645)

* PMM-6722 enable 'EmitUnpopulated' serialization option

* PMM-6722 Add API test

* PMM-6722 Add license header

* PMM-6722 Fix linter

* PMM-6722 Fix API tests

* PMM-6722 Fix API test

* PMM-6722 Fix API test

* PMM-6722 Fix API tests

* Post-merge fixes

* Cleanup

* ci: trigger the build

* Fix after merge

* Fix after merge

* PMM-12624 single inventory agents add endpoint (#2722)

* PMM-12624 migrate to a single exporter/add endpoint

* PMM-12624 update descriptors to silence errors

* PMM-12624 upgrade mongo to at least 4.4

* PMM-12624 revert proto fields renumbering

* PMM-12624 rename AddExporter to AddAgent

* PMM-12624 add Agents to refactoring

* PMM-12624 make gen

* PMM-12624 rename addExporter to addAgent

* PMM-12624 add the documentation

* PMM-12624 make grpc methods private

* PMM-8019 Support partial updates of settings and other entities (#2705)

* PMM-8019 Get rid of enable/disable flags in settings

* PMM-8019 Fixes

* PMM-8019 Fix

* PMM-8019 Cleanup

* PMM-8019 Fix tests

* PMM-8019 Fixes

* PMM-8019 Fix migrations order

* PMM-8019 Fix DB migrations

* PMM-8019 Fix tests

* PMM-8019 Update docs

* PMM-8019 Fix

* PMM-8019 Make check enabling toogle optional

* PMM-8019 Make role update params optional

* PMM-8019 Fix API tests

* PMM-8019 Use optional fields for tour flags

* PMM-8019 Use optionals instead of wrappers in API where it's possible

* PMM-8019 Comments

* PMM-8019 Fix tests

* PMM-8019 Fix linters

* PMM-8019 Fix

* PMM-12678 Reset protobuf field nums, remove all deprecated stuff from API (#2733)

* PMM-12678 Reorder protobuf fields

* PMM-12678 Fix tests

* PMM-12678 Mark some fileds as reserved

* PMM-12678 Cleanup

* PMM-12678 Fix tests

* PMM-12678 Fix tests

* PMM-12678 Cleanup

* PMM-12678 Cleanup

* PMM-12678 Cleanup

* PMM-12678 Cleanup

* PMM-12678 Fix mocks

* PMM-12678 Fix proto fields numbering

* PMM-12677 remove STT naming (#2779)

* PMM-12677: rename all stt usages to advisors

* rename stt in query

* PMM-12677 fix migrations (#2812)

* add null check to values before re-use

We try to re-use existing values for disabled checks and check
intervals. But it is possible these values does not exist, leading to
malformed JSON. This adds a null check, and only re-use these existing
settings if they exist.

* Update managed/models/database.go

---------

Co-authored-by: Alex Demidoff <[email protected]>

* PMM-12811 single agents change endpoint (#2777)

* PMM-12811 fix a typo

* PMM-12811 fix tests

* PMM-12811 modify agents.proto

* PMM-12811 modify agents_server and tests

* PMM-12811 fix API tests

* PMM-12811 fix linter warning

* PMM-12811 increase container wait time

* PMM-12811 print docker logs on failure

* PMM-12811 increase the container wait time again

* PMM-12811 try exit-code param for container launch

* PMM-12811 check the container exit code

* PMM-12811 launch pmm w/o waiting

* PMM-12811 launch the container manually

* PMM-12811 simplify, remove redundant methods

* PMM-12811 rename exporter to agent in proto

* PMM-12811 document the change

* PMM-12811 fix API tests

* PMM-12811 fix platform_test.go

* PMM-12811 prefer a single enable boolean vs paired

* PMM-12811 make custom_labels map optional

* PMM-12811 fix Advisor params

* PMM-12811 get rid of remove_custom_labels field

* PMM-12811 remove a duplicate test

* PMM-12811 follow up on review

* PMM-12811 pass context to changeAgent

* PMM-12811 move tableCount to MysqldExporter

* PMM-12811 pass context around, fix tests

* PMM-12811 add an annotation about one param

* PMM-12811 fix Azure test

* PMM-12677 stt naming cleanup (#2805)

* update tests

* rename security checks to advisor checks

* update test files

* update route

* PMM-12836 restructure management API (#2814)

* PMM-12836 restructure alerting api

* PMM-12836 restucture api-tests

* PMM-12836 modify alerting for swagger

* PMM-12836 restructure backup api

* PMM-12836 make gen after rebase

* PMM-12836 restructure bump api

* PMM-12836 remove outdated json specs

* PMM-12836 regenerate proto specs

* PMM-12836 restructure role api

* PMM-12836 restructure advisors api

* PMM-12836 restructure qan api, promote to v1

* PMM-12836 add qan.v1 to the main swagger spec

* PMM-12836 restructure azure api

* PMM-12836 restructure actions api

* PMM-12836 fix lint errors

* PMM-12836 fix api-tests

* PMM-12836 regenerate code

* PMM-12836 remove grpc wrappers for node & mysql

* PMM-12836 fix the comment

* PMM-12836 remove grpc wrappers for mongo, pg and proxysql services

* PMM-12836 make platform API lowercase

* PMM-12836 remove grpc wrapper for annotation service

* PMM-12836 remove the comments

* PMM-12836 fix lint error

* PMM-12836 revert QAN migration to one service

* chore: run make gen

* chore: fix linter errors

* chore: fix tests

* chore: fix linter errors

* chore: fix more linter errors

* chore: fix more linter errors

* PMM-12913 Use regular http verbs (#2828)

* PMM-12913 fix logrus' field name for dump

* PMM-12913 refactor empty proto messages

* PMM-12913 make /updates and /settings lowercase

* PMM-12913 fix linter errors

* PMM-12913 merge all QAN endpoints into one service

* PMM-12913 update QAN endpoints with summary and description

* PMM-12913 fix linter errors

* PMM-12913 merge mongodb to management/service

* PMM-12913 merge proxysql to management/service

* PMM-12913 merge postgresql & mysql to management/service

* PMM-12913 merge external, haproxy & rds to management/service

* PMM-12913 merge anotation & node to management/service

* PMM-12913 merge MgmtNode to MgmtService

* PMM-12913 merge MgmtAgent to MgmtService

* PMM-12913 merge Azure to MgmtService

* PMM-12913 rename Service to ManagementService

* PMM-12913 provide a migration doc

* PMM-12913 rename MgmtService to ManagementServiceV1Beta

* Revert "PMM-12913 refactor empty proto messages"

This reverts commit a4e9545.

* PMM-12913 revert the addition of google.protobuf.Empty

* PMM-12913 remodel some APIs

* PMM-12913 move table_count to the beginning of rds.proto

* PMM-12913 rename RestoreHistoryService to RestoreService

* PMM-12913 fix the message name

* PMM-12913 move /v1/backup/Backups/Restore  to RestoreService

* PMM-12913 merge changes from parent

* PMM-12913 fix the linter error

* PMM-12913 remove table_count from rds.proto

* PMM-12913 fix null pointer ref in supervisord.go

* chore: remove unused imports in proto files

* chore: run make gen

* test

* Minor readibility improvements

* Linguistic review

* Linguistic review

* Merge branch 'v3' into v3-api-breaking-changes

* PMM-13090: Sync environment variables with v3-api-breaking-changes (#2982)

* PMM-12619: Make PMM environment variables more consistent (#2857)

* refactored environment variables

* update migration doc

* replace test line

* drop no lint rule

* fix parser tests

* re-order table values

* remove deprecated env variables

* fix tests

* use singluar advisor

* introduce PMM_DEV_ prefix for dev-related variables

* clean up environment variables

* drop printf

* drop unused variable

* update tests

* add notes for removed variable

* update oauth variables

* update changed variable list

* update variable check validation

* refactor tests

* surpress linter error

* fix docker readme

* restore error checks

* include backup management variable

* Update for grammar

* PMM-13020 Drop identifier prefixes (#2970)

* PMM-13020 Add a db migration

* PMM-13020 strip agent_id, node_id, action_id

* PMM-13020 drop service_id

* PMM-13020 drop machine_id

* PMM-13020 drop location_id

* Update agent/agents/mysql/slowlog/slowlog_test.go

Co-authored-by: Nurlan Moldomurov <[email protected]>

* PMM-13020 fix wrong strip-offs

* PMM-13020 fix text output spacing

* PMM-13020 fix text output spacing

* PMM-13020 drop role_id migration

* PMM-13020 fix text output spacing

* PMM-13020 fix wrong agent_id

* PMM-13020 fix slowlog jsons

* PMM-13020 fix scrape config and rds tests

* PMM-13020 fix scrape config test

* PMM-13020 fix victoriametrics test

* PMM-13020 fix node_helpers test

* PMM-13020 fix grafana test (name was too long)

* PMM-13020 strip prefixes in qan fixtures

* PMM-13020 fix QAN tests

* PMM-13020 cut the prefix when reading params

* PMM-13020 fix the job_name in vm tests

* PMM-13020 update the docs

---------

Co-authored-by: Nurlan Moldomurov <[email protected]>

* Merge branch 'v3' into v3-api-breaking-changes

* fix: node.proto and node_test

* fix: linter errors

* PMM-12913 Migrate api endpoints to REST (#2880)

* PMM-12913 Add a resource name to endpoints ending with /v1

* PMM-12913 fix the linter error (goconst)

* PMM-12913 migrate /v1/version

* PMM-12913 migrate /v1/readyz

* PMM-12913 all endpoints begin with `/v1`

* PMM-12913 make gen

* PMM-12913 migrate /v1/settings/Get

* PMM-12913 fix unit test fo /v1/server/settings

* PMM-12913 migrate /v1/settings/Change

* PMM-12913 migrate /v1/AWSInstanceCheck

* PMM-12913 fix alerting api tests

* PMM-12913 fix ManagementService being disabled

* PMM-12913 fix backup API tests

* PMM-12913 temporarily allow /v1/version

* PMM-12913 update admins' readme

* PMM-12913 fix the Agent connect path in auth

* PMM-12913 fix wrong grpc paths

* PMM-12913 fix the port in readme

* PMM-12913 fix some grpc paths

* PMM-12913 add check-agent-setup script

* PMM-12913 migrate /v1/server/leaderHealthCheck endpoint

* PMM-12913 migrate /v1/settings/Get

* PMM-12913 fix the api test

* PMM-12913 migrate /v1/updates/Start

* PMM-12913 fix actions

* PMM-12913 migrate /logs.zip

* PMM-12913  fix auth_server_test

* PMM-12913 migrate /v1/updates/Status

* PMM-12913 migrate /v1/users

* PMM-12913 migrate /v1/inventory/Agents

* PMM-12913 fix logs_test

* PMM-12913 use an interface for commonAgentParams

* PMM-12913 re-add `/agent_id/`

* PMM-12913 migrate /v1/inventory/Agents/Get

* PMM-12913 migrate /v1/inventory/Agents/Remove

* PMM-12913 migrate /v1/inventory/Agents/GetLogs

* PMM-12913 migrate /v1/inventory/Nodes

* PMM-12913 migrate /v1/inventory/Services

* PMM-12913 fix tests for /v1/inventory/services

* PMM-12913 migrate /v1/management/Service

* PMM-12913 migrate /v1/actions

* PMM-12899 migrate /v1/alerting endpoints

* PMM-12899 migrate /v1/advisors emdpoints

* PMM-12899 rename BackupsService to BackupService

* PMM-12899 migrate /v1/backup/Artifacts

* PMM-12899 migrate /v1/backup/Backups

* PMM-12913 refactor /v1/backups/locations

* PMM-12913 refactor /v1/backups/restores

* PMM-12913 refactor /v1/dumps

* PMM-12913 move dump and role API to v1beta1 folder

* PMM-12913 refactor /v1/role, rename tp /v1/accesscontrol

* PMM-12913 refactor /v1/management/nodes {Get,LIst}

* PMM-12913 refactor /v1/management/services/List

* PMM-12913 refactor /v1/management/services/azure

* PMM-12913 refactor /v1/management/agent/List

* PMM-12913 migrate /v1/platform

* PMM-12913 migrate /v1/qan

* PMM-12913 refactor the primitive types in alerting.proto

* PMM-12913 fix a few linter errors

* PMM-12913 do not show CollectorService in swagger

* PMM-12913 split /backup/GetLogs up to two endpoints

* PMM-12913 fix restore tests

* PMM-12913 update migration examples

* PMM-12913 fix /v1/qan/metrics:getFilters being unavailable

* PMM-12913 fix the linter error

* PMM-12913 fix /v1/qan/metrics:getFilters test

* PMM-12913 update migration examples

* PMM-12913 fix an iteration bug

* PMM-12913 fix an issue with QAN failing to persist data

* PMM-12913 remove debug output

* PMM-12913 auth_server fixes for QAN

* PMM-12913 fix agent API tests

* PMM-12913 fix the QAN URL routing issue

* PMM-12913 remove the unnecessary PMM_NICER_API

* PMM-12913 add the routing error handler

* PMM-12913 minor syntax fixes

* PMM-12913 remove PMM_LESS_LOG_NOISE envvar

* PMM-12913 remove ID normalizers

* PMM-12913 update the migration doc

* PMM-12913 better error handling

* PMM-12913 fix /v1/backups/artifacts/{artifact_id} delete endpoint

* PMM-12913 simplify setup.py

* PMM-12913 fix a linter error

* PMM-12913 merge ArtifactService with BackupService

* Revert "PMM-12913 better error handling"

This reverts commit add2d3f.

* PMM-12913: regenerate code, fix Makefile.include

* PMM-12913: fix node_test

* PMM-12913: fix UnregisterNode method name

* PMM-12857 fix API tests

* PMM-12857 fix agent tests

* PMM-12857 fix auth_test and clean up readyz_test

* PMM-12857 fix settings_test

* PMM-12857 fix auth_test

* PMM-13054 fix the backup test

* PMM-13054 fix advisor tests

* PMM-13054 fix auth_server tests again

* PMM-13054 remove redundant functionality

* PMM-13054 fix actions tests

* PMM-13054 minor cleanup

* PMM-13054 disable platform tests until the env is ready

* PMM-13054 fix advisors_test

* PMM-13054 try better error msg to debug failures

* PMM-13054 fix alerting_test

* Revert "PMM-13054 try better error msg to debug failures"

This reverts commit 862ec3b.

---------

Co-authored-by: Alex Demidoff <[email protected]>
Co-authored-by: Nurlan Moldomurov <[email protected]>
Co-authored-by: Michael Okoko <[email protected]>
Co-authored-by: Catalina A <[email protected]>
  • Loading branch information
5 people authored Jul 18, 2024
1 parent 8271136 commit ee86153
Show file tree
Hide file tree
Showing 1,197 changed files with 285,984 additions and 327,284 deletions.
13 changes: 2 additions & 11 deletions .devcontainer/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def install_packages():
run_commands([
"dnf install -y gcc git make pkgconfig \
vim \
mc tmux psmisc lsof which iproute \
mc tmux psmisc lsof which iproute diffutils \
bash-completion \
man man-pages \
openssl-devel \
Expand All @@ -47,16 +47,7 @@ def install_go():

go_version = str(subprocess.check_output("gimme -r " + GO_VERSION, shell=True).strip().decode())

if GO_VERSION == "tip":
run_commands([
"mkdir $HOME/git_source",
"wget https://github.com/git/git/archive/refs/tags/v2.34.4.tar.gz -O $HOME/git.tar.gz",
"tar -xzf $HOME/git.tar.gz -C $HOME/git_source --strip-components 1",
"cd $HOME/git_source && make configure && ./configure --prefix=/usr && make all && make install",
])
gimme_go_dir = "go"
else:
gimme_go_dir = "go{go_version}.linux.amd64".format(go_version=go_version)
gimme_go_dir = "go{go_version}.linux.amd64".format(go_version=go_version)

run_commands([
"gimme " + go_version,
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
strategy:
matrix:
images:
- { mysql: 'mysql:5.6', mongo: 'mongo:4.2', postgres: 'postgres:10', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'mysql:5.6', mongo: 'mongo:4.4', postgres: 'postgres:10', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'mysql:5.7', mongo: 'mongo:4.4', postgres: 'postgres:11', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'mysql:8.0', mongo: 'mongo:4.4', postgres: 'postgres:12', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'mysql:8.0', mongo: 'mongo:4.4', postgres: 'postgres:13', pmm_server: 'perconalab/pmm-server:3-dev-latest' }

# Percona + latest PMM Server release
- { mysql: 'percona:5.6', mongo: 'percona/percona-server-mongodb:4.2', postgres: 'perconalab/percona-distribution-postgresql:11', pg_libs: 'pg_stat_statements,pg_stat_monitor', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'percona:5.6', mongo: 'percona/percona-server-mongodb:4.4', postgres: 'perconalab/percona-distribution-postgresql:11', pg_libs: 'pg_stat_statements,pg_stat_monitor', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'percona:5.7', mongo: 'percona/percona-server-mongodb:4.4', postgres: 'perconalab/percona-distribution-postgresql:12.8-pg_stat', pg_libs: 'pg_stat_statements,pg_stat_monitor', pmm_server: 'perconalab/pmm-server:3-dev-latest' }
- { mysql: 'percona:8.0', mongo: 'percona/percona-server-mongodb:4.4', postgres: 'perconalab/percona-distribution-postgresql:13.5-pg_stat', pg_libs: 'pg_stat_statements,pg_stat_monitor', pmm_server: 'perconalab/pmm-server:3-dev-latest' }

Expand Down Expand Up @@ -114,8 +114,8 @@ jobs:
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
echo "--- Environment variables ---"
env | sort
echo "--- GO Environment ---"
go env | sort
git status
2 changes: 1 addition & 1 deletion .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
run: |
docker run -e PMM_SERVER_URL=${{env.PMM_URL}} \
-e PMM_RUN_UPDATE_TEST=0 \
-e PMM_RUN_STT_TESTS=0 \
-e PMM_RUN_ADVISOR_TESTS=0 \
--name pmm-api-tests \
--network host \
percona/pmm-api-tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
run: echo "machine github.com login percona-robot password ${{ secrets.ROBOT_TOKEN }}" > $HOME/.netrc

- name: Set up Go release
if: matrix.go.version != 'tip'
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,26 @@ jobs:
- name: Run go-sumtype
run: bin/go-sumtype ./...

- name: Run linters
- name: Run API linter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$(bin/buf lint -v api); code="$?"; test "$code" -eq 0; then
echo "$out"
exit 0
fi
echo "API linter exited with code: $code"
echo "$out"
## buf uses exit code 100 for linter warnings
if [ "$code" -ne 100 ] || ${{ github.event.pull_request == null }}; then
exit $code
fi
# One may need to suppress passing to reviewdog because of https://github.com/reviewdog/reviewdog/issues/1696
echo "$out" | bin/reviewdog -f=buf -reporter=github-pr-review -fail-on-error=true
- name: Run code linters
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
Expand All @@ -92,20 +111,20 @@ jobs:

- name: Run go-consistent
env:
COMMAND: 'bin/go-consistent -pedantic -exclude "tests" ./...'
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$( ${{ env.COMMAND }} ); exit_code=$?; [ $exit_code -ne 0 ]; then
if [ $exit_code -gt 1 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
else
echo "$out" | bin/reviewdog -f=go-consistent -reporter=github-pr-review -fail-on-error=true
fi
else
if out=$(bin/go-consistent -pedantic -exclude "tests" ./...); exit_code=$?; [ $exit_code -eq 0 ]; then
echo "$out"
exit 0
fi
if [ $exit_code -gt 1 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
fi
echo "$out" | bin/reviewdog -f=go-consistent -reporter=github-pr-review -fail-on-error=true
- name: Test common API
run: make test-common

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
- name: Launch PMM Server (see docker-compose.yml)
run: |
make env-compose-up # the container workdir is /root/go/src/github.com/percona/pmm
docker exec -t pmm-server id -Z || :
docker logs pmm-server
- name: Mark the root directory of pmm as safe
Expand Down Expand Up @@ -123,7 +124,8 @@ jobs:
docker exec pmm-server go env | sort
docker exec pmm-server supervisorctl status || true
services=$(docker exec pmm-server supervisorctl status | awk '{print $1}')
while IFS= read -r service; do
services=(`echo ${services}`)
for service in "${services[@]}"; do
echo "Logs for $service:"
docker exec pmm-server supervisorctl tail $service
done <<< "$services"
done
11 changes: 8 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ linters-settings:
cyclop:
max-complexity: 30

inamedparam:
# Skips check for interface methods with only a single parameter.
skip-single-param: true

depguard:
rules:
main:
Expand Down Expand Up @@ -81,11 +85,11 @@ linters:
enable-all: true
disable:
# keep the rules sorted alpahbetically
- deadcode # unmaintained, we leverage `unused`
- dupl # we can't avoid duplicating code
- execinquery # false positives only
- exhaustivestruct # too annoying
- exhaustruct # too many files to fix/nolint
- deadcode # unmaintained, we leverage `unused`
- dupl # we can't avoid duplicating code
- funlen # useless
- gochecknoglobals # mostly useless
- gochecknoinits # we use init functions
Expand All @@ -100,7 +104,7 @@ linters:
- maligned # deprecated
- nlreturn # too annoying
- nosnakecase # deprecated
- protogetter # mostly useless
- protogetter # we need direct access to proto fields
- rowserrcheck # disabled because of generics
- scopelint # too many false positives
- structcheck # replaced by unused
Expand Down Expand Up @@ -145,6 +149,7 @@ issues:
- forcetypeassert # for tests' brevity sake
- funlen # tests may be long
- gocognit # triggered by subtests
- goconst # not critical for tests
- gomnd # tests are full of magic numbers
- ireturn # we have exceptions, so need to silence them in tests
- lll # tests often require long lines
Expand Down
3 changes: 1 addition & 2 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ packages:
interfaces:
agentsRegistry:
agentsStateUpdater:
authProvider:
checksService:
connectionChecker:
grafanaClient:
Expand All @@ -47,7 +46,7 @@ packages:
serviceInfoBroker:
versionCache:
victoriaMetricsClient:
github.com/percona/pmm/managed/services/management/alerting:
github.com/percona/pmm/managed/services/alerting:
interfaces:
grafanaClient:
github.com/percona/pmm/managed/services/management/backup:
Expand Down
85 changes: 59 additions & 26 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ gen-api: ## Generate PMM API

bin/buf generate -v api

for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/alerting api/managementpb/backup api/managementpb/dump api/managementpb/azure api/managementpb/role api/qanpb api/managementpb/agent api/managementpb/node api/managementpb/service api/platformpb api/userpb; do \
SPECS="\
api/agentlocal/v1 \
api/server/v1 \
api/user/v1 \
api/inventory/v1 \
api/management/v1 \
api/management/v1/service \
api/actions/v1 \
api/advisors/v1 \
api/alerting/v1 \
api/backup/v1 \
api/dump/v1beta1 \
api/accesscontrol/v1beta1 \
api/qan/v1 \
api/platform/v1"; \
for API in $$SPECS; do \
set -x ; \
bin/swagger mixin $$API/json/header.json $$API/*.swagger.json --output=$$API/json/$$(basename $$API).json --keep-spec-order; \
bin/swagger flatten --with-flatten=expand --with-flatten=remove-unused $$API/json/$$(basename $$API).json --output=$$API/json/$$(basename $$API).json ; \
Expand All @@ -67,37 +82,40 @@ gen-api: ## Generate PMM API
--additional-initialism=ha ; \
done

# generate public API spec, omit agentlocalpb (always private),
# generate public API spec, omit agentlocal and inventory (always private),
# as well as a number of protos that are in beta (not v1 yet, they all go to a similar call below)
bin/swagger mixin --output=api/swagger/swagger.json \
api/swagger/header.json \
api/serverpb/json/serverpb.json \
api/userpb/json/userpb.json \
api/inventorypb/json/inventorypb.json \
api/managementpb/json/managementpb.json \
api/managementpb/backup/json/backup.json \
api/managementpb/alerting/json/alerting.json
api/server/v1/json/v1.json \
api/user/v1/json/v1.json \
api/inventory/v1/json/v1.json \
api/management/v1/json/v1.json \
api/actions/v1/json/v1.json \
api/alerting/v1/json/v1.json \
api/advisors/v1/json/v1.json \
api/backup/v1/json/v1.json \
api/qan/v1/json/v1.json \
api/platform/v1/json/v1.json
bin/swagger validate api/swagger/swagger.json

bin/swagger-order --output=api/swagger/swagger.json api/swagger/swagger.json

# generate API spec with all PMM Server APIs (omit agentlocalpb)
# generate API spec with all PMM Server APIs (omit agentlocal)
bin/swagger mixin --output=api/swagger/swagger-dev.json \
api/swagger/header-dev.json \
api/serverpb/json/serverpb.json \
api/userpb/json/userpb.json \
api/inventorypb/json/inventorypb.json \
api/managementpb/json/managementpb.json \
api/managementpb/alerting/json/alerting.json \
api/managementpb/backup/json/backup.json \
api/managementpb/dump/json/dump.json \
api/managementpb/azure/json/azure.json \
api/managementpb/role/json/role.json \
api/managementpb/agent/json/agent.json \
api/managementpb/node/json/node.json \
api/managementpb/service/json/service.json \
api/qanpb/json/qanpb.json \
api/platformpb/json/platformpb.json
api/server/v1/json/v1.json \
api/user/v1/json/v1.json \
api/inventory/v1/json/v1.json \
api/management/v1/json/v1.json \
api/actions/v1/json/v1.json \
api/alerting/v1/json/v1.json \
api/advisors/v1/json/v1.json \
api/backup/v1/json/v1.json \
api/dump/v1beta1/json/v1beta1.json \
api/accesscontrol/v1beta1/json/v1beta1.json \
api/qan/v1/json/v1.json \
api/platform/v1/json/v1.json

bin/swagger validate api/swagger/swagger-dev.json

bin/swagger-order --output=api/swagger/swagger-dev.json api/swagger/swagger-dev.json
Expand All @@ -124,7 +142,21 @@ clean: clean_swagger ## Remove generated files
find api -name '*.pb.gw.go' -print -delete
find api -name '*.validate.go' -print -delete

for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/alerting api/managementpb/backup api/management/dump api/managementpb/role api/managementpb/agent api/managementpb/node api/managementpb/service api/qanpb api/platformpb ; do \
SPECS="\
api/agentlocal/v1 \
api/server/v1 \
api/user/v1 \
api/inventory/v1 \
api/management/v1 \
api/actions/v1 \
api/alerting/v1 \
api/advisors/v1 \
api/backup/v1 \
api/dump/v1beta1 \
api/accesscontrol/v1beta1 \
api/qan/v1 \
api/platform/v1"; \
for API in $$SPECS; do \
rm -fr $$API/json/client $$API/json/models $$API/json/$$(basename $$API).json ; \
done
rm -f api/swagger/swagger.json api/swagger/swagger-dev.json
Expand All @@ -136,8 +168,9 @@ api-test: ## Run API tests on dev env.
go test -count=1 -race -p 1 -v ./api-tests/... -pmm.server-insecure-tls

check: ## Run required checkers and linters
LOG_LEVEL=error bin/golangci-lint run ; \
bin/go-sumtype ./... ; \
bin/buf lint -v api
LOG_LEVEL=error bin/golangci-lint run
bin/go-sumtype ./...
bin/go-consistent -pedantic ./...

check-license: ## Run license header checks against source files
Expand Down
11 changes: 6 additions & 5 deletions admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ git, make, curl, go, gcc, pmm-server, pmm-agent

## Local setup
### To run pmm-admin commands
- Run [pmm-server docker container](https://hub.docker.com/r/percona/pmm-server) or [pmm-managed](https://github.com/percona/pmm-managed).
- Run [pmm-server docker container](https://hub.docker.com/r/percona/pmm-server) or [pmm-managed](https://github.com/percona/pmm/tree/main/managed).
- Run pmm-agent `cd ../agent`.
- Run pmm-admin commands.
```shell script
Expand All @@ -18,8 +18,9 @@ git, make, curl, go, gcc, pmm-server, pmm-agent

You should see something like this
```shell script
Agent ID: /agent_id/fcbe3cb4-a95a-43f4-aef5-c3494caa5132
Node ID : /node_id/77be6b4d-a1d9-4687-8fae-7acbaee7db47
Agent ID: fcbe3cb4-a95a-43f4-aef5-c3494caa5132
Node ID : 77be6b4d-a1d9-4687-8fae-7acbaee7db47
Node name: mysql-server-test-1
PMM Server:
URL : https://127.0.0.1:443/
Expand All @@ -31,10 +32,10 @@ PMM-agent:
Latency : 211.026µs
Agents:
/agent_id/3329a405-8a5d-4414-9890-b6ae4209e0cc NODE_EXPORTER RUNNING
3329a405-8a5d-4414-9890-b6ae4209e0cc NODE_EXPORTER RUNNING 40001
```
It means that everything works.

## Testing
pmm-admin doesn't require setting-up environment.
pmm-admin doesn't require setting-up an environment.
Run `make test` to run tests.
6 changes: 3 additions & 3 deletions admin/agentlocal/agentlocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
httptransport "github.com/go-openapi/runtime/client"
"github.com/sirupsen/logrus"

"github.com/percona/pmm/api/agentlocalpb/json/client"
agentlocal "github.com/percona/pmm/api/agentlocalpb/json/client/agent_local"
"github.com/percona/pmm/api/agentlocal/v1/json/client"
agentlocal "github.com/percona/pmm/api/agentlocal/v1/json/client/agent_local_service"
)

// SetTransport configures transport for accessing local pmm-agent API.
Expand Down Expand Up @@ -100,7 +100,7 @@ func GetRawStatus(ctx context.Context, requestNetworkInfo NetworkInfo) (*agentlo
Context: ctx,
}

res, err := client.Default.AgentLocal.Status(params)
res, err := client.Default.AgentLocalService.Status(params)
if err != nil {
if res == nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion admin/cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func getDefaultKongOptions(appName string) []kong.Option {

var defaultMachineID string
if nodeinfo.MachineID != "" {
defaultMachineID = "/machine_id/" + nodeinfo.MachineID
defaultMachineID = nodeinfo.MachineID
}

mysqlQuerySources := []string{
Expand Down
Loading

0 comments on commit ee86153

Please sign in to comment.