@@ -28,7 +28,6 @@ import (
28
28
"sync"
29
29
"time"
30
30
31
- "github.com/DataExMachina-dev/side-eye-go/sideeyeclient"
32
31
"github.com/cockroachdb/cockroach/pkg/build"
33
32
"github.com/cockroachdb/cockroach/pkg/cli/exit"
34
33
"github.com/cockroachdb/cockroach/pkg/cmd/roachprod/grafana"
@@ -2565,68 +2564,6 @@ func StopOpenTelemetry(ctx context.Context, l *logger.Logger, clusterName string
2565
2564
return opentelemetry .Stop (ctx , l , c )
2566
2565
}
2567
2566
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
-
2630
2567
// DestroyDNS destroys the DNS records for the given cluster.
2631
2568
func DestroyDNS (ctx context.Context , l * logger.Logger , clusterName string ) error {
2632
2569
c , err := GetClusterFromCache (l , clusterName )
@@ -3027,77 +2964,6 @@ func Deploy(
3027
2964
return nil
3028
2965
}
3029
2966
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
-
3101
2967
// GetClusterFromCache finds and returns a SyncedCluster from
3102
2968
// the local cluster cache.
3103
2969
//
0 commit comments