-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DJM] Add new script for dataproc #32525
Open
aboitreaud
wants to merge
3
commits into
main
Choose a base branch
from
adrien.boitreaud/djm-install-script-dataproc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−8
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
// Package djm contains data-jobs-monitoring installation logic | ||
package djm | ||
|
||
import ( | ||
"cloud.google.com/go/compute/metadata" | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/DataDog/datadog-agent/pkg/fleet/installer/setup/common" | ||
"github.com/DataDog/datadog-agent/pkg/util/log" | ||
) | ||
|
||
const ( | ||
dataprocInjectorVersion = "0.26.0-1" | ||
dataprocJavaTracerVersion = "1.42.2-1" | ||
dataprocAgentVersion = "7.58.2-1" | ||
) | ||
|
||
var ( | ||
tracerEnvConfigDataproc = []common.InjectTracerConfigEnvVar{ | ||
{ | ||
Key: "DD_DATA_JOBS_ENABLED", | ||
Value: "true", | ||
}, | ||
{ | ||
Key: "DD_INTEGRATIONS_ENABLED", | ||
Value: "false", | ||
}, | ||
{ | ||
Key: "DD_DATA_JOBS_COMMAND_PATTERN", | ||
Value: ".*org.apache.spark.deploy.*", | ||
}, | ||
{ | ||
Key: "DD_SPARK_APP_NAME_AS_SERVICE", | ||
Value: "true", | ||
}, | ||
} | ||
) | ||
|
||
// SetupDataproc sets up the DJM environment on Dataproc | ||
func SetupDataproc(s *common.Setup) error { | ||
|
||
metadataClient := metadata.NewClient(nil) | ||
s.Packages.Install(common.DatadogAgentPackage, dataprocAgentVersion) | ||
s.Packages.Install(common.DatadogAPMInjectPackage, dataprocInjectorVersion) | ||
s.Packages.Install(common.DatadogAPMLibraryJavaPackage, dataprocJavaTracerVersion) | ||
|
||
os.Setenv("DD_APM_INSTRUMENTATION_ENABLED", "host") | ||
|
||
hostname, err := os.Hostname() | ||
if err != nil { | ||
return fmt.Errorf("failed to get hostname: %w", err) | ||
} | ||
s.Config.DatadogYAML.Hostname = hostname | ||
s.Config.DatadogYAML.DJM.Enabled = true | ||
s.Config.InjectTracerYAML.AdditionalEnvironmentVariables = tracerEnvConfigDataproc | ||
|
||
// Ensure tags are always attached with the metrics | ||
s.Config.DatadogYAML.ExpectedTagsDuration = "10m" | ||
isMaster, clusterName, err := setupCommonDataprocHostTags(s, metadataClient) | ||
if err != nil { | ||
return fmt.Errorf("failed to set tags: %w", err) | ||
} | ||
if isMaster == "true" { | ||
setupResourceManager(s, clusterName) | ||
} | ||
return nil | ||
} | ||
|
||
func setupCommonDataprocHostTags(s *common.Setup, metadataClient *metadata.Client) (string, string, error) { | ||
ctx := context.Background() | ||
|
||
clusterID, err := metadataClient.InstanceAttributeValueWithContext(ctx, "dataproc-cluster-uuid") | ||
if err != nil { | ||
return "", "", err | ||
} | ||
setHostTag(s, "cluster_id", clusterID) | ||
setHostTag(s, "dataproc_cluster_id", clusterID) | ||
|
||
dataprocRole, err := metadataClient.InstanceAttributeValueWithContext(ctx, "dataproc-role") | ||
if err != nil { | ||
return "", "", err | ||
} | ||
isMaster := "false" | ||
if dataprocRole == "Master" { | ||
isMaster = "true" | ||
} | ||
setHostTag(s, "is_master_node", isMaster) | ||
s.Span.SetTag("host."+"is_master_node", isMaster) | ||
|
||
clusterName, err := metadataClient.InstanceAttributeValueWithContext(ctx, "dataproc-cluster-name") | ||
if err != nil { | ||
log.Warn("failed to get clusterName, using clusterID instead") | ||
return isMaster, clusterID, nil | ||
} | ||
setHostTag(s, "cluster_name", clusterName) | ||
|
||
return isMaster, clusterName, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: as this package basically handles http calls to the metadata endpoints, I wonder if wrapping the transport could let us trace these calls
Like so:
datadog-agent/pkg/fleet/installer/oci/download.go
Line 244 in 179220f
That way we can know if customers have errors and if we need retries