Skip to content

Commit 7ab511a

Browse files
authored
ci(release): Fixing the release script for prod (#825)
Signed-off-by: Vincent Boutour <vincent.boutour@datadoghq.com>
1 parent 3f3007f commit 7ab511a

File tree

5 files changed

+93
-112
lines changed

5 files changed

+93
-112
lines changed

aws/logs_monitoring/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ indent_size = 4
55
indent_style = space
66
insert_final_newline = true
77
trim_trailing_whitespace = true
8+
9+
[*.yaml]
10+
indent_size = 2

aws/logs_monitoring/release.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,12 @@ prod_release() {
178178
log_info "You are about to\n\t- bump the version from ${CURRENT_VERSION} to ${FORWARDER_VERSION}\n\t- create lambda layer version ${LAYER_VERSION}\n\t- create a release of aws-dd-forwarder-${FORWARDER_VERSION} on GitHub\n\t- upload the template.yaml to s3://${BUCKET}/aws/forwarder/${FORWARDER_VERSION}.yaml\n"
179179

180180
# Confirm to proceed
181-
if user_confirm "Continue"; then
181+
if ! user_confirm "Continue"; then
182182
log_error "Aborting..."
183183
fi
184184

185185
# Get the latest code
186186
git pull origin master
187-
GIT_COMMIT="$(git rev-parse --short HEAD)"
188-
log_info "Using ${GIT_COMMIT} commit as the release target..."
189187

190188
log_info "Bumping the version number to ${FORWARDER_VERSION}..."
191189
perl -pi -e "s/DD_FORWARDER_VERSION = \"[0-9\.]+/DD_FORWARDER_VERSION = \"${FORWARDER_VERSION}/g" "settings.py"
@@ -194,8 +192,16 @@ prod_release() {
194192
yq --inplace ".Mappings.Constants.DdForwarder.Version |= \"${FORWARDER_VERSION}\"" "template.yaml"
195193
yq --inplace ".Mappings.Constants.DdForwarder.LayerVersion |= \"${LAYER_VERSION}\"" "template.yaml"
196194

197-
# Confirm to proceed
198-
if [[ ! -e ${BUNDLE_PATH} ]] || user_confirm "Bundle already exists. Do you want to use it" "true"; then
195+
if git diff --quiet; then
196+
log_info "Committing version number change..."
197+
git add "settings.py" "template.yaml"
198+
git commit --signoff --message "ci(release): Update version from ${CURRENT_VERSION} to ${FORWARDER_VERSION}"
199+
fi
200+
201+
GIT_COMMIT="$(git rev-parse --short HEAD)"
202+
log_info "Using ${GIT_COMMIT} commit as the release target..."
203+
204+
if [[ ! -e ${BUNDLE_PATH} ]] || ! user_confirm "Bundle already exists. Do you want to use it" "true"; then
199205
log_info "Building the Forwarder bundle..."
200206
./tools/build_bundle.sh "${FORWARDER_VERSION}"
201207

aws/logs_monitoring/template.yaml

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ Parameters:
4646
ConstraintDescription: ReservedConcurrency must be an integer number
4747
Default: ""
4848
Description: >-
49-
Reserved concurrency for the Datadog Forwarder Lambda function. If empty, use unreserved account concurrency.
50-
We recommend using at least 10 reserved concurrency, but default to 0 as you may need to increase your limits for this.
51-
If using unreserved account concurrency you may limit other lambda functions in your environment.
49+
Reserved concurrency for the Datadog Forwarder Lambda function. If empty, use unreserved account concurrency. We recommend using at least 10 reserved concurrency, but default to 0 as you may need to increase your limits for this. If using unreserved account concurrency you may limit other lambda functions in your environment.
5250
LogRetentionInDays:
5351
Type: Number
5452
Default: 90
@@ -232,7 +230,7 @@ Parameters:
232230
DdForwarderBucketsAccessLogsTarget:
233231
Type: String
234232
Default: ""
235-
Description: (Optional) The name of the S3 bucket to store access logs. Leave empty if access logging is not needed.
233+
Description: (Optional) The name of the S3 bucket to store access logs. Leave empty if access logging is not needed.
236234
DdStoreFailedEvents:
237235
Type: String
238236
Default: false
@@ -353,12 +351,12 @@ Conditions:
353351
CreateS3Bucket:
354352
Fn::And:
355353
- Fn::Or:
356-
- Fn::Equals:
357-
- Ref: DdFetchLogGroupTags
358-
- true
359-
- Fn::Equals:
360-
- Ref: DdFetchLambdaTags
361-
- true
354+
- Fn::Equals:
355+
- Ref: DdFetchLogGroupTags
356+
- true
357+
- Fn::Equals:
358+
- Ref: DdFetchLambdaTags
359+
- true
362360
- Fn::Equals:
363361
- Ref: DdForwarderExistingBucketName
364362
- ""
@@ -437,7 +435,7 @@ Conditions:
437435
- Fn::Equals:
438436
- Ref: ReservedConcurrency
439437
- ""
440-
ShouldUseAccessLogBucket: !Not [!Equals [!Ref DdForwarderBucketsAccessLogsTarget, ""]]
438+
ShouldUseAccessLogBucket: !Not [!Equals [!Ref DdForwarderBucketsAccessLogsTarget, ""]]
441439
SetForwarderBucket:
442440
Fn::Or:
443441
- Condition: CreateS3Bucket
@@ -489,7 +487,6 @@ Resources:
489487
- layer
490488
- Datadog-Forwarder
491489
- Fn::FindInMap: [Constants, DdForwarder, LayerVersion]
492-
493490
Code:
494491
Fn::If:
495492
- UseZipCopier
@@ -501,12 +498,8 @@ Resources:
501498
S3Key:
502499
Fn::Sub:
503500
- "aws-dd-forwarder-${DdForwarderVersion}.zip"
504-
- {
505-
DdForwarderVersion:
506-
!FindInMap [Constants, DdForwarder, Version],
507-
}
501+
- {DdForwarderVersion: !FindInMap [Constants, DdForwarder, Version]}
508502
- ZipFile: " "
509-
510503
MemorySize:
511504
Ref: MemorySize
512505
Runtime: python3.11
@@ -690,7 +683,6 @@ Resources:
690683
- SecurityGroupIds: !Ref VPCSecurityGroupIds
691684
SubnetIds: !Ref VPCSubnetIds
692685
- Ref: AWS::NoValue
693-
694686
ForwarderRole:
695687
Type: AWS::IAM::Role
696688
Properties:
@@ -725,12 +717,12 @@ Resources:
725717
- s3:DeleteObject
726718
Resource:
727719
- Fn::If:
728-
- CreateS3Bucket
729-
- Fn::Join:
730-
- "/"
731-
- - Fn::GetAtt: ForwarderBucket.Arn
732-
- "*"
733-
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}/*"
720+
- CreateS3Bucket
721+
- Fn::Join:
722+
- "/"
723+
- - Fn::GetAtt: ForwarderBucket.Arn
724+
- "*"
725+
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}/*"
734726
Effect: Allow
735727
- Ref: AWS::NoValue
736728
# Get the actual log content from the s3 bucket based on the received s3 event.
@@ -741,9 +733,9 @@ Resources:
741733
- s3:ListBucket
742734
Resource:
743735
- Fn::If:
744-
- CreateS3Bucket
745-
- Fn::GetAtt: ForwarderBucket.Arn
746-
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}"
736+
- CreateS3Bucket
737+
- Fn::GetAtt: ForwarderBucket.Arn
738+
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}"
747739
Condition:
748740
StringLike:
749741
s3:prefix:
@@ -820,7 +812,6 @@ Resources:
820812
- DdForwarder
821813
- Version
822814
Key: dd_forwarder_version
823-
824815
CloudWatchLogsPermission:
825816
Type: AWS::Lambda::Permission
826817
Properties:
@@ -890,20 +881,18 @@ Resources:
890881
BlockPublicPolicy: true
891882
IgnorePublicAcls: true
892883
RestrictPublicBuckets: true
893-
LoggingConfiguration:
894-
!If
895-
- ShouldUseAccessLogBucket
896-
-
897-
DestinationBucketName: !Ref DdForwarderBucketsAccessLogsTarget
898-
LogFilePrefix: "datadog-forwarder/"
899-
- !Ref "AWS::NoValue"
884+
LoggingConfiguration: !If
885+
- ShouldUseAccessLogBucket
886+
- DestinationBucketName: !Ref DdForwarderBucketsAccessLogsTarget
887+
LogFilePrefix: "datadog-forwarder/"
888+
- !Ref "AWS::NoValue"
900889
LifecycleConfiguration:
901-
Rules:
902-
- Id: delete-incomplete-mpu-7days
903-
Prefix: ''
904-
AbortIncompleteMultipartUpload:
905-
DaysAfterInitiation: 7
906-
Status: Enabled
890+
Rules:
891+
- Id: delete-incomplete-mpu-7days
892+
Prefix: ""
893+
AbortIncompleteMultipartUpload:
894+
DaysAfterInitiation: 7
895+
Status: Enabled
907896
ForwarderBucketPolicy:
908897
Type: "AWS::S3::BucketPolicy"
909898
Condition: CreateS3Bucket
@@ -939,10 +928,7 @@ Resources:
939928
- !Ref SourceZipUrl
940929
- Fn::Sub:
941930
- "https://github.com/DataDog/datadog-serverless-functions/releases/download/aws-dd-forwarder-${DdForwarderVersion}/aws-dd-forwarder-${DdForwarderVersion}.zip"
942-
- {
943-
DdForwarderVersion:
944-
!FindInMap [Constants, DdForwarder, Version],
945-
}
931+
- {DdForwarderVersion: !FindInMap [Constants, DdForwarder, Version]}
946932
# The Forwarder's source code is too big to fit the inline code size limit for CloudFormation. In most of AWS
947933
# partitions and regions, the Forwarder is able to load its source code from a Lambda layer attached to it.
948934
# In places where Datadog can't/doesn't yet publish Lambda layers, use another Lambda to copy the source code
@@ -1059,20 +1045,20 @@ Resources:
10591045
- s3:DeleteObject
10601046
Resource:
10611047
- Fn::If:
1062-
- CreateS3Bucket
1063-
- Fn::Join:
1064-
- "/"
1065-
- - Fn::GetAtt: "ForwarderBucket.Arn"
1066-
- "*"
1067-
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}/*"
1048+
- CreateS3Bucket
1049+
- Fn::Join:
1050+
- "/"
1051+
- - Fn::GetAtt: "ForwarderBucket.Arn"
1052+
- "*"
1053+
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}/*"
10681054
- Effect: Allow
10691055
Action:
10701056
- s3:ListBucket
10711057
Resource:
10721058
- Fn::If:
1073-
- CreateS3Bucket
1074-
- Fn::GetAtt: "ForwarderBucket.Arn"
1075-
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}"
1059+
- CreateS3Bucket
1060+
- Fn::GetAtt: "ForwarderBucket.Arn"
1061+
- Fn::Sub: "arn:aws:s3:::${DdForwarderExistingBucketName}"
10761062
- !If
10771063
- SetS3SourceZip
10781064
- Effect: Allow

aws/logs_monitoring/tools/publish_prod.sh

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,53 @@
22

33
# Use with `./publish_prod.sh <DESIRED_NEW_VERSION>
44

5-
set -e
5+
set -o nounset -o pipefail -o errexit
66

7-
# Ensure on main, and pull the latest
8-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
9-
if [ $BRANCH != "master" ]; then
10-
echo "Not on master, aborting"
7+
log_info() {
8+
local BLUE='\033[0;34m'
9+
local RESET='\033[0m'
10+
11+
printf -- "%b%b%b\n" "${BLUE}" "${*}" "${RESET}" 1>&2
12+
}
13+
14+
log_error() {
15+
local RED='\033[0;31m'
16+
local RESET='\033[0m'
17+
18+
printf -- "%b%b%b\n" "${RED}" "${*}" "${RESET}" 1>&2
1119
exit 1
12-
else
13-
echo "Updating master"
14-
git pull origin master
20+
}
21+
22+
# Ensure on main, and pull the latest
23+
if [[ $(git rev-parse --abbrev-ref HEAD) != "master" ]]; then
24+
log_error "Not on master, aborting"
1525
fi
1626

1727
# Ensure no uncommitted changes
18-
if [ -n "$(git status --porcelain)" ]; then
19-
echo "Detected uncommitted changes, aborting"
20-
exit 1
28+
if ! git diff --quiet; then
29+
log_error "Detected uncommitted changes, aborting"
2130
fi
2231

2332
# Read the new version
24-
if [ -z "$1" ]; then
25-
echo "Must specify a layer version"
26-
exit 1
27-
else
28-
LAYER_VERSION=$1
33+
if [[ -z ${1:-} ]]; then
34+
log_error "Must specify a layer version"
2935
fi
3036

37+
LAYER_VERSION=$1
38+
3139
# Read the new version
32-
if [ -z "$2" ]; then
33-
echo "Must specify a forwarder version"
34-
exit 1
35-
else
36-
FORWARDER_VERSION=$2
40+
if [[ -z ${2:-} ]]; then
41+
log_error "Must specify a forwarder version"
3742
fi
3843

44+
FORWARDER_VERSION=$2
45+
3946
# Ensure AWS access before proceeding
4047
aws-vault exec sso-govcloud-us1-fed-engineering -- aws sts get-caller-identity
4148
aws-vault exec sso-prod-engineering -- aws sts get-caller-identity
4249

43-
echo "Publishing layers to GovCloud AWS regions"
50+
log_info "Publishing layers to GovCloud AWS regions"
4451
LAYER_VERSION="${LAYER_VERSION}" FORWARDER_VERSION"=${FORWARDER_VERSION}" aws-vault exec sso-govcloud-us1-fed-engineering -- ./tools/publish_layers.sh
4552

46-
echo
47-
echo "Publishing layers to commercial AWS regions"
53+
log_info "Publishing layers to commercial AWS regions"
4854
LAYER_VERSION="${LAYER_VERSION}" FORWARDER_VERSION"=${FORWARDER_VERSION}" aws-vault exec sso-prod-engineering -- ./tools/publish_layers.sh

aws/logs_monitoring/trace_forwarder/README.md

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Datadog Trace Forwarder
22

3-
Shared libary for submitting traces to trace intake.
3+
Shared libary for submitting traces to trace intake.
44
Features include:
5-
* Tools for building AWS Lambda Layer from library
6-
* Trace obfuscation, (using logic from datadog-agent)
7-
* Submits Stats/Transcations for traces
8-
* Python bindings
5+
6+
- Tools for building AWS Lambda Layer from library
7+
- Trace obfuscation, (using logic from datadog-agent)
8+
- Submits Stats/Transcations for traces
9+
- Python bindings
910

1011
```python
1112
from trace_forwarder.connection import TraceConnection
@@ -42,9 +43,9 @@ conn.send("""
4243

4344
## Requirements
4445

45-
* dep
46-
* go 1.12 or higher
47-
* docker
46+
- dep
47+
- go 1.12 or higher
48+
- docker
4849

4950
## Building Go Binary
5051

@@ -58,24 +59,3 @@ Output is saved to bin, and the shared library will be compatible with your loca
5859
```bash
5960
./scripts/build_linux_go_bin.sh
6061
```
61-
62-
## Lambda Layer
63-
### Building Lambda Layer
64-
65-
You can build the lambda layer with the following command
66-
67-
```bash
68-
./scripts/build_layers.sh
69-
```
70-
71-
### Publishing to staging
72-
73-
```bash
74-
./scripts/publish_staging.sh
75-
```
76-
77-
### Publishing to prod
78-
79-
```bash
80-
./scripts/publish_prod.sh
81-
```

0 commit comments

Comments
 (0)