Skip to content

Commit

Permalink
Merge branch 'master' into run_testsuite_with_sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom authored Dec 5, 2024
2 parents 3c4e67b + 850c6b3 commit 569802b
Show file tree
Hide file tree
Showing 67 changed files with 3,062 additions and 809 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ SECRET_KEY_BASE=8ea53ad3bc6c03923e376c8bdd85059c1885524947a7efe53d5e9c9d4e398611
EXTERNAL_PORT=8080
SCC_USERNAME=
SCC_PASSWORD=
RMT_METRICS_ENABLED=
PROMETHEUS_JOB_NAME=
18 changes: 12 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## Description

Please describe your change and provide as much context as possible.
<!--
Please describe your change and provide as much context as needed including a link to the reference issue / ticket / Trello card.
-->

Fixes # (issue)
* Related Issue / Ticket / Trello card: <link reference>

## How to test

<!-- Describe the steps how verify your change -->

## Change Type

Expand All @@ -16,13 +22,13 @@ Fixes # (issue)

*Please check off each item if the requirement is met.*

- [ ] I have verified that my code follows RMT's coding standards with `rubocop`.
- [ ] I have reviewed my own code and believe that it's ready for an external review.
- [ ] I have provided comments for any hard-to-understand code.
- [ ] I have documented the `MANUAL.md` file with any changes to the user experience.
- [ ] RMT's test coverage remains at 100%.
- [ ] If my changes are non-trivial, I have added a changelog entry to notify users at `package/obs/rmt-server.changes`.

## Other Notes
## Review

Please check out our [review guidelines](https://github.com/SUSE/scc-docs/blob/master/team/workflow/code_review.md)
and get in touch with the author to get a shared understanding of the change.

Please use this space to provide notes or thoughts to the team, such as tips on how to review/demo your changes.
10 changes: 5 additions & 5 deletions .github/workflows/lint-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ jobs:
- name: Prepare database
run: |
bundle exec rails db:migrate
bundle exec rails db:drop db:create db:migrate
- name: Run core tests
run: |
bundle exec rspec --format documentation
bundle exec rake test:core
- name: Run core tests with sqlite
run: |
sed -i 's/adapter: mysql2/adapter: sqlite3/' config/rmt.yml
bundle exec rspec --format documentation
bundle exec rake test:core
- name: Run PubCloud engines tests
run: |
bundle exec rake test:engines
Expand All @@ -96,4 +96,4 @@ jobs:
run: |
echo "::group::Version verification checks"
ruby ci/check-version-matches.rb
echo "::endgroup::"
echo "::endgroup::"
4 changes: 4 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ unless ENV['NO_COVERAGE']
# omit registration sharing (removing systems using rmt-cli)
add_filter('engines/registration_sharing/lib/registration_sharing.rb')

add_filter('lib/rmt/db.rb')
add_filter('lib/rmt.rb')
add_filter('config')

track_files('app/**/*.rb')
track_files('lib/**/*.rb')
end
Expand Down
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ gem 'repomd_parser', '~> 1.1.0'
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'

# Prometheus Exporter:
gem 'yabeda'
gem 'yabeda-rails'
gem 'yabeda-puma-plugin'
gem 'yabeda-prometheus'

gem 'strong_migrations'

group :development, :test do
Expand All @@ -43,7 +49,7 @@ group :development, :test do
gem 'gettext', require: false # needed for gettext_i18n_rails tasks
gem 'ruby_parser', '< 3.20', require: false # needed for gettext_i18n_rails tasks, Locked because of Ruby >= 2.6 dependency
gem 'gettext_test_log'
gem 'memory_profiler'
gem 'memory_profiler', '~> 1.0.2' # locked because 1.1.0 requires ruby version >= 3.1.0
gem 'awesome_print'
end

Expand Down
57 changes: 41 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
anyway_config (2.6.4)
ruby-next-core (~> 1.0)
ast (2.4.2)
awesome_print (1.9.2)
base32 (0.3.4)
base64 (0.2.0)
bigdecimal (3.1.6)
bigdecimal (3.1.8)
builder (3.2.4)
byebug (11.1.3)
bzip2-ffi (1.1.1)
Expand Down Expand Up @@ -104,7 +106,8 @@ GEM
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
fakefs (1.8.0)
fast_gettext (2.3.0)
fast_gettext (2.4.0)
prime
ffaker (2.21.0)
ffi (1.16.3)
formatador (0.2.5)
Expand All @@ -118,7 +121,7 @@ GEM
prime
racc
text (>= 1.3.0)
gettext_i18n_rails (1.12.0)
gettext_i18n_rails (1.13.0)
fast_gettext (>= 0.9.0)
gettext_test_log (0.2.1)
guard (2.16.2)
Expand All @@ -135,13 +138,13 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hashdiff (1.1.0)
hashdiff (1.1.1)
hpricot (0.8.6)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.3.1)
jsonapi-renderer (0.2.2)
jwt (2.8.1)
jwt (2.9.3)
base64
listen (3.6.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -151,15 +154,15 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
lumberjack (1.2.8)
memory_profiler (1.0.1)
memory_profiler (1.0.2)
method_source (1.1.0)
mini_portile2 (2.6.1)
minitest (5.15.0)
mixlib-shellout (2.4.4)
mustache (1.1.1)
mysql2 (0.5.6)
nenv (0.3.0)
nio4r (2.7.0)
nio4r (2.7.3)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
Expand All @@ -172,11 +175,13 @@ GEM
prime (0.1.2)
forwardable
singleton
prometheus-client (4.2.3)
base64
pry (0.14.0)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.7)
puma (5.6.8)
puma (5.6.9)
nio4r (~> 2.0)
racc (1.8.0)
rack (2.2.9)
Expand Down Expand Up @@ -208,8 +213,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.3.9)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
Expand Down Expand Up @@ -266,6 +270,7 @@ GEM
rubocop (~> 1.19)
rubocop-thread_safety (0.4.4)
rubocop (>= 0.53.0)
ruby-next-core (1.0.3)
ruby-progressbar (1.11.0)
ruby_parser (3.19.2)
sexp_processor (~> 4.16)
Expand Down Expand Up @@ -295,15 +300,14 @@ GEM
sqlite3 (1.4.4)
strong_migrations (0.7.9)
activerecord (>= 5)
strscan (3.1.0)
sync (0.5.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
text (1.3.1)
thor (1.2.2)
timecop (0.9.9)
timecop (0.9.10)
tins (1.26.0)
sync
typhoeus (1.4.1)
Expand All @@ -316,10 +320,27 @@ GEM
activesupport (>= 3)
railties (>= 3)
yard (~> 0.9.20)
webmock (3.23.0)
webmock (3.24.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
yabeda (0.13.1)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer
yabeda-prometheus (0.9.1)
prometheus-client (>= 3.0, < 5.0)
rack
yabeda (~> 0.10)
yabeda-puma-plugin (0.7.1)
json
puma
yabeda (~> 0.5)
yabeda-rails (0.9.0)
activesupport
anyway_config (>= 1.3, < 3)
railties
yabeda (~> 0.8)
yard (0.9.35)
zeitwerk (2.6.15)
zstd-ruby (1.5.6.1)
Expand Down Expand Up @@ -350,7 +371,7 @@ DEPENDENCIES
guard-rspec
jwt (~> 2.1)
listen (>= 3.0.5, <= 3.6.0)
memory_profiler
memory_profiler (~> 1.0.2)
minitest (~> 5.15.0)
mysql2 (~> 0.5.3)
nokogiri (< 1.13)
Expand Down Expand Up @@ -381,6 +402,10 @@ DEPENDENCIES
vcr (~> 6.0)
versionist
webmock
yabeda
yabeda-prometheus
yabeda-puma-plugin
yabeda-rails

BUNDLED WITH
1.17.3
31 changes: 12 additions & 19 deletions PACKAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Note: Look below for direction on publishing to registry.
```
* Alternatively, if an OBS working copy is already checked out, update the working copy by running `osc up`
2. Run `make dist` in your RMT working directory to build a tarball.
3. Copy the files from the `package/obs` directory to the OBS working directory.
3. Copy the files from the `package/obs` directory to the OBS working directory `systemsmanagement:SCC:RMT/rmt-server`.
4. Examine the changes by running `osc status` and `osc diff`.
5. Stage the changes by running `osc addremove`.
6. Build the package with osc:
Expand All @@ -41,14 +41,6 @@ Note: Look below for direction on publishing to registry.
```
2. On github, submit a release for the tag. See https://help.github.com/en/articles/creating-releases for assistance.
#### Helm chart update process
RMT helm chart is found [here](https://github.com/SUSE/helm-charts.git).
Edit `rmt-helm/Chart.yaml` to update the chart version (`version`) and rmt-version (`appVersion`). The `BuildTag` version needs to be updated. Look at this example [pull-request](https://github.com/SUSE/helm-charts/pull/5) bumping the version.
[Bruno Leon](mailto:[email protected]) is the maintainer and point of contact for rmt-helm.
#### Submit Requests to openSUSE Factory and SLES
To get a maintenance request accepted, each changelog entry needs to have at
Expand All @@ -72,13 +64,7 @@ osc sr systemsmanagement:SCC:RMT rmt-server openSUSE:Factory

###### Get target codestreams where to submit

To check out which codestreams the package is currently maintained in, run:

```bash
osc -A https://api.suse.de maintained rmt-server
```

For a more detailed view which target codestreams are in which state, check out: [Codestream overview](https://maintenance.suse.de/maintained/?package=rmt-server)
To check out which codestreams RMT is currently maintained, see https://smelt.suse.de/maintained/?q=rmt-server.

###### Submit updates

Expand Down Expand Up @@ -112,8 +98,15 @@ You can check the status of your requests [here](https://build.opensuse.org/pack
After your requests have been accepted, they still have to pass maintenance testing before they are released to customers. You can check their progress at [maintenance.suse.de](https://maintenance.suse.de/search/?q=rmt-server). If you still need help, the maintenance team can be reached at [[email protected]]([email protected]) or #maintenance on irc.suse.de.


## Packaging and publishing to SUSE registry
## Container image and publishing to SUSE registry

SUSE registry houses the rmt-server docker image. The image is built automatically on OBS/IBS, and can be found [here](https://build.opensuse.org/package/show/devel:BCI:SLE-15-SP6/rmt-server-image). It is getting published here: `registry.suse.com/suse/rmt-server`.


SUSE registry houses the rmt-server docker image. The image is built on OBS/IBS, project for SLES 15sp4 based distributions can be found [here](https://build.opensuse.org/package/show/devel:BCI:SLE-15-SP4/rmt-server-image).
#### Helm chart update process

RMT helm chart is defined [here](https://github.com/SUSE/helm-charts.git) and published at `registry.suse.com/suse/rmt-helm`.

Edit `rmt-helm/Chart.yaml` to update the chart version (`version`) and rmt-version (`appVersion`). The `BuildTag` version needs to be updated. Look at this example [pull-request](https://github.com/SUSE/helm-charts/pull/5) bumping the version.

At the moment of writing, the publishing process has to be done manually. This can be achieved by reaching out to the Auto-Build team (only available internally).
Reach out to the BCI team (Dirk Mueller or `#proj-bci` slack channel) to trigger the release of the helm-chart.
16 changes: 12 additions & 4 deletions app/controllers/api/connect/v3/systems/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ def activate
end

def show
if @system.products.include? @product
if @product.identifier.casecmp?('sles')
# if system has SLE Micro
# it should access to SLES products
sle_micro = @system.products.any? { |p| p.identifier.downcase.include?('sle-micro') }
sle_micro_same_arch = @system.products.pluck(:arch).include?(@product.arch) if sle_micro
end
if @system.products.include?(@product) || sle_micro_same_arch
respond_with(
@product,
serializer: ::V3::ProductSerializer,
Expand Down Expand Up @@ -108,7 +114,7 @@ def create_product_activation

# in BYOS mode, we rely on the activation being performed in
# `engines/scc_proxy/lib/scc_proxy/engine.rb` and don't need further checks here
return activation if @system.proxy_byos
return activation if @system.byos?

if @subscription.present?
activation.subscription = @subscription
Expand All @@ -123,8 +129,10 @@ def remove_previous_product_activations(product_ids)
end

def load_subscription
# Find subscription by regcode if provided, otherwise use the first subscription (bsc#1220109)
if params[:token].present? && !@system.proxy_byos
# Find subscription by regcode if provided and not a public cloud system,
# otherwise check if there's already an activation with a matching
# subscription (for migrations, bsc#1220109)
if params[:token].present? && @system.not_applicable?
@subscription = Subscription.find_by(regcode: params[:token])
unless @subscription
raise ActionController::TranslatedError.new(N_('No subscription with this Registration Code found'))
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/connect/v3/systems/systems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def update

# Since the payload is handled by rails all values are converted to string
# e.g. cpus: 16 becomes cpus: "16". We save this as string for now and expect
# SCC to handle the convertation correctly
@system.system_information = hwinfo_params[:hwinfo].to_json
# SCC to handle the conversion correctly
@system.system_information = @system.system_information_hash.update(hwinfo_params[:hwinfo]).to_json

if @system.save
logger.info(N_("Updated system information for host '%s'") % @system.hostname)
Expand Down
Loading

0 comments on commit 569802b

Please sign in to comment.