Skip to content

Commit

Permalink
Make collect-info multi-arch compatible, providing arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Jul 22, 2024
1 parent f246161 commit 8a77cc4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ hs_err_pid*
ds-collector.tar.gz
ds-collector.*.tar.gz
collector/
ds-collector/collect-info
ds-collector/collect-info*
ds-collector/logs
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
.PHONY: collector

collector: check-env generate-key
@docker run --rm --privileged multiarch/qemu-user-static:register
# assumes we're building on amd64 and need qemu for arm64
@test -f /usr/bin/qemu-aarch64-static
@cp -R ds-collector/ collector
@rm -f collector/collect-info
@cd collector ; docker run --rm -v $$PWD:/volume -w /volume -t clux/muslrust rustc --target x86_64-unknown-linux-musl rust-commands/*.rs ; cd -
@test -f collector/collect-info
@cd collector ; docker run --rm --platform linux/arm64 -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static -v $$PWD:/volume -w /volume -t clux/muslrust rustc --target aarch64-unknown-linux-musl rust-commands/*.rs ; mv collect-info collect-info.aarch64-unknown-linux-musl ; cd -
@cd collector ; docker run --rm --platform linux/amd64 -v $$PWD:/volume -w /volume -t clux/muslrust rustc --target x86_64-unknown-linux-musl rust-commands/*.rs ; mv collect-info collect-info.x86_64-unknown-linux-musl ; cd -
@test -f collector/collect-info.aarch64-unknown-linux-musl
@test -f collector/collect-info.x86_64-unknown-linux-musl
@rm -f collector/collector.hosts
@rm -f collector/collector.conf
@mv collector/collector.hosts.in collector/collector.hosts
Expand Down
2 changes: 1 addition & 1 deletion ds-collector-tests/integration-bastion.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y openssh-server locales sshpass procps ethtool netcat net-tools sysstat pciutils ntp ntpstat numactl lvm2 curl xxd
RUN apt-get update && apt-get install -y openssh-server locales sshpass procps ethtool netcat-traditional net-tools sysstat pciutils ntp ntpstat numactl lvm2 curl xxd qemu binfmt-support qemu-user-static


RUN mkdir /var/run/sshd
Expand Down
23 changes: 20 additions & 3 deletions ds-collector/ds-collector
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#!/bin/bash
#
# ds-collector
#
# Collect artifacts and ship for analysis
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# ds-collector :: Collect artifacts and ship for analysis
#
# The following are expected to be installed on the Cassandra/DSE nodes:
# blockdev
Expand Down Expand Up @@ -966,7 +978,12 @@ get_info() {
node_push "$0" "$baseDir/$targetFile"
node_push "${script_directory}/${prometheus}" "$baseDir/${prometheus}"
node_push "${script_directory}/$dstat" "$baseDir/$dstat"
node_push "${script_directory}/collect-info" "$baseDir/collect-info"
if [ "arm64" == "$(node_connect 'arch')" ] ; then
collect_info_binary = "collect-info.aarch64-unknown-linux-musl"
else
collect_info_binary = "collect-info.x86_64-unknown-linux-musl"
fi
node_push "${script_directory}/${collect_info_binary}" "$baseDir/collect-info"

node_connect "mkdir -p $baseDir/etc"
for f in ${script_directory}/etc/*; do
Expand Down
25 changes: 24 additions & 1 deletion ds-collector/rust-commands/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
## Compile rust binaries for Linux
## Compile rust binaries for Linux amd64 and arm64

docker run -v $PWD:/volume -w /volume -t clux/muslrust rustc --target x86_64-unknown-linux-musl *.rs

On Mac aarch:

docker run --platform linux/arm64 -v $PWD:/volume -w /volume -t clux/muslrust rustc --target aarch64-unknown-linux-musl *.rs

cp collect-info collect-info.aarch64-unknown-linux-musl

docker run --platform linux/amd64 -v $PWD:/volume -w /volume -t clux/muslrust rustc --target x86_64-unknown-linux-musl *.rs

cp collect-info collect-info.x86_64-unknown-linux-musl

On Linux:

docker run --rm --privileged multiarch/qemu-user-static:register

sudo apt-get install -y qemu binfmt-support qemu-user-static

docker run --platform linux/arm64 -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static -v $PWD:/volume -w /volume -t clux/muslrust rustc --target aarch64-unknown-linux-musl *.rs

cp collect-info collect-info.aarch64-unknown-linux-musl

docker run --platform linux/amd64 -v $PWD:/volume -w /volume -t clux/muslrust rustc --target x86_64-unknown-linux-musl *.rs

cp collect-info collect-info.x86_64-unknown-linux-musl

0 comments on commit 8a77cc4

Please sign in to comment.