user/gitlab-foss: fix sys-filesystem #315

Merged
ayakael merged 1 commit from gitlab-foss/fix-sys-filesystem into edge 2023-11-29 19:39:54 +00:00
3 changed files with 40 additions and 107 deletions

View file

@ -5,7 +5,7 @@ pkgname=gitlab-foss
_pkgname=${pkgname%-foss} _pkgname=${pkgname%-foss}
pkgver=16.6.0 pkgver=16.6.0
_gittag=v$pkgver _gittag=v$pkgver
pkgrel=0 pkgrel=1
pkgdesc="A version control for your server" pkgdesc="A version control for your server"
url="https://gitlab.com/gitlab-org/gitlab-foss" url="https://gitlab.com/gitlab-org/gitlab-foss"
arch="x86_64 aarch64" arch="x86_64 aarch64"
@ -74,7 +74,7 @@ source="https://gitlab.com/gitlab-org/gitlab-foss/-/archive/$_gittag/gitlab-foss
$_pkgname.confd $_pkgname.confd
$_pkgname.logrotate $_pkgname.logrotate
bin-wrapper.in bin-wrapper.in
remove-sys-filesystem-depend.patch downgrade-sys-filesystem-depend.patch
" "
builddir="$srcdir/gitlab-foss-$_gittag" builddir="$srcdir/gitlab-foss-$_gittag"
@ -387,5 +387,5 @@ cb4ec100f0ea7ffcbb37aead8423e636629e2f4848b2974a7b2468e96cb1081ca732ac336417b08d
4dc00b16462f30591297fcb535fc364185d3ed76e9956597f0423a8dfd8a9a351f6ac29d9f0c73052c11324fba4768eb89a21c6bef4da99f15baaea8c9ab8407 gitlab.confd 4dc00b16462f30591297fcb535fc364185d3ed76e9956597f0423a8dfd8a9a351f6ac29d9f0c73052c11324fba4768eb89a21c6bef4da99f15baaea8c9ab8407 gitlab.confd
57f258246925fbef0780caebdf005983c72fe3db1ab3242a1e00137bd322f5ec6c0fd958db7178b8fc22103d071f550d6f71f08422bcd9e859d2a734b2ecef00 gitlab.logrotate 57f258246925fbef0780caebdf005983c72fe3db1ab3242a1e00137bd322f5ec6c0fd958db7178b8fc22103d071f550d6f71f08422bcd9e859d2a734b2ecef00 gitlab.logrotate
a944c3886388ba1574bf8c96b6de4d9f24ef4a83f553c31a224e17a3b01f2a5c65b60c59b7ed7ca4b25670c60ea8dd41b96a8a623d909d2bb09bdf2520ed7f23 bin-wrapper.in a944c3886388ba1574bf8c96b6de4d9f24ef4a83f553c31a224e17a3b01f2a5c65b60c59b7ed7ca4b25670c60ea8dd41b96a8a623d909d2bb09bdf2520ed7f23 bin-wrapper.in
97e19d601365da710341eea83324987e2d61061a4c816972d957cdb3300f8d65d07ca53bc46d4cbe9a476e5e72255e7081bdebc5217e7f3e95b8165f114c7b5f remove-sys-filesystem-depend.patch ab9a09fca6126b18b76e61380990dc217f915162985880e90b905b3210a1fef229af3db1f1ca180177d3cba91ab5fe33798ac685055abf0adc44a1b630f71b39 downgrade-sys-filesystem-depend.patch
" "

View file

@ -0,0 +1,37 @@
diff --git a/Gemfile.orig b/Gemfile
index c1e9e34..a4448b7 100644
--- a/Gemfile.orig
+++ b/Gemfile
@@ -525,7 +525,7 @@ gem 'health_check', '~> 3.0' # rubocop:todo Gemfile/MissingFeatureCategory
# System information
gem 'vmstat', '~> 2.3.0' # rubocop:todo Gemfile/MissingFeatureCategory
-gem 'sys-filesystem', '~> 1.4.3' # rubocop:todo Gemfile/MissingFeatureCategory
+gem 'sys-filesystem', '= 1.3.2' # rubocop:todo Gemfile/MissingFeatureCategory
# NTP client
gem 'net-ntp' # rubocop:todo Gemfile/MissingFeatureCategory
diff --git a/Gemfile.lock.orig b/Gemfile.lock
index e2ebb91..39b6df3 100644
--- a/Gemfile.lock.orig
+++ b/Gemfile.lock
@@ -1605,8 +1605,8 @@ GEM
attr_required (>= 0.0.5)
httpclient (>= 2.4)
sync (0.5.0)
- sys-filesystem (1.4.3)
- ffi (~> 1.1)
+ sys-filesystem (1.3.2)
+ ffi (>= 0)
sysexits (1.2.0)
table_print (1.5.7)
tanuki_emoji (0.9.0)
@@ -2061,7 +2059,7 @@ DEPENDENCIES
ssh_data (~> 1.3)
stackprof (~> 0.2.25)
state_machines-activerecord (~> 0.8.0)
- sys-filesystem (~> 1.4.3)
+ sys-filesystem (= 1.3.2)
tanuki_emoji (~> 0.9)
telesignenterprise (~> 2.2)
terser (= 1.0.2)

