Skip to content

Commit 3509fcc

Browse files
committed
roachprod: add parca-agent cli commands
Add start and stop commands for the parca-agent to the roachprod CLI. Epic: None Release note: None
1 parent a9bc092 commit 3509fcc

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

pkg/cmd/roachprod/cli/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ go_library(
1818
"//pkg/roachprod",
1919
"//pkg/roachprod/agents/fluentbit",
2020
"//pkg/roachprod/agents/opentelemetry",
21+
"//pkg/roachprod/agents/parca",
2122
"//pkg/roachprod/cloud",
2223
"//pkg/roachprod/config",
2324
"//pkg/roachprod/errors",

pkg/cmd/roachprod/cli/commands.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,32 @@ func (cr *commandRegistry) buildOpentelemetryStopCmd() *cobra.Command {
21472147
}
21482148
}
21492149

2150+
func (cr *commandRegistry) buildParcaAgentStartCmd() *cobra.Command {
2151+
parcaAgentStartCmd := &cobra.Command{
2152+
Use: "parca-agent-start <cluster>",
2153+
Short: "Install and start the Parca Agent",
2154+
Long: "Install and start the Parca Agent",
2155+
Args: cobra.ExactArgs(1),
2156+
Run: Wrap(func(cmd *cobra.Command, args []string) error {
2157+
return roachprod.StartParcaAgent(context.Background(), config.Logger, args[0], parcaAgentConfig)
2158+
}),
2159+
}
2160+
initParcaAgentStartCmdFlags(parcaAgentStartCmd)
2161+
return parcaAgentStartCmd
2162+
}
2163+
2164+
func (cr *commandRegistry) buildParcaAgentStopCmd() *cobra.Command {
2165+
return &cobra.Command{
2166+
Use: "parca-agent-stop <cluster>",
2167+
Short: "Stop the Parca Agent",
2168+
Long: "Stop the Parca Agent",
2169+
Args: cobra.ExactArgs(1),
2170+
Run: Wrap(func(cmd *cobra.Command, args []string) error {
2171+
return roachprod.StopParcaAgent(context.Background(), config.Logger, args[0])
2172+
}),
2173+
}
2174+
}
2175+
21502176
func (cr *commandRegistry) buildFetchLogsCmd() *cobra.Command {
21512177
fetchLogsCmd := &cobra.Command{
21522178
Use: "fetchlogs <cluster> <destination (optional)> [flags]",

pkg/cmd/roachprod/cli/flags.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/cockroachdb/cockroach/pkg/roachprod"
1414
"github.com/cockroachdb/cockroach/pkg/roachprod/agents/fluentbit"
1515
"github.com/cockroachdb/cockroach/pkg/roachprod/agents/opentelemetry"
16+
"github.com/cockroachdb/cockroach/pkg/roachprod/agents/parca"
1617
"github.com/cockroachdb/cockroach/pkg/roachprod/config"
1718
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
1819
"github.com/cockroachdb/cockroach/pkg/roachprod/ssh"
@@ -101,9 +102,9 @@ var (
101102

102103
sshKeyUser string
103104

104-
fluentBitConfig fluentbit.Config
105-
105+
fluentBitConfig fluentbit.Config
106106
opentelemetryConfig opentelemetry.Config
107+
parcaAgentConfig parca.Config
107108

108109
fetchLogsTimeout time.Duration
109110
)
@@ -393,6 +394,11 @@ func initOpentelemetryStartCmdFlags(opentelemetryStartCmd *cobra.Command) {
393394
"Datadog tags as a comma-separated list in the format KEY1:VAL1,KEY2:VAL2")
394395
}
395396

397+
func initParcaAgentStartCmdFlags(parcaAgentStartCmd *cobra.Command) {
398+
parcaAgentStartCmd.Flags().StringVar(&parcaAgentConfig.Token, "parca-agent-token", "",
399+
"Parca Agent Token")
400+
}
401+
396402
func initGCCmdFlags(gcCmd *cobra.Command) {
397403
gcCmd.Flags().BoolVarP(&dryrun,
398404
"dry-run", "n", dryrun, "dry run (don't perform any actions)")

pkg/cmd/roachprod/cli/resgistry.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func (cr *commandRegistry) register() {
6868
cr.buildFluentBitStopCmd(),
6969
cr.buildOpentelemetryStartCmd(),
7070
cr.buildOpentelemetryStopCmd(),
71+
cr.buildParcaAgentStartCmd(),
72+
cr.buildParcaAgentStopCmd(),
7173
cr.buildFetchLogsCmd(),
7274
cr.buildGetLatestPProfCmd(),
7375
cr.buildFetchCertsDir(),

0 commit comments

Comments
 (0)