Skip to content

Commit

Permalink
Upgrade go to 1.20.4 and fix go version detection to address test fai…
Browse files Browse the repository at this point in the history
…lures (#1319)

Summary: This upgrades our golang SDKs to the latest patch version
to pull in bug fixes and security fixes.

Our go tls tracing tests failed with this minor version upgrade. These
failures are due to our go version detection failing, which prevents
stirling from adding uprobes to the application. For now I've applied a
temporary fix for our go version detection, but in #1300 and #1318 we
need to revamp how this detection works since it has issues with 32 bit
binaries and now binaries built for go 1.20.4 and later.

Relevant Issues: N/A

Type of change: /kind cleanup

Test Plan: Existing tests should provide enough coverage.
- [x] Verified that `go_tls_trace_bpf_tests` failing on #1266 pass
([P381](https://phab.corp.pixielabs.ai/P381))

---------

Signed-off-by: Vihang Mehta <vihang@pixielabs.ai>
Signed-off-by: Dom Del Nano <ddelnano@pixielabs.ai>
Co-authored-by: Vihang Mehta <vihang@pixielabs.ai>
  • Loading branch information
ddelnano and vihangm authored May 10, 2023
1 parent cb18a3d commit 912711d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pl_go_overrides()

go_download_sdk(
name = "go_sdk",
version = "1.20.2",
version = "1.20.4",
)

go_rules_dependencies()
Expand Down Expand Up @@ -231,12 +231,12 @@ go_download_sdk(

go_download_sdk(
name = "go_sdk_1_19",
version = "1.19.7",
version = "1.19.9",
)

go_download_sdk(
name = "go_sdk_1_20",
version = "1.20.2",
version = "1.20.4",
)

pip_parse(
Expand Down
8 changes: 4 additions & 4 deletions docker.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_IMAGE_TAG=202305050100
LINTER_IMAGE_DIGEST=9d37b36e898e9e056126854689649c884d7751f3abe7d377d9cb6acb39bcf97e
DEV_IMAGE_DIGEST=c211563cf1163e740fcab8f385226c9bf80f4eabf061a739b0aaa7fcd5fce6f4
DEV_IMAGE_WITH_EXTRAS_DIGEST=b5c273d4d9766d05c7c092b212bda379b6125c45112b167bd3144c083889cb77
DOCKER_IMAGE_TAG=202305092241
LINTER_IMAGE_DIGEST=e931f126300a52976e8a64898cff1e10c4208e4bbe99e0b393df359ba4374b53
DEV_IMAGE_DIGEST=19bdb2ec8d50e2c8640641a70fe3c8cf3c9099cfb2ef19011c920e38cf4d0e93
DEV_IMAGE_WITH_EXTRAS_DIGEST=e4a2fa72a7d23d91096d34ea61f4f56b77842ee8afe4d79fc0c9158ec5287a93
24 changes: 24 additions & 0 deletions src/stirling/obj_tools/go_syms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace obj_tools {
// This symbol points to a static string variable that describes the Golang tool-chain version used
// to build the executable. This symbol is embedded in a Golang executable's data section.
constexpr std::string_view kGoBuildVersionSymbol = "runtime.buildVersion";
constexpr std::string_view kGoBuildVersionStrSymbol = "runtime.buildVersion.str";

namespace {

Expand All @@ -43,7 +44,30 @@ bool IsGoExecutable(ElfReader* elf_reader) {
return elf_reader->SearchTheOnlySymbol(obj_tools::kGoBuildVersionSymbol).ok();
}

// TODO(ddelnano): Between Go 1.20.2 and 1.20.4 our build version detection started failing.
// Our version detection's assumptions is very different from how Go does this internally
// and needs a signficant rehaul. That is being tracked in
// https://github.com/pixie-io/pixie/issues/1318 but in the meantime optimisitcally read the
// runtime.buildVersion.str before following our previous heuristic.
StatusOr<std::string> ReadBuildVersionDirect(ElfReader* elf_reader) {
auto str_symbol_status = elf_reader->SearchTheOnlySymbol(kGoBuildVersionStrSymbol);
if (!str_symbol_status.ok()) {
return error::NotFound("Unable to find runtime.buildVersion.str");
}
auto str_symbol = str_symbol_status.ValueOrDie();
PX_ASSIGN_OR_RETURN(auto symbol_bytecode, elf_reader->SymbolByteCode(".rodata", str_symbol));
return std::string(reinterpret_cast<const char*>(symbol_bytecode.data()),
symbol_bytecode.size() - 1);
}

StatusOr<std::string> ReadBuildVersion(ElfReader* elf_reader) {
auto direct_version_str = ReadBuildVersionDirect(elf_reader);
if (!direct_version_str.ok()) {
LOG(INFO) << absl::Substitute(
"Falling back to the runtime.buildVersion symbol for go version detection");
} else {
return direct_version_str;
}
PX_ASSIGN_OR_RETURN(ElfReader::SymbolInfo symbol,
elf_reader->SearchTheOnlySymbol(kGoBuildVersionSymbol));

Expand Down
2 changes: 1 addition & 1 deletion src/stirling/obj_tools/go_syms_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST(ReadBuildVersionTest, WorkingOnBasicGoBinary) {
const std::string kPath = px::testing::BazelRunfilePath(kTestGoBinaryPath);
ASSERT_OK_AND_ASSIGN(std::unique_ptr<ElfReader> elf_reader, ElfReader::Create(kPath));
ASSERT_OK_AND_ASSIGN(std::string version, ReadBuildVersion(elf_reader.get()));
EXPECT_THAT(version, StrEq("go1.19.7"));
EXPECT_THAT(version, StrEq("go1.19.9"));
}

TEST(IsGoExecutableTest, WorkingOnBasicGoBinary) {
Expand Down
4 changes: 2 additions & 2 deletions tools/chef/cookbooks/px_dev/attributes/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
'648b599397548e4bb92429eec6391374c2cbb0edb835e3b3f03d4281c011f401'

default['golang']['download_path'] =
'https://go.dev/dl/go1.20.2.linux-amd64.tar.gz'
'https://go.dev/dl/go1.20.4.linux-amd64.tar.gz'
default['golang']['sha256'] =
'4eaea32f59cde4dc635fbc42161031d13e1c780b87097f4b4234cfce671f1768'
'698ef3243972a51ddb4028e4a1ac63dc6d60821bf18e59a807e051fee0a385bd'

default['golangci-lint']['download_path'] =
'https://github.com/golangci/golangci-lint/releases/download/v1.51.1/golangci-lint-1.51.1-linux-amd64.tar.gz'
Expand Down
4 changes: 2 additions & 2 deletions tools/chef/cookbooks/px_dev/attributes/mac_os_x.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
'8d3709d957c7115610e764621569728be102d213fee15bc1d1aa9d465eb2c258'

default['golang']['download_path'] =
'https://go.dev/dl/go1.20.2.darwin-amd64.tar.gz'
'https://go.dev/dl/go1.20.4.darwin-amd64.tar.gz'
default['golang']['sha256'] =
'c93b8ced9517d07e1cd4c362c6e2d5242cb139e29b417a328fbf19aded08764c'
'242b099b5b9bd9c5d4d25c041216bc75abcdf8e0541aec975eeabcbce61ad47f'

default['golangci-lint']['download_path'] =
'https://github.com/golangci/golangci-lint/releases/download/v1.51.1/golangci-lint-1.51.1-darwin-amd64.tar.gz'
Expand Down

0 comments on commit 912711d

Please sign in to comment.