Skip to content

Commit 22c5876

Browse files
andreimateisrosenberg
authored andcommitted
roachprod: remove Side-Eye support
Epic: none Release note: None
1 parent c5727d1 commit 22c5876

File tree

5 files changed

+0
-240
lines changed

5 files changed

+0
-240
lines changed

pkg/cmd/roachprod/cli/commands.go

-64
Original file line numberDiff line numberDiff line change
@@ -2054,70 +2054,6 @@ func (cr *commandRegistry) buildJaegerURLCmd() *cobra.Command {
20542054
return jaegerURLCmd
20552055
}
20562056

2057-
func (cr *commandRegistry) buildSideEyeRootCmd() *cobra.Command {
2058-
sideEyeRootCmd := &cobra.Command{
2059-
Use: "side-eye",
2060-
Short: "interact with side-eye.io functionality",
2061-
Long: `Interact with side-eye.io functionality
2062-
2063-
Side-Eye (app.side-eye.io) is a distributed debugger that can be used to capture
2064-
snapshots of a CockroachDB cluster.
2065-
`,
2066-
Args: cobra.MinimumNArgs(1),
2067-
}
2068-
sideEyeRootCmd.AddCommand(buildSideEyeInstallCmd())
2069-
sideEyeRootCmd.AddCommand(buildSideEyeSnapCmd())
2070-
return sideEyeRootCmd
2071-
}
2072-
2073-
func buildSideEyeInstallCmd() *cobra.Command {
2074-
return &cobra.Command{
2075-
Use: "install <cluster>",
2076-
Short: "install and start the Side-Eye agents on all nodes in the cluster",
2077-
Long: `Install and start the Side-Eye agents on all nodes in the cluster
2078-
2079-
` + "`roachprod side-eye snapshot <cluster>`" + ` can then be used to capture cluster snapshots.
2080-
`,
2081-
Args: cobra.ExactArgs(1),
2082-
Run: wrap(func(cmd *cobra.Command, args []string) error {
2083-
cluster := args[0]
2084-
2085-
ctx := context.Background()
2086-
l := config.Logger
2087-
sideEyeToken, ok := roachprod.GetSideEyeTokenFromEnv()
2088-
if !ok {
2089-
return errors.New("Side-Eye token is not configured via SIDE_EYE_API_TOKEN or gcloud secret")
2090-
}
2091-
2092-
return roachprod.StartSideEyeAgents(ctx, l, cluster, cluster /* envName */, sideEyeToken)
2093-
}),
2094-
}
2095-
}
2096-
2097-
func buildSideEyeSnapCmd() *cobra.Command {
2098-
return &cobra.Command{
2099-
Use: "snapshot <cluster/Side-Eye environment>",
2100-
Aliases: []string{"snap"},
2101-
Short: "capture a cluster snapshot",
2102-
Long: `Capture a cluster snapshot using Side-Eye
2103-
2104-
The command will print an app.side-eye.io URL where the snapshot can be viewed.
2105-
`,
2106-
Args: cobra.ExactArgs(1),
2107-
Run: wrap(func(cmd *cobra.Command, args []string) error {
2108-
cluster := args[0]
2109-
ctx := context.Background()
2110-
l := config.Logger
2111-
l.PrintfCtx(ctx, "capturing snapshot of the cluster with Side-Eye...")
2112-
snapURL, ok := roachprod.CaptureSideEyeSnapshot(context.Background(), config.Logger, cluster, nil /* client */)
2113-
if ok {
2114-
l.PrintfCtx(ctx, "captured Side-Eye snapshot: %s", snapURL)
2115-
}
2116-
return nil
2117-
}),
2118-
}
2119-
}
2120-
21212057
func (cr *commandRegistry) buildFluentBitStartCmd() *cobra.Command {
21222058
fluentBitStartCmd := &cobra.Command{
21232059
Use: "fluent-bit-start <cluster>",

pkg/cmd/roachprod/cli/resgistry.go

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func (cr *commandRegistry) register() {
6464
cr.buildJaegerStartCmd(),
6565
cr.buildJaegerStopCmd(),
6666
cr.buildJaegerURLCmd(),
67-
cr.buildSideEyeRootCmd(),
6867
cr.buildFluentBitStartCmd(),
6968
cr.buildFluentBitStopCmd(),
7069
cr.buildOpentelemetryStartCmd(),

pkg/roachprod/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ go_library(
3939
"//pkg/util/timeutil",
4040
"@com_github_cockroachdb_errors//:errors",
4141
"@com_github_cockroachdb_errors//oserror",
42-
"@com_github_dataexmachina_dev_side_eye_go//sideeyeclient",
4342
"@org_golang_x_sys//unix",
4443
],
4544
)

pkg/roachprod/install/install.go

-40
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ import (
1010
"context"
1111
"fmt"
1212
"io"
13-
"os"
14-
"os/exec"
1513
"sort"
1614
"strings"
1715

1816
rperrors "github.com/cockroachdb/cockroach/pkg/roachprod/errors"
1917
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
20-
"github.com/cockroachdb/errors"
2118
)
2219

2320
var installCmds = map[string]string{
@@ -101,10 +98,6 @@ sudo apt-get install -y /tmp/otelcol-contrib.deb;
10198
rm /tmp/otelcol-contrib.deb;
10299
`,
103100

104-
"side-eye": `
105-
curl https://sh.side-eye.io/ | SIDE_EYE_API_TOKEN=%API_KEY% SIDE_EYE_ENVIRONMENT="%ROACHPROD_CLUSTER_NAME%" sh
106-
`,
107-
108101
"bzip2": `
109102
sudo apt-get update;
110103
sudo apt-get install -y bzip2;
@@ -121,19 +114,6 @@ sudo apt-get install -y vmtouch;
121114
`,
122115
}
123116

124-
// installLocalCmds is a map from software name to a map of strings that
125-
// are replaced in the installCmd for that software with the stdout of executing
126-
// a command locally.
127-
var installLocalCmds = map[string]map[string]*exec.Cmd{
128-
"side-eye": {
129-
"%API_KEY%": sideEyeSecretCmd,
130-
},
131-
}
132-
133-
var sideEyeSecretCmd = exec.Command("gcloud",
134-
"--project", "cockroach-ephemeral",
135-
"secrets", "versions", "access", "latest", "--secret", "side-eye-key")
136-
137117
// SortedCmds TODO(peter): document
138118
func SortedCmds() []string {
139119
cmds := make([]string, 0, len(installCmds))
@@ -170,16 +150,6 @@ func InstallTool(
170150
}
171151
cmd = strings.ReplaceAll(cmd, "%ROACHPROD_CLUSTER_NAME%", c.Name)
172152

173-
for replace, localCmd := range installLocalCmds[softwareName] {
174-
copy := *localCmd
175-
copy.Stderr = os.Stderr
176-
out, err := copy.Output()
177-
if err != nil {
178-
return errors.Wrapf(err, "running local command to derive install argument %s, command %s, failed", replace, copy.String())
179-
}
180-
cmd = strings.ReplaceAll(cmd, replace, string(out))
181-
}
182-
183153
// Ensure that we early exit if any of the shell statements fail.
184154
cmd = "set -exuo pipefail;" + cmd
185155
if err := c.Run(ctx, l, stdout, stderr, WithNodes(nodes), "installing "+softwareName, cmd); err != nil {
@@ -188,13 +158,3 @@ func InstallTool(
188158

189159
return nil
190160
}
191-
192-
func GetGcloudSideEyeSecret() string {
193-
c := *sideEyeSecretCmd
194-
c.Stderr = os.Stderr
195-
out, err := c.Output()
196-
if err != nil {
197-
return ""
198-
}
199-
return string(out)
200-
}

pkg/roachprod/roachprod.go

-134
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"sync"
2929
"time"
3030

31-
"github.com/DataExMachina-dev/side-eye-go/sideeyeclient"
3231
"github.com/cockroachdb/cockroach/pkg/build"
3332
"github.com/cockroachdb/cockroach/pkg/cli/exit"
3433
"github.com/cockroachdb/cockroach/pkg/cmd/roachprod/grafana"
@@ -2565,68 +2564,6 @@ func StopOpenTelemetry(ctx context.Context, l *logger.Logger, clusterName string
25652564
return opentelemetry.Stop(ctx, l, c)
25662565
}
25672566

2568-
// StartSideEyeAgents starts the Side-Eye agent on all the nodes in the given
2569-
// cluster.
2570-
//
2571-
// envName is the name of the Side-Eye environment that the agents will register
2572-
// with.
2573-
//
2574-
// apiToken is the token that the agents will use to identify their organization
2575-
// (i.e. usually cockroachlabs.com) to the Side-Eye service.
2576-
//
2577-
// See CaptureSideEyeSnapshot() for using these agents to capture cluster
2578-
// snapshots.
2579-
func StartSideEyeAgents(
2580-
ctx context.Context, l *logger.Logger, clusterName string, envName string, apiToken string,
2581-
) error {
2582-
c, err := GetClusterFromCache(l, clusterName)
2583-
if err != nil {
2584-
return err
2585-
}
2586-
2587-
// Note that this command is similar to the one used by `roachprod install
2588-
// side-eye`. We could use that through install.InstallTool(), but that code
2589-
// looks up the API token in `gcloud secrets`; we already know the token, so
2590-
// let's just use it directly.
2591-
cmd := fmt.Sprintf(
2592-
`curl https://sh.side-eye.io/ | SIDE_EYE_API_TOKEN="%s" SIDE_EYE_ENVIRONMENT="%s" sh`,
2593-
apiToken, envName)
2594-
allNodes := c.TargetNodes()
2595-
err = c.Run(
2596-
ctx, l, l.Stdout, l.Stderr, install.WithNodes(allNodes), "installing Side-Eye agent", cmd)
2597-
if err != nil {
2598-
return err
2599-
}
2600-
2601-
l.PrintfCtx(ctx, "installed the Side-Eye agent on all nodes. Access this cluster at https://app.side-eye.io")
2602-
return nil
2603-
}
2604-
2605-
// UpdateSideEyeEnvironmentName updates the environment name used by the
2606-
// Side-Eye agents running on the given cluster.
2607-
func UpdateSideEyeEnvironmentName(
2608-
ctx context.Context, l *logger.Logger, clusterName string, newEnvName string,
2609-
) error {
2610-
c, err := GetClusterFromCache(l, clusterName)
2611-
if err != nil {
2612-
return err
2613-
}
2614-
2615-
cmd := fmt.Sprintf(
2616-
`sudo snap set side-eye-agent environment='%s' && sudo snap restart side-eye-agent`,
2617-
newEnvName)
2618-
allNodes := c.TargetNodes()
2619-
err = c.Run(
2620-
ctx, l, l.Stdout, l.Stderr, install.WithNodes(allNodes),
2621-
"updating Side-Eye agents with new environment name", cmd)
2622-
if err != nil {
2623-
return err
2624-
}
2625-
2626-
l.PrintfCtx(ctx, "updated Side-Eye environment name to %q", newEnvName)
2627-
return nil
2628-
}
2629-
26302567
// DestroyDNS destroys the DNS records for the given cluster.
26312568
func DestroyDNS(ctx context.Context, l *logger.Logger, clusterName string) error {
26322569
c, err := GetClusterFromCache(l, clusterName)
@@ -3027,77 +2964,6 @@ func Deploy(
30272964
return nil
30282965
}
30292966

3030-
var sideEyeEnvToken, _ = os.LookupEnv("SIDE_EYE_API_TOKEN")
3031-
3032-
// GetSideEyeTokenFromEnv returns the Side-Eye API token from either an
3033-
// environment variable or gcloud secrets. The second return value is false if
3034-
// the key is not found in either place.
3035-
func GetSideEyeTokenFromEnv() (string, bool) {
3036-
sideEyeToken := sideEyeEnvToken
3037-
if sideEyeToken == "" {
3038-
sideEyeToken = install.GetGcloudSideEyeSecret()
3039-
}
3040-
if sideEyeToken == "" {
3041-
return "", false
3042-
}
3043-
return sideEyeToken, true
3044-
}
3045-
3046-
// CaptureSideEyeSnapshot asks the Side-Eye service to take a snapshot of the
3047-
// cockroach processes of the specified cluster/environment. All errors are
3048-
// logged and swallowed. The agents must previously have been installed
3049-
// through StartSideEyeAgents().
3050-
//
3051-
// sideEyeEnv should generally be the cluster name, unless the agents have been
3052-
// explicitly configured to use a different name.
3053-
//
3054-
// If client is specified, it will be used to communicate with the Side-Eye
3055-
// service. If nil, a client is created and initialized based on the API key
3056-
// form the environment; if the key is not found in the environment, the call is
3057-
// a no-op.
3058-
//
3059-
// On success returns <the snapshot URL>, true. On failure returns "", false.
3060-
func CaptureSideEyeSnapshot(
3061-
ctx context.Context, l *logger.Logger, sideEyeEnv string, client *sideeyeclient.SideEyeClient,
3062-
) (string, bool) {
3063-
if client == nil {
3064-
sideEyeToken, ok := GetSideEyeTokenFromEnv()
3065-
if !ok {
3066-
l.Printf("Side-Eye token is not configured via SIDE_EYE_API_TOKEN or gcloud secret, skipping snapshot")
3067-
return "", false
3068-
}
3069-
3070-
var err error
3071-
client, err = sideeyeclient.NewSideEyeClient(sideeyeclient.WithApiToken(sideEyeToken))
3072-
if err != nil {
3073-
l.Errorf("failed to create Side-Eye client: %s", err)
3074-
return "", false
3075-
}
3076-
defer client.Close()
3077-
}
3078-
3079-
// Protect against the snapshot taking too long.
3080-
snapCtx, cancel := context.WithTimeout(ctx, time.Minute)
3081-
defer cancel()
3082-
snapRes, err := client.CaptureSnapshot(snapCtx, sideEyeEnv)
3083-
if err != nil {
3084-
msg := "failed to capture cluster snapshot"
3085-
if errors.Is(err, sideeyeclient.NoProcessesError{}) {
3086-
msg += "; is cockroach running?"
3087-
}
3088-
l.PrintfCtx(ctx, "Side-Eye failed to capture cluster snapshot: %s", msg)
3089-
return "", false
3090-
}
3091-
3092-
// Handle partial errors.
3093-
for _, pe := range snapRes.ProcessErrors {
3094-
l.PrintfCtx(ctx, "partial failure: error snapshotting one of the processes: %s: %s (%d): %s",
3095-
pe.Hostname, pe.Program, pe.Pid, pe.Error)
3096-
}
3097-
3098-
return snapRes.SnapshotURL, true
3099-
}
3100-
31012967
// GetClusterFromCache finds and returns a SyncedCluster from
31022968
// the local cluster cache.
31032969
//

0 commit comments

Comments
 (0)