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-12624 single inventory agents add endpoint #2722

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .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 \
Copy link
Member Author

@ademidoff ademidoff Dec 22, 2023

Choose a reason for hiding this comment

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

This is necessary to run make format, which fails without it.

bash-completion \
man man-pages \
openssl-devel \
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 @@ -113,8 +113,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/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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
Copy link
Member Author

Choose a reason for hiding this comment

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

This auth method has been deprecated.


- name: Set up Go release
if: matrix.go.version != 'tip'
Expand Down
28 changes: 15 additions & 13 deletions admin/commands/inventory/add_agent_external_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Custom labels : {{ .Agent.CustomLabels }}
`)

type addAgentExternalExporterResult struct {
Agent *agents.AddExternalExporterOKBodyExternalExporter `json:"external_exporter"`
Agent *agents.AddAgentOKBodyExternalExporter `json:"external_exporter"`
}

func (res *addAgentExternalExporterResult) Result() {}
Expand Down Expand Up @@ -67,22 +67,24 @@ func (cmd *AddAgentExternalExporterCommand) RunCmd() (commands.Result, error) {
cmd.MetricsPath = fmt.Sprintf("/%s", cmd.MetricsPath)
}

params := &agents.AddExternalExporterParams{
Body: agents.AddExternalExporterBody{
RunsOnNodeID: cmd.RunsOnNodeID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
Scheme: cmd.Scheme,
MetricsPath: cmd.MetricsPath,
ListenPort: cmd.ListenPort,
CustomLabels: customLabels,
PushMetrics: cmd.PushMetrics,
params := &agents.AddAgentParams{
Body: agents.AddAgentBody{
ExternalExporter: &agents.AddAgentParamsBodyExternalExporter{
RunsOnNodeID: cmd.RunsOnNodeID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
Scheme: cmd.Scheme,
MetricsPath: cmd.MetricsPath,
ListenPort: cmd.ListenPort,
CustomLabels: customLabels,
PushMetrics: cmd.PushMetrics,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.AgentsService.AddExternalExporter(params)
resp, err := client.Default.AgentsService.AddAgent(params)
if err != nil {
return nil, err
}
Expand Down
46 changes: 24 additions & 22 deletions admin/commands/inventory/add_agent_mongodb_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Custom labels : {{ .Agent.CustomLabels }}
`)

type addAgentMongodbExporterResult struct {
Agent *agents.AddMongoDBExporterOKBodyMongodbExporter `json:"mongodb_exporter"`
Agent *agents.AddAgentOKBodyMongodbExporter `json:"mongodb_exporter"`
}

func (res *addAgentMongodbExporterResult) Result() {}
Expand Down Expand Up @@ -81,31 +81,33 @@ func (cmd *AddAgentMongodbExporterCommand) RunCmd() (commands.Result, error) {
return nil, err
}

