Skip to content

Commit 912711d

Browse files
ddelnanovihangm
andauthored
Upgrade go to 1.20.4 and fix go version detection to address test failures (#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>
1 parent cb18a3d commit 912711d

6 files changed

Lines changed: 36 additions & 12 deletions

File tree

WORKSPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pl_go_overrides()
3333

3434
go_download_sdk(
3535
name = "go_sdk",
36-
version = "1.20.2",
36+
version = "1.20.4",
3737
)
3838

3939
go_rules_dependencies()
@@ -231,12 +231,12 @@ go_download_sdk(
231231

232232
go_download_sdk(
233233
name = "go_sdk_1_19",
234-
version = "1.19.7",
234+
version = "1.19.9",
235235
)
236236

237237
go_download_sdk(
238238
name = "go_sdk_1_20",
239-
version = "1.20.2",
239+
version = "1.20.4",
240240
)
241241

242242
pip_parse(

docker.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DOCKER_IMAGE_TAG=202305050100
2-
LINTER_IMAGE_DIGEST=9d37b36e898e9e056126854689649c884d7751f3abe7d377d9cb6acb39bcf97e
3-
DEV_IMAGE_DIGEST=c211563cf1163e740fcab8f385226c9bf80f4eabf061a739b0aaa7fcd5fce6f4
4-
DEV_IMAGE_WITH_EXTRAS_DIGEST=b5c273d4d9766d05c7c092b212bda379b6125c45112b167bd3144c083889cb77
1+
DOCKER_IMAGE_TAG=202305092241
2+
LINTER_IMAGE_DIGEST=e931f126300a52976e8a64898cff1e10c4208e4bbe99e0b393df359ba4374b53
3+
DEV_IMAGE_DIGEST=19bdb2ec8d50e2c8640641a70fe3c8cf3c9099cfb2ef19011c920e38cf4d0e93
4+
DEV_IMAGE_WITH_EXTRAS_DIGEST=e4a2fa72a7d23d91096d34ea61f4f56b77842ee8afe4d79fc0c9158ec5287a93

src/stirling/obj_tools/go_syms.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace obj_tools {
2727
// This symbol points to a static string variable that describes the Golang tool-chain version used
2828
// to build the executable. This symbol is embedded in a Golang executable's data section.
2929
constexpr std::string_view kGoBuildVersionSymbol = "runtime.buildVersion";
30+
constexpr std::string_view kGoBuildVersionStrSymbol = "runtime.buildVersion.str";
3031

3132
namespace {
3233

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

47+
// TODO(ddelnano): Between Go 1.20.2 and 1.20.4 our build version detection started failing.
48+
// Our version detection's assumptions is very different from how Go does this internally
49+
// and needs a signficant rehaul. That is being tracked in
50+
// https://github.com/pixie-io/pixie/issues/1318 but in the meantime optimisitcally read the
51+
// runtime.buildVersion.str before following our previous heuristic.
52+
StatusOr<std::string> ReadBuildVersionDirect(ElfReader* elf_reader) {
53+
auto str_symbol_status = elf_reader->SearchTheOnlySymbol(kGoBuildVersionStrSymbol);
54+
if (!str_symbol_status.ok()) {
55+
return error::NotFound("Unable to find runtime.buildVersion.str");
56+
}
57+
auto str_symbol = str_symbol_status.ValueOrDie();
58+
PX_ASSIGN_OR_RETURN(auto symbol_bytecode, elf_reader->SymbolByteCode(".rodata", str_symbol));
59+
return std::string(reinterpret_cast<const char*>(symbol_bytecode.data()),
60+
symbol_bytecode.size() - 1);
61+
}
62+
4663
StatusOr<std::string> ReadBuildVersion(ElfReader* elf_reader) {
64+
auto direct_version_str = ReadBuildVersionDirect(elf_reader);
65+
if (!direct_version_str.ok()) {
66+
LOG(INFO) << absl::Substitute(
67+
"Falling back to the runtime.buildVersion symbol for go version detection");
68+
} else {
69+
return direct_version_str;
70+
}
4771
PX_ASSIGN_OR_RETURN(ElfReader::SymbolInfo symbol,
4872
elf_reader->SearchTheOnlySymbol(kGoBuildVersionSymbol));
4973

src/stirling/obj_tools/go_syms_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST(ReadBuildVersionTest, WorkingOnBasicGoBinary) {
3636
const std::string kPath = px::testing::BazelRunfilePath(kTestGoBinaryPath);
3737
ASSERT_OK_AND_ASSIGN(std::unique_ptr<ElfReader> elf_reader, ElfReader::Create(kPath));
3838
ASSERT_OK_AND_ASSIGN(std::string version, ReadBuildVersion(elf_reader.get()));
39-
EXPECT_THAT(version, StrEq("go1.19.7"));
39+
EXPECT_THAT(version, StrEq("go1.19.9"));
4040
}
4141

4242
TEST(IsGoExecutableTest, WorkingOnBasicGoBinary) {

tools/chef/cookbooks/px_dev/attributes/linux.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
'648b599397548e4bb92429eec6391374c2cbb0edb835e3b3f03d4281c011f401'
3434

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

4040
default['golangci-lint']['download_path'] =
4141
'https://github.com/golangci/golangci-lint/releases/download/v1.51.1/golangci-lint-1.51.1-linux-amd64.tar.gz'

tools/chef/cookbooks/px_dev/attributes/mac_os_x.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
'8d3709d957c7115610e764621569728be102d213fee15bc1d1aa9d465eb2c258'
3535

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

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

0 commit comments

Comments
 (0)