Skip to content

Commit 137ef22

Browse files
chore: grab module from s3 bucket and skip version validation (#151)
1 parent 358016f commit 137ef22

File tree

3 files changed

+9
-80
lines changed

3 files changed

+9
-80
lines changed

installer/configurator/configurator.go

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ func main() {
128128
handleError(err, sender, *appID, *dryRun)
129129
}
130130

131+
// TODO: Re-enable once we again have signatures available
132+
if !*skipVerify {
133+
log.Debug("Temporarily skipping module signature verification")
134+
*skipVerify = true
135+
}
136+
131137
if err := configurator.DownloadAndInstallModule(*arch, *skipVerify); err != nil {
132138
handleError(err, sender, *appID, *dryRun)
133139
}

installer/configurator/nginx_configurator.go

+3-17
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ func (n *NginxConfigurator) VerifyRequirements() error {
4545
log.Info("Detected NGINX version: ", n.Version)
4646
IntegrationVersion = n.Version
4747

48-
minSupportedVersion, maxSupportedVersion, err := getSupportedModuleVersions()
49-
if err != nil {
50-
return NewInstallerError(NginxError, fmt.Errorf("could not retrieve the supported versions for nginx-datadog"))
51-
}
52-
53-
log.Debug(fmt.Sprintf("Got lowest and highest supported versions for nginx-datadog from module release assets: [%s-%s]", minSupportedVersion, maxSupportedVersion))
54-
55-
if compareVersions(n.Version, minSupportedVersion) < 0 || compareVersions(n.Version, maxSupportedVersion) > 0 {
56-
return NewInstallerError(NginxError, fmt.Errorf("nginx version %s is not supported, must be in range [%s-%s]", n.Version, minSupportedVersion, maxSupportedVersion))
57-
}
58-
59-
log.Info("The installed NGINX version is supported")
60-
6148
return nil
6249
}
6350

@@ -142,14 +129,13 @@ func (n *NginxConfigurator) DownloadAndInstallModule(arch string, skipVerify boo
142129
return err
143130
}
144131

145-
// TODO: Use the releases once the module is actually released with RUM
146-
// baseURL := fmt.Sprintf("https://github.com/DataDog/nginx-datadog/releases/latest/download/")
147-
baseURL := "https://ddagent-windows-unstable.s3.amazonaws.com/inject-browser-sdk/nginx/latest/"
132+
baseURL := "https://rum-auto-instrumentation.s3.us-east-1.amazonaws.com/nginx/latest/"
148133
moduleURL := baseURL + fmt.Sprintf("ngx_http_datadog_module-%s-%s.so.tgz", arch, n.Version)
149134

150135
moduleContent, err := downloadFile(moduleURL)
151136
if err != nil {
152-
return NewInstallerError(NginxError, fmt.Errorf("failed to download module: %v", err))
137+
return NewInstallerError(NginxError, fmt.Errorf("failed to download module %s. "+
138+
"This is likely because this NGINX version (%s) is not supported: %v", moduleURL, n.Version, err))
153139
}
154140

155141
tmpDir, err := os.MkdirTemp("", "nginx-module-verification")

installer/configurator/utils.go

-63
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,15 @@ package main
33
import (
44
"archive/tar"
55
"compress/gzip"
6-
"context"
76
"fmt"
87
"io"
98
"os"
109
"path/filepath"
11-
"regexp"
12-
"strconv"
1310
"strings"
1411

15-
"github.com/google/go-github/github"
16-
1712
log "github.com/sirupsen/logrus"
1813
)
1914

20-
func getSupportedModuleVersions() (string, string, error) {
21-
client := github.NewClient(nil)
22-
23-
release, _, err := client.Repositories.GetLatestRelease(context.Background(), "DataDog", "nginx-datadog")
24-
if err != nil {
25-
return "", "", NewInstallerError(NginxError, fmt.Errorf("error getting latest release for the NGINX module: %v", err))
26-
}
27-
28-
log.Debug("Got latest release for the NGINX module")
29-
30-
re := regexp.MustCompile(`ngx_http_datadog_module-(?:amd64|arm64)-(\d+\.\d+\.\d+)\.so\.tgz`)
31-
32-
lowestVersion, highestVersion := "", ""
33-
for _, asset := range release.Assets {
34-
matches := re.FindStringSubmatch(*asset.Name)
35-
if len(matches) > 1 {
36-
version := matches[1]
37-
if lowestVersion == "" || compareVersions(version, lowestVersion) < 0 {
38-
lowestVersion = version
39-
}
40-
if highestVersion == "" || compareVersions(version, highestVersion) > 0 {
41-
highestVersion = version
42-
}
43-
}
44-
}
45-
46-
if lowestVersion == "" || highestVersion == "" {
47-
return "", "", NewInstallerError(NginxError, fmt.Errorf("no valid version found for the NGINX module in the release assets"))
48-
}
49-
50-
return lowestVersion, highestVersion, nil
51-
}
52-
53-
func compareVersions(v1, v2 string) int {
54-
v1Segments := strings.Split(v1, ".")
55-
v2Segments := strings.Split(v2, ".")
56-
57-
for i := 0; i < len(v1Segments) && i < len(v2Segments); i++ {
58-
v1digit, _ := strconv.Atoi(v1Segments[i])
59-
v2digit, _ := strconv.Atoi(v2Segments[i])
60-
if v1digit < v2digit {
61-
return -1
62-
}
63-
if v1digit > v2digit {
64-
return 1
65-
}
66-
}
67-
68-
if len(v1Segments) < len(v2Segments) {
69-
return -1
70-
}
71-
if len(v1Segments) > len(v2Segments) {
72-
return 1
73-
}
74-
75-
return 0
76-
}
77-
7815
func extractTarGzFile(srcPath, destPath string) error {
7916
file, err := os.Open(srcPath)
8017
if err != nil {

0 commit comments

Comments
 (0)