params := &agents.AddMongoDBExporterParams{
Body: agents.AddMongoDBExporterBody{
PMMAgentID: cmd.PMMAgentID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
AgentPassword: cmd.AgentPassword,
CustomLabels: customLabels,
SkipConnectionCheck: cmd.SkipConnectionCheck,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
TLSCertificateKey: tlsCertificateKey,
TLSCertificateKeyFilePassword: cmd.TLSCertificateKeyFilePassword,
TLSCa: tlsCa,
AuthenticationMechanism: cmd.AuthenticationMechanism,
PushMetrics: cmd.PushMetrics,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
StatsCollections: commands.ParseDisableCollectors(cmd.StatsCollections),
CollectionsLimit: cmd.CollectionsLimit,
LogLevel: &cmd.LogLevel,
params := &agents.AddAgentParams{
Body: agents.AddAgentBody{
MongodbExporter: &agents.AddAgentParamsBodyMongodbExporter{
PMMAgentID: cmd.PMMAgentID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
AgentPassword: cmd.AgentPassword,
CustomLabels: customLabels,
SkipConnectionCheck: cmd.SkipConnectionCheck,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
TLSCertificateKey: tlsCertificateKey,
TLSCertificateKeyFilePassword: cmd.TLSCertificateKeyFilePassword,
TLSCa: tlsCa,
AuthenticationMechanism: cmd.AuthenticationMechanism,
PushMetrics: cmd.PushMetrics,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
StatsCollections: commands.ParseDisableCollectors(cmd.StatsCollections),
CollectionsLimit: cmd.CollectionsLimit,
LogLevel: &cmd.LogLevel,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.AgentsService.AddMongoDBExporter(params)
resp, err := client.Default.AgentsService.AddAgent(params)
if err != nil {
return nil, err
}
Expand Down
46 changes: 24 additions & 22 deletions admin/commands/inventory/add_agent_mysqld_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Tablestat collectors : {{ .TablestatStatus }}
`)

type addAgentMysqldExporterResult struct {
Agent *agents.AddMySQLdExporterOKBodyMysqldExporter `json:"mysqld_exporter"`
TableCount int32 `json:"table_count,omitempty"`
Agent *agents.AddAgentOKBodyMysqldExporter `json:"mysqld_exporter"`
TableCount int32 `json:"table_count,omitempty"`
}

func (res *addAgentMysqldExporterResult) Result() {}
Expand Down Expand Up @@ -125,30 +125,32 @@ func (cmd *AddAgentMysqldExporterCommand) RunCmd() (commands.Result, error) {
}
}

params := &agents.AddMySQLdExporterParams{
Body: agents.AddMySQLdExporterBody{
PMMAgentID: cmd.PMMAgentID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
AgentPassword: cmd.AgentPassword,
CustomLabels: customLabels,
SkipConnectionCheck: cmd.SkipConnectionCheck,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
TLSCa: tlsCa,
TLSCert: tlsCert,
TLSKey: tlsKey,
TablestatsGroupTableLimit: cmd.TablestatsGroupTableLimit,
PushMetrics: cmd.PushMetrics,
ExposeExporter: cmd.ExposeExporter,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
LogLevel: &cmd.LogLevel,
params := &agents.AddAgentParams{
Body: agents.AddAgentBody{
MysqldExporter: &agents.AddAgentParamsBodyMysqldExporter{
PMMAgentID: cmd.PMMAgentID,
ServiceID: cmd.ServiceID,
Username: cmd.Username,
Password: cmd.Password,
AgentPassword: cmd.AgentPassword,
CustomLabels: customLabels,
SkipConnectionCheck: cmd.SkipConnectionCheck,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
TLSCa: tlsCa,
TLSCert: tlsCert,
TLSKey: tlsKey,
TablestatsGroupTableLimit: cmd.TablestatsGroupTableLimit,
PushMetrics: cmd.PushMetrics,
ExposeExporter: cmd.ExposeExporter,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
LogLevel: &cmd.LogLevel,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.AgentsService.AddMySQLdExporter(params)
resp, err := client.Default.AgentsService.AddAgent(params)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions admin/commands/inventory/add_agent_mysqld_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func TestAddAgentMysqldExporter(t *testing.T) {
t.Run("TablestatEnabled", func(t *testing.T) {
res := &addAgentMysqldExporterResult{
Agent: &agents.AddMySQLdExporterOKBodyMysqldExporter{
Agent: &agents.AddAgentOKBodyMysqldExporter{
AgentID: "/agent_id/1",
PMMAgentID: "/agent_id/2",
Username: "username",
Expand Down Expand Up @@ -61,7 +61,7 @@ Tablestat collectors : enabled (the limit is 1000, the actual table count is 50

t.Run("TablestatEnabledNoLimit", func(t *testing.T) {
res := &addAgentMysqldExporterResult{
Agent: &agents.AddMySQLdExporterOKBodyMysqldExporter{
Agent: &agents.AddAgentOKBodyMysqldExporter{
AgentID: "/agent_id/1",
PMMAgentID: "/agent_id/2",
Username: "username",
Expand Down Expand Up @@ -95,7 +95,7 @@ Tablestat collectors : enabled (the table count limit is not set).

t.Run("TablestatEnabledUnknown", func(t *testing.T) {
res := &addAgentMysqldExporterResult{
Agent: &agents.AddMySQLdExporterOKBodyMysqldExporter{
Agent: &agents.AddAgentOKBodyMysqldExporter{
AgentID: "/agent_id/1",
PMMAgentID: "/agent_id/2",
Username: "username",
Expand Down Expand Up @@ -129,7 +129,7 @@ Tablestat collectors : enabled (the limit is 1000, the actual table count is un

t.Run("TablestatDisabled", func(t *testing.T) {
res := &addAgentMysqldExporterResult{
Agent: &agents.AddMySQLdExporterOKBodyMysqldExporter{
Agent: &agents.AddAgentOKBodyMysqldExporter{
AgentID: "/agent_id/1",
PMMAgentID: "/agent_id/2",
Username: "username",
Expand Down Expand Up @@ -163,7 +163,7 @@ Tablestat collectors : disabled (the limit is 1000, the actual table count is 2

t.Run("TablestatDisabledAlways", func(t *testing.T) {
res := &addAgentMysqldExporterResult{
Agent: &agents.AddMySQLdExporterOKBodyMysqldExporter{
Agent: &agents.AddAgentOKBodyMysqldExporter{
AgentID: "/agent_id/1",
PMMAgentID: "/agent_id/2",
Username: "username",
Expand Down
22 changes: 12 additions & 10 deletions admin/commands/inventory/add_agent_node_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Custom labels: {{ .Agent.CustomLabels }}
`)

type addAgentNodeExporterResult struct {
Agent *agents.AddNodeExporterOKBodyNodeExporter `json:"node_exporter"`
Agent *agents.AddAgentOKBodyNodeExporter `json:"node_exporter"`
}

func (res *addAgentNodeExporterResult) Result() {}
Expand All @@ -53,19 +53,21 @@ type AddAgentNodeExporterCommand struct {

func (cmd *AddAgentNodeExporterCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &agents.AddNodeExporterParams{
Body: agents.AddNodeExporterBody{
PMMAgentID: cmd.PMMAgentID,
CustomLabels: customLabels,
PushMetrics: cmd.PushMetrics,
ExposeExporter: cmd.ExposeExporter,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
LogLevel: &cmd.LogLevel,
params := &agents.AddAgentParams{
Body: agents.AddAgentBody{
NodeExporter: &agents.AddAgentParamsBodyNodeExporter{
PMMAgentID: cmd.PMMAgentID,
CustomLabels: customLabels,
PushMetrics: cmd.PushMetrics,
ExposeExporter: cmd.ExposeExporter,
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
LogLevel: &cmd.LogLevel,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.AgentsService.AddNodeExporter(params)
resp, err := client.Default.AgentsService.AddAgent(params)
if err != nil {
return nil, err
}
Expand Down
14 changes: 8 additions & 6 deletions admin/commands/inventory/add_agent_pmm_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Custom labels : {{ .Agent.CustomLabels }}
`)

type addPMMAgentResult struct {
Agent *agents.AddPMMAgentOKBodyPMMAgent `json:"pmm_agent"`
Agent *agents.AddAgentOKBodyPMMAgent `json:"pmm_agent"`
}

func (res *addPMMAgentResult) Result() {}
Expand All @@ -46,15 +46,17 @@ type AddPMMAgentCommand struct {

func (cmd *AddPMMAgentCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &agents.AddPMMAgentParams{
Body: agents.AddPMMAgentBody{
RunsOnNodeID: cmd.RunsOnNodeID,
CustomLabels: customLabels,
params := &agents.AddAgentParams{
Body: agents.AddAgentBody{
PMMAgent: &agents.AddAgentParamsBodyPMMAgent{
RunsOnNodeID: cmd.RunsOnNodeID,
CustomLabels: customLabels,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.AgentsService.AddPMMAgent(params)
resp, err := client.Default.AgentsService.AddAgent(params)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading