Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Place this into ${dynflow_checkout}/examples/cancellation.rb
# run with ruby examples/cancellation.rb
# frozen_string_literal: true
require_relative 'example_helper'
class SequentialParent < Dynflow::Action
def plan(klass, count = 10, args: [])
def bar(a, b, c)
puts [a, b, c]
end
def foo(...)
bar(1, ...)
end
foo(1, 2)
@adamruzicka
adamruzicka / howto.md
Created March 8, 2024 14:12
Encrypting asahi linux installation

Outline

  • Install Asahi
  • Add cryptsetup into initrd
  • Make initrd spawn a shell before mounting disk
  • Reencrypt the partition in-place
  • Configure grub and rebuild initramfs to open LUKS device during startup.
  • Cleanup

Steps

Install Asahi

@adamruzicka
adamruzicka / post.md
Created April 25, 2023 13:55
State of plugin translations

From what I've seen, strings are not getting translated in pure React pages coming from plugins. Translations work as long they are being done on the backend, but if they are done on the frontend, they end up not translated.

When updated translations are pulled in Foreman, a po_to_json rake task is called which converts the *.po files into javascript files under app/assets/javascripts/locale/$lang/app.js. These files usually look like this

var locales = locales || {}
locales['it'] = {
  "domain": "app",
  "locale_data": {
 "Failed to fetch: ": ["Recupero fallito:"],
# Save this script as $LOCATION/queues.rb
# Run with foreman-rake console < $LOCATION/queues.rb
# Kill with C-c
# It collects sidekiq statistics every $INTERVAL seconds
# The statistics are saved into three CSV files
INTERVAL = (ENV['interval'] || 15).to_i
stats_csv = CSV.open(ENV['STATS'] || '/tmp/stats.csv', 'wb')
#!/usr/bin/env ruby
# frozen_string_literal: true
# examples/excessive_logging.rb
# Reproducer for https://bugzilla.redhat.com/show_bug.cgi?id=1877917
# Run with something like
# for i in 1 2 5 10 50 100 500 1000; do echo -n "$i: "; COUNT=$i bundle exec ruby examples/excessive_logging.rb >/dev/null 2>&1 | wc -l -c | column -t; done
require_relative 'example_helper'
@adamruzicka
adamruzicka / memory recycling.md
Last active July 30, 2020 09:17
Memory recycler in the age of Sidekiq

Memory recycler in the age of Sidekiq

Starting with the move to sidekiq, the memory recycler is gone. Luckily, by splitting the executor into several systemd services, we can leverage the resource control features[1] provided by systemd and cgroups to fill the feature gap created by removal of the memory recycler.

Prerequisites

Before we can get to the memory limiting, let's take a look at how the default state looks. There are the orchestrator, worker and worker-hosts-queue processes running as instances of the dynflow-sidekiq@.service template

From 81cb056aaa972a0c1ad9a49b7c4887d0df8111d6 Mon Sep 17 00:00:00 2001
From: Adam Ruzicka <aruzicka@redhat.com>
Date: Wed, 22 Jul 2020 12:26:17 +0200
Subject: [PATCH] Workaround undefined method singleton_class? error
NoMethodError: undefined method `singleton_class?' for #<Class:0x0000556b7d6b69b0>
/tmp/foreman/app/models/operatingsystem.rb:91:in `<class:Jail>'
/tmp/foreman/app/models/operatingsystem.rb:90:in `<class:Operatingsystem>'
/tmp/foreman/app/models/operatingsystem.rb:4:in `<main>'
/tmp/foreman/app/models/concerns/audit_search.rb:82:in `block in audited_classes_without_sti'
@adamruzicka
adamruzicka / scaling.md
Last active October 30, 2020 14:36
Dynflow workers scaling

Intro

Out of the box, foreman ships with orchestrator and a single worker If you have Katello, you will get an additional worker for processing of the host queue

root@modest-gator:~# ls -l /etc/foreman/dynflow/
total 1
-rw-r--r--. 1 root foreman 51 May 14 07:35 orchestrator.yml
-rw-r--r--. 1 root foreman 59 May 14 07:35 worker.yml
# /usr/share/foreman/config/initializers/foreman-tasks-db-pool-size.rb
ForemanTasks.dynflow.config.db_pool_size = 30