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

Improve server version detection #9

Merged
merged 6 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.3.3', '2.5.1', '2.7.0']

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
ruby-version: '2.7.0'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Lint
run: bundle exec rubocop
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Check if a the local minio version is in the most recent version

### Optional parameters

Checks will check the default URL https://dl.min.io/server/minio/release
and the default Platform linux-amd64 for updates. Adjust these optional
parameters if you want to check a different platform or for whatever
Checks will check the default URL https://dl.min.io/server/minio/release
and the default Platform linux-amd64 for updates. Adjust these optional
parameters if you want to check a different platform or for whatever
reason need to check a different URL.

| Parameter | Description |
Expand All @@ -42,7 +42,20 @@ reason need to check a different URL.

## Development

After checking out the repo, run `bin/setup` to install dependencies. You can
Install rbenv and ruby-build to get a ruby 2.7.x on your system (running on ubuntu 20.04).

yay rbenv ruby-build
benni-as marked this conversation as resolved.
Show resolved Hide resolved

Add the rbenv shell extension (`eval "$(rbenv init -)"`) to your shell config (e.g. `~/.zshrc`) and install ruby 2.7.0

rbenv install 2.7.0

After checking out the repo verify, that your system is using the 2.7.0 ruby:

# rbenv version
2.7.0 (set by ..../sensu-plugins-minio/.ruby-version)

Run `bin/setup` to install dependencies. You can
also run `bin/console` for an interactive prompt that will allow you to
experiment.

Expand Down
2 changes: 1 addition & 1 deletion bin/check-minio-update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def latest_version
def local_version
@local_version ||= begin
stdout, stderr, status = Open3.capture3(
{ 'PATH' => ENV['PATH'] }, 'minio --version', unsetenv_others: true
{ 'PATH' => ENV['PATH'] }, 'journalctl --boot --unit minio | grep "Version: RELEASE" | tail -n 1', unsetenv_others: true # rubocop:disable Layout/LineLength
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--boot bedeutet, dass wir nur die frischestens logs bekommen. Sonst werden die mitunter ganz schön lang und wir haben unnötig Disk IO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darüber hinaus hatte ich auch nach einem Version String im health endpoint geschaut, aber den hat minio aus Sicherheitsgründen vor längerer Zeit ausgebaut.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR: Ich hab lokal via bin/console überprüft, ob Open3#capture3 auch Shell pipes unterstützt ✅

irb(main):014:1* Open3.capture3(
irb(main):015:1*   { 'PATH' => ENV['PATH'] }, 'echo foo | wc -l', unsetenv_others: true # rubocop:disable Layout/LineLength
irb(main):016:0> )
=> ["1\n", "", #<Process::Status: pid 24932 exit 0>]

Dafür musste ich noch 1 File hinzufügen, siehe a3b8b20

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, danke für den Check. Ich hatte das gar nicht lokal ausprobiert und mich auf den test verlassen. Aber jetzt fällt mir auf, dass der Test ja Open3 komplett mockt (was ja auch nicht anders geht). Also gut, dass nochmal ausprobiert zu haben.

)

unless status.success?
Expand Down
3 changes: 2 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install --path vendor/bundle
bundle config set path vendor/bundle
bundle install

# Do any other automated setup that you need to do here
3 changes: 3 additions & 0 deletions lib/sensu/plugins/minio.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'sensu/plugins/minio/version'
2 changes: 1 addition & 1 deletion spec/check_minio_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

let(:stdout) do
'minio version RELEASE.2022-07-17T15-43-14Z (commit-id=1b339ea062b423f1c6fbeb02116d020d18418917)' # rubocop:disable Layout/LineLength
'Mar 25 07:37:03 weact-staging-db-07 minio[220013]: Version: RELEASE.2022-07-17T15-43-14Z (go1.21.8 linux/amd64)' # rubocop:disable Layout/LineLength
end

let(:stderr) { nil }
Expand Down
Loading