Skip to content

Commit

Permalink
chore: test with go1.24-rc.1 (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller authored Dec 19, 2024
1 parent fc38e19 commit 28d8094
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
- macos
- ubuntu
- windows
go-version: [oldstable, stable]
go-version: [oldstable, stable, '~1.24.0-rc.1']
build-mode: [DRIVER]
include:
# Alternate build modes (only on ubuntu, latest go; to save CI time)
Expand Down
2 changes: 1 addition & 1 deletion _integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ replace github.com/DataDog/orchestrion => ../
require (
cloud.google.com/go/pubsub v1.45.1
github.com/99designs/gqlgen v0.17.57
github.com/DataDog/go-libddwaf/v3 v3.5.1
github.com/DataDog/orchestrion v1.0.1
github.com/IBM/sarama v1.43.3
github.com/Shopify/sarama v1.38.1
Expand Down Expand Up @@ -87,7 +88,6 @@ require (
github.com/DataDog/datadog-agent/pkg/util/log v0.59.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.1 // indirect
github.com/DataDog/datadog-go/v5 v5.5.0 // indirect
github.com/DataDog/go-libddwaf/v3 v3.5.1 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.3 // indirect
github.com/DataDog/go-sqllexer v0.0.17 // indirect
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
Expand Down
4 changes: 4 additions & 0 deletions _integration-tests/tests/os/lfi.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"datadoghq.dev/orchestrion/_integration-tests/utils"
"datadoghq.dev/orchestrion/_integration-tests/validator/trace"
waf "github.com/DataDog/go-libddwaf/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/DataDog/dd-trace-go.v1/appsec/events"
Expand All @@ -33,6 +34,9 @@ func (tc *TestCase) Setup(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("appsec does not support Windows")
}
if ok, err := waf.Health(); !ok {
t.Skip("WAF is not available:", err)
}

t.Setenv("DD_APPSEC_RULES", "../testdata/rasp-only-rules.json")
t.Setenv("DD_APPSEC_ENABLED", "true")
Expand Down
21 changes: 18 additions & 3 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"time"

"github.com/DataDog/orchestrion/internal/filelock"
"github.com/DataDog/orchestrion/internal/goflags"
"github.com/DataDog/orchestrion/internal/jobserver"
"github.com/DataDog/orchestrion/internal/jobserver/client"
"github.com/DataDog/orchestrion/internal/log"
"github.com/fsnotify/fsnotify"
"gopkg.in/yaml.v3"

"github.com/urfave/cli/v2"
)
Expand All @@ -32,18 +34,31 @@ var Server = &cli.Command{
},
&cli.IntFlag{
Name: "port",
Usage: "Choose a port to listen on",
Usage: "Choose a port to listen on.",
Value: -1,
DefaultText: "random",
},
&cli.DurationFlag{
Name: "inactivity-timeout",
Usage: "Automatically shut down after a period without any connected client",
Usage: "Automatically shut down after a period without any connected client.",
Value: time.Minute,
},
&cli.BoolFlag{
Name: "nats-logging",
Usage: "Enable NATS server logging",
Usage: "Enable NATS server logging.",
},
&cli.StringFlag{
Name: "build-flags",
Usage: "Specify the 'go build' flags to use when resolving packages. This is specified as a YAML array and must start with a valid go subcommand (e.g, 'build').",
DefaultText: "Looked up the process hierarchy",
Action: func(_ *cli.Context, val string) error {
var args []string
if err := yaml.Unmarshal([]byte(val), &args); err != nil {
return cli.Exit(fmt.Errorf("invalid -build-flags value: %w", err), 2)
}
goflags.SetFlags(".", args)
return nil
},
},
},
Hidden: true,
Expand Down
15 changes: 10 additions & 5 deletions internal/jobserver/pkgs/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *service) resolve(req *ResolveRequest) (ResolveResponse, error) {
}