View file

@ -1,104 +0,0 @@
diff --git a/Gemfile.orig b/Gemfile
index c1e9e34..a4448b7 100644
--- a/Gemfile.orig
+++ b/Gemfile
@@ -525,7 +525,6 @@ gem 'health_check', '~> 3.0' # rubocop:todo Gemfile/MissingFeatureCategory
# System information
gem 'vmstat', '~> 2.3.0' # rubocop:todo Gemfile/MissingFeatureCategory
-gem 'sys-filesystem', '~> 1.4.3' # rubocop:todo Gemfile/MissingFeatureCategory
# NTP client
gem 'net-ntp' # rubocop:todo Gemfile/MissingFeatureCategory
diff --git a/Gemfile.lock.orig b/Gemfile.lock
index e2ebb91..39b6df3 100644
--- a/Gemfile.lock.orig
+++ b/Gemfile.lock
@@ -1605,8 +1605,6 @@ GEM
attr_required (>= 0.0.5)
httpclient (>= 2.4)
sync (0.5.0)
- sys-filesystem (1.4.3)
- ffi (~> 1.1)
sysexits (1.2.0)
table_print (1.5.7)
tanuki_emoji (0.9.0)
@@ -2061,7 +2059,6 @@ DEPENDENCIES
ssh_data (~> 1.3)
stackprof (~> 0.2.25)
state_machines-activerecord (~> 0.8.0)
- sys-filesystem (~> 1.4.3)
tanuki_emoji (~> 0.9)
telesignenterprise (~> 2.2)
terser (= 1.0.2)
diff --git a/app/controllers/admin/system_info_controller.rb.orig b/app/controllers/admin/system_info_controller.rb
index 96fb73c..7b8435e 100644
--- a/app/controllers/admin/system_info_controller.rb.orig
+++ b/app/controllers/admin/system_info_controller.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require 'open3'
class Admin::SystemInfoController < Admin::ApplicationController
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
@@ -36,6 +37,11 @@ class Admin::SystemInfoController < Admin::ApplicationController
'vfat'
].freeze
+ MOUNT_REGEX = /(\S+) on (\S+) type (\S+) \(([^)]+)\)/
+
+ Mount = Struct.new('Mount', :name, :mount_point, :mount_type, :options)
+ FsStat = Struct.new('FsStats', :path, :bytes_total, :bytes_used)
+
def show
@cpus = begin
Vmstat.cpu
@@ -47,7 +53,6 @@ def show
rescue StandardError
nil
end
- mounts = Sys::Filesystem.mounts
@disks = []
mounts.each do |mount|
@@ -57,15 +62,38 @@ def show
next if (EXCLUDED_MOUNT_TYPES & [mount.mount_type]).any?
begin
- disk = Sys::Filesystem.stat(mount.mount_point)
+ disk = fs_stat(mount.mount_point)
@disks.push({
bytes_total: disk.bytes_total,
bytes_used: disk.bytes_used,
disk_name: mount.name,
mount_path: disk.path
})
- rescue Sys::Filesystem::Error
+ rescue IOError
end
end
end
+
+ def mounts
+ stdout, stderr, status = Open3.capture3('mount')
+ fail IOError, stderr unless status.success?
+
+ stdout.lines
+ .map { |line| MOUNT_REGEX.match(line) }
+ .compact
+ .map { |match| Mount.new(*match.captures) }
+ end
+
+ def fs_stat(mount_point)
+ stdout, status = Open3.capture2('stat', '-c', '%s %b %a', '-f', mount_point)
+ fail IOError unless status.success?
+
+ block_size, blocks_total, blocks_free = stdout.split(' ').map(&:to_i)
+
+ bytes_total = blocks_total * block_size
+ bytes_free = blocks_free * block_size
+ bytes_used = bytes_total - bytes_free
+
+ FsStat.new(mount_point, bytes_total, bytes_used)
+ end
end