Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-27837: add aarch64 support #20

Merged
merged 17 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build docker images
on:
push:
paths:
- 'test/run_tests/Dockerfile_*'
- 'test/run_tests/Dockerfile_*'
# Allows running this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -27,18 +27,24 @@ jobs:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Extract metadata (tags, labels) for Docker (both ARM and AMD64)
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }} # e.g. apm_ruby_ubuntu
flavor: |
latest=true

Expand All @@ -47,7 +53,7 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64, linux/arm64
file: test/run_tests/Dockerfile_${{ matrix.os }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

4 changes: 2 additions & 2 deletions .github/workflows/verify_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
-e MODE=${{ github.event.inputs.install-registry }} \
-e RUBY_VERSION=${{ matrix.ruby_version }} \
-v $(pwd):/home \
--rm ghcr.io/${{ github.repository }}/apm_ruby_${{ matrix.os }}:nh-27837-b \
--rm ghcr.io/${{ github.repository }}/apm_ruby_${{ matrix.os }}:latest \
./home/.github/workflows/scripts/_helper_run_install_tests.sh


Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
-e MODE=${{ github.event.inputs.install-registry }} \
-e RUBY_VERSION=${{ matrix.ruby_version }} \
-v $(pwd):/home \
--rm ghcr.io/${{ github.repository }}/apm_ruby_${{ matrix.os }}:nh-27837-b \
--rm ghcr.io/${{ github.repository }}/apm_ruby_${{ matrix.os }}:latest \
./home/.github/workflows/scripts/_helper_run_install_tests.sh

verify_install_ubi8_amd64_test:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Dates in this file are in the format MM/DD/YYYY.
This release includes the following features:

* Update to the latest redis-rb gem (> 5.x)
* Update latest liboboe library (11.1.0)
* Start to support solarwinds-apm-ruby arm64/aarch64
* Init message update for swo/nh backends

Pushed to Rubygems:

Expand Down
30 changes: 24 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ Rake::TestTask.new do |t|
when /libraries/
t.test_files = FileList['test/support/*_test.rb'] +
FileList['test/reporter/*_test.rb'] +
FileList['test/instrumentation/*_test.rb']
((ENV["ARCH"] != "aarch64" && ENV["ARCH"] != "arm64")?
FileList['test/instrumentation/*_test.rb'] :
FileList['test/instrumentation/*_test.rb'].exclude("test/instrumentation/memcached_test.rb", "test/instrumentation/grpc_test.rb"))

when /instrumentation_mocked/
# WebMock is interfering with other tests, so these have to run separately
t.test_files = FileList['test/mocked/*_test.rb']
Expand Down Expand Up @@ -68,15 +71,24 @@ end

task :docker_test => :docker_tests

desc 'Start docker container for testing and debugging, accepts: alpine, debian, centos as args, default: ubuntu'
desc 'Start docker container for testing and debugging, accepts: alpine, debian, centos as args, default: ubuntu
Example: bundle exec rake docker ubuntu arm'
task :docker, :environment do
_arg1, arg2 = ARGV
_arg1, arg2, arg3 = ARGV
os = arg2 || 'ubuntu'
arch = arg3 || ''

puts "Running on #{os}"

Dir.chdir('test/run_tests')
exec("docker-compose down -v --remove-orphans && docker-compose run --service-ports --name ruby_sw_apm_#{os} ruby_sw_apm_#{os} /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
case arg3
when "arm"
puts "Building ARM64 architecture"
exec("docker-compose -f docker-compose-arm.yml down -v --remove-orphans && docker-compose -f docker-compose-arm.yml run --service-ports --name ruby_sw_apm_#{os}_arm ruby_sw_apm_#{os}_arm /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
else
puts "Building x86_64 architecture"
exec("docker-compose down -v --remove-orphans && docker-compose run --service-ports --name ruby_sw_apm_#{os} ruby_sw_apm_#{os} /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
end
end

desc 'Stop all containers that were started for testing and debugging'
Expand Down Expand Up @@ -175,12 +187,15 @@ task :fetch_oboe_file, [:env] do |t, args|

sha_files = ['liboboe-1.0-x86_64.so.sha256',
'liboboe-1.0-lambda-x86_64.so.sha256',
'liboboe-1.0-aarch64.so.0.0.0.sha256',
'liboboe-1.0-aarch64.so.sha256',
'liboboe-1.0-alpine-x86_64.so.sha256',
'liboboe-1.0-alpine-aarch64.so.sha256',
'liboboe-1.0-aarch64.so.sha256',
'liboboe-1.0-alpine-aarch64.so.0.0.0.sha256',
'liboboe-1.0-alpine-x86_64.so.0.0.0.sha256',
'liboboe-1.0-x86_64.so.0.0.0.sha256']


sha_files.each do |filename|
remote_file = File.join(oboe_dir, filename)
local_file = File.join(ext_lib_dir, filename)
Expand Down Expand Up @@ -373,6 +388,8 @@ task :build_gem_push_to_packagecloud, [:version] do |t, args|

require 'package_cloud'

puts "\n=== Ready to push solarwinds_apm #{args[:version]} ===\n"

abort("Require PACKAGECLOUD_TOKEN\n See here: https://packagecloud.io/docs ") if ENV["PACKAGECLOUD_TOKEN"]&.empty? || ENV["PACKAGECLOUD_TOKEN"].nil?
abort("No version specified.") if args[:version]&.empty? || args[:version].nil?

Expand All @@ -387,7 +404,8 @@ task :build_gem_push_to_packagecloud, [:version] do |t, args|

puts "\n=== Gem will be pushed #{gem_to_push} ===\n"
gem_to_push_version = gem_to_push&.match(/-\d*.\d*.\d*/).to_s.gsub("-","")
gem_to_push_version = gem_to_push&.match(/-\d*.\d*.\d*.pre/).to_s.gsub("-","") if args[:version].include? "pre"
gem_to_push_version = gem_to_push&.match(/-\d*.\d*.\d*.\d*pre/).to_s.gsub("-","") if args[:version].include? "pre"
puts "\n=== gem_to_push_version: #{gem_to_push_version} ===\n"

abort("Couldn't find the required gem file.") if gem_to_push.nil? || gem_to_push_version != args[:version]

Expand Down
23 changes: 15 additions & 8 deletions gemfiles/libraries.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ gem 'rest-client'
# doesn't install well on alpine, explained here:
# https://qiita.com/takkeybook/items/5eae085d902957f0fe5b
# needs fixing for Ruby >= 3
if File.exist?('/etc/centos-release') && RUBY_VERSION < '2.6.0'
gem 'grpc', '~> 1.48.0'
gem 'google-protobuf'
elsif !File.exist?('/etc/alpine-release') && RUBY_VERSION < '3.0.0'
gem 'grpc'
gem 'google-protobuf'
if ENV["ARCH"] != "aarch64" && ENV["ARCH"] != "arm64"
if File.exist?('/etc/centos-release') && RUBY_VERSION < '2.6.0'
gem 'grpc', '~> 1.48.0'
gem 'google-protobuf'
elsif !File.exist?('/etc/alpine-release') && RUBY_VERSION < '3.0.0'
gem 'grpc'
gem 'google-protobuf'
end
end

if File.exist?('/etc/centos-release')
gem 'bunny', '<= 2.19.0'
else
gem 'bunny'
end

gem 'bunny'
gem 'curb'

gem 'dalli'
Expand All @@ -38,7 +45,7 @@ end
gem 'httpclient'
gem 'logging'
gem 'lumberjack'
gem 'memcached'
gem 'memcached' if ENV["ARCH"] != 'aarch64' && ENV["ARCH"] != "arm64"
gem 'mongo', '>= 2.11.3'
gem 'patron' # not instrumented, included to test a non-instrumented faraday adapter
gem 'redis', '<= 4.8.0'
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/test_gems.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ group :development, :test do
gem 'simplecov-console'
gem 'webmock' if RUBY_VERSION >= '2.0.0'

gem 'sinatra', '<= 2.2.2' # padrino only support sinatra < 3.0.0
gem 'sinatra', '>= 1.4.6', '<= 2.2.2' # padrino only support sinatra < 3.0.0
end
2 changes: 0 additions & 2 deletions lib/solarwinds_apm/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ def build_init_report
platform_info['process.command_line'] = $PROGRAM_NAME
platform_info['process.telemetry.path'] = Gem::Specification.find_by_name('solarwinds_apm')&.full_gem_path
platform_info['os.type'] = RUBY_PLATFORM
platform_info['os.description'] = `uname -a`.gsub("\n","")
# platform_info['process.detailed_command_line'] = `ps axw`.split("\n").select{ |ps| ps[ /\A#{ $$ }/ ] }[0]

platform_info.merge!(report_gem_in_use)

Expand Down
6 changes: 4 additions & 2 deletions solarwinds_apm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Automatic tracing and metrics for Ruby applications. Get started at cloud.solarw
}

s.extra_rdoc_files = ['LICENSE']
s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|gemfiles)/}) }
s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|gemfiles|.github)/}) }
s.files += ['ext/oboe_metal/src/oboe.h',
'ext/oboe_metal/src/oboe_api.cpp',
'ext/oboe_metal/src/oboe_api.h',
Expand All @@ -34,7 +34,9 @@ Automatic tracing and metrics for Ruby applications. Get started at cloud.solarw
'ext/oboe_metal/src/bson/platform_hacks.h',
'ext/oboe_metal/src/VERSION',
'ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.0.0.0.sha256',
'ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256'
'ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256',
'ext/oboe_metal/lib/liboboe-1.0-aarch64.so.0.0.0.sha256',
'ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.0.0.0.sha256'
]
s.files += ['lib/solarwinds_apm/cert/star.appoptics.com.issuer.crt']
s.files -= ['build_gem.sh',
Expand Down
1 change: 0 additions & 1 deletion test/run_tests/.ruby_version_alpine

This file was deleted.

1 change: 0 additions & 1 deletion test/run_tests/.ruby_version_centos

This file was deleted.

1 change: 0 additions & 1 deletion test/run_tests/.ruby_version_debian

This file was deleted.

1 change: 0 additions & 1 deletion test/run_tests/.ruby_version_ubuntu

This file was deleted.

17 changes: 4 additions & 13 deletions test/run_tests/Dockerfile_centos
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
FROM centos:7

#RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* &&\
# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*

# install OS packages
RUN yum update -y \
&& yum install -y epel-release \
&& yum install -y centos-release-scl \
&& yum install -y llvm-toolset-7.0 \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-x86_64/postgresql14-libs-14.1-1PGDG.rhel7.x86_64.rpm \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-x86_64/postgresql14-14.1-1PGDG.rhel7.x86_64.rpm \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-x86_64/postgresql14-devel-14.1-1PGDG.rhel7.x86_64.rpm
&& ARCH=`uname -m` \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-$ARCH/postgresql14-libs-14.6-1PGDG.rhel7.$ARCH.rpm \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-$ARCH/postgresql14-14.6-1PGDG.rhel7.$ARCH.rpm \
&& yum install -y https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7-$ARCH/postgresql14-devel-14.6-1PGDG.rhel7.$ARCH.rpm
RUN ln -s /usr/pgsql-14/bin/pg_config /usr/local/bin/pg_config

RUN yum groupinstall 'Development Tools' -y \
Expand Down Expand Up @@ -44,13 +42,6 @@ RUN yum groupinstall 'Development Tools' -y \
zlib-devel \
&& rm -rf /var/lib/apt/lists/*

#yum install fontconfig libXrender libXext
#


# update node to current stable version
# RUN npm cache clean -f && npm install -g n && n stable

# rbenv setup
# use rbenv-default-gems to automatically install bundler for each ruby version
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv \
Expand Down
3 changes: 3 additions & 0 deletions test/run_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ services:
ruby_sw_apm_alpine:
container_name: ruby_sw_apm_alpine
image: ruby_sw_apm_alpine
platform: linux/amd64
build:
context: .
dockerfile: ./Dockerfile_alpine
Expand All @@ -103,6 +104,7 @@ services:
ruby_sw_apm_debian:
container_name: ruby_sw_apm_debian
image: ruby_sw_apm_debian
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile_debian
Expand All @@ -120,6 +122,7 @@ services:
ruby_sw_apm_centos:
container_name: ruby_sw_apm_centos
image: ruby_sw_apm_centos
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile_centos
Expand Down
11 changes: 11 additions & 0 deletions test/run_tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ for ruby in ${rubies[@]} ; do
cd - || exit 1
fi
fi

if [[ $ruby == '2.5.9' ]]; then
gem install bundler -v 2.3.26
fi

unset BUNDLE_GEMFILE
bundle update
bundle exec rake clean fetch compile
Expand All @@ -169,6 +174,12 @@ for ruby in ${rubies[@]} ; do
if [[ $gemfile =~ .*rails7.* && $ruby =~ ^2.[65].* ]]; then continue; fi

echo "*** installing gems from $BUNDLE_GEMFILE ***"

export ARCH=$(uname -m)
if [[ $ARCH == "arm64" || $ARCH == "aarch64" ]]; then
bundle config set force_ruby_platform true
fi

bundle update # --quiet
if [ "$?" -ne 0 ]; then
echo "Problem during gem install. Skipping tests for $gemfile"
Expand Down