resp, err := s.resolved.Load(reqHash, func() (ResolveResponse, error) {
log.Tracef("[JOBSERVER] pkgs.Resolve(%s in %s)\n", req.Pattern, req.Dir)
log.Debugf("[JOBSERVER] pkgs.Resolve(%s in %s)\n", req.Pattern, req.Dir)

env := req.Env
if req.toolexecImportpath != "" {
Expand Down Expand Up @@ -152,21 +152,26 @@ func (s *service) resolve(req *ResolveRequest) (ResolveResponse, error) {
Mode:
// We need the export file (the whole point of the resolution)
packages.NeedExportFile |
// We want to also resolve transitive dependencies, so we need Deps & Imports
packages.NeedDeps | packages.NeedImports |
// We want to also resolve transitive dependencies, so we need Deps & Imports. We also
// need CompiledGoFiles in order to see imports possibly added by the toolchain (cgo,
// cover, etc...)
packages.NeedCompiledGoFiles | packages.NeedDeps | packages.NeedImports |
// Finally, we need the resolved package import path
packages.NeedName,
Dir: req.Dir,
Env: env,
BuildFlags: buildFlags,
Logf: func(format string, args ...any) { log.Infof("[JOBSERVER] packages.Load -- "+format+"\n", args...) },
Logf: func(format string, args ...any) { log.Tracef("[JOBSERVER] packages.Load -- "+format+"\n", args...) },
},
req.Pattern,
)
if err != nil {
log.Errorf("[JOBSERVER] pkgs.Resolve(%s) failed: %v\n", req.Pattern, err)
return nil, err
}
if len(pkgs) == 0 {
return nil, fmt.Errorf("no packages returned for pattern: %q", req.Pattern)
}

resp := make(ResolveResponse)
var errs error
Expand All @@ -179,7 +184,7 @@ func (s *service) resolve(req *ResolveRequest) (ResolveResponse, error) {
return nil, errs
}

log.Tracef("[JOBSERVER] pkgs.Resolve(%s) result: %#v\n", req.Pattern, resp)
log.Debugf("[JOBSERVER] pkgs.Resolve(%s) result: %#v\n", req.Pattern, resp)
return resp, nil
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/toolexec/aspect/linkdeps/linkdeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func FromImportConfig(importcfg *importcfg.ImportConfig) (LinkDeps, error) {
return LinkDeps{}, fmt.Errorf("reading %s from %s=%s: %w", Filename, importPath, archivePath, err)
}

for _, dep := range ld.Dependencies() {
for dep := range ld.deps {
if _, satisfied := importcfg.PackageFile[dep]; satisfied {
// This transitive link-time dependency is already satisfied at
// compile-time, so we don't need to carry it over.
Expand Down
50 changes: 28 additions & 22 deletions internal/toolexec/aspect/oncompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,39 @@ func (w Weaver) OnCompile(cmd *proxy.CompileCommand) (err error) {
log.Debugf("Recording synthetic dependency: %q => %v\n", depImportPath, kind)
linkDeps.Add(depImportPath)

if kind == typed.ImportStatement {
// Imported packages need to be provided in the compilation's importcfg file
deps, err := resolvePackageFiles(depImportPath, cmd.WorkDir)
if kind != typed.ImportStatement {
// We cannot attempt to resolve link-time dependencies (relocation targets), as these are
// typically used to avoid creating dependency cycles. Corrollary to this, the `link.deps`
// file will not contain transitive closures for these packages, so we need to resolve these
// at link-time.
continue
}

// Imported packages need to be provided in the compilation's importcfg file
deps, err := resolvePackageFiles(depImportPath, cmd.WorkDir)
if err != nil {
return fmt.Errorf("resolving woven dependency on %s: %w", depImportPath, err)
}
for dep, archive := range deps {
deps, err := linkdeps.FromArchive(archive)
if err != nil {
return fmt.Errorf("resolving woven dependency on %s: %w", depImportPath, err)
return fmt.Errorf("reading %s from %s[%s]: %w", linkdeps.Filename, dep, archive, err)
}
for dep, archive := range deps {
deps, err := linkdeps.FromArchive(archive)
if err != nil {
return fmt.Errorf("reading %s from %s[%s]: %w", linkdeps.Filename, dep, archive, err)
}
log.Debugf("Processing %s dependencies from %s...\n", linkdeps.Filename, dep)
for _, tDep := range deps.Dependencies() {
if _, found := imports.PackageFile[tDep]; !found {
log.Debugf("Copying transitive %s dependency on %q inherited from %q via %q\n", linkdeps.Filename, tDep, depImportPath, dep)
linkDeps.Add(tDep)
}
log.Debugf("Processing %s dependencies from %s...\n", linkdeps.Filename, dep)
for _, tDep := range deps.Dependencies() {
if _, found := imports.PackageFile[tDep]; !found {
log.Debugf("Copying transitive %s dependency on %q inherited from %q via %q\n", linkdeps.Filename, tDep, depImportPath, dep)
linkDeps.Add(tDep)
}
}

if _, ok := imports.PackageFile[dep]; ok {
// Already part of natural dependencies, nothing to do...
continue
}
log.Debugf("Recording transitive dependency of %q: %q => %q\n", depImportPath, dep, archive)
imports.PackageFile[dep] = archive
regUpdated = true
if _, ok := imports.PackageFile[dep]; ok {
// Already part of natural dependencies, nothing to do...
continue
}
log.Debugf("Recording transitive dependency of %q: %q => %q\n", depImportPath, dep, archive)
imports.PackageFile[dep] = archive
regUpdated = true
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/toolexec/aspect/onlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (Weaver) OnLink(cmd *proxy.LinkCommand) error {
continue
}

log.Tracef("Resolving %s dependency on %q...\n", linkdeps.Filename, depPath)
deps, err := resolvePackageFiles(depPath, cmd.WorkDir)
if err != nil {
return fmt.Errorf("resolving %q: %w", depPath, err)
Expand Down
8 changes: 8 additions & 0 deletions internal/toolexec/aspect/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ func resolvePackageFiles(importPath string, workDir string) (map[string]string,
}

// Check for missing archives...
var found bool
for ip, arch := range archives {
if arch == "" {
return nil, fmt.Errorf("failed to resolve archive for %q", ip)
}
if ip == importPath {
found = true
}
}

if !found {
return nil, fmt.Errorf("resolution did not include requested package %q", importPath)
}

return archives, nil
Expand Down

0 comments on commit 28d8094

Please sign in to comment.