Skip to content

Instantly share code, notes, and snippets.

@mccun934
mccun934 / gist:5412e46ede9c4692b8666f2a77d51f0d
Created January 28, 2017 15:49
delete / clear qpid queue
# for each of such $queue:
# rm -rf /var/lib/qpidd/.qpidd/qls/jrnl/${queue}
# qpid-config --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 add queue $queue --durable
@mccun934
mccun934 / capsule-clear.bash
Created January 24, 2017 19:22
This clears all Pulp content from a capsule so it can be re-synced
mongo pulp_database --eval "db.units_distribution.drop();db.units_docker_blob.drop();db.units_docker_image.drop();db.units_docker_manifest.drop();db.units_docker_tag.drop();db.units_drpm.drop();db.units_erratum.drop();db.units_iso.drop();db.units_package_category.drop();db.units_package_environment.drop();db.units_package_group.drop();db.units_puppet_module.drop();db.units_rpm.drop();db.units_srpm.drop();db.units_yum_repo_metadata_file.drop();db.repo_content_units.drop();"
mongo pulp_database --eval 'db.repo_importers.update({"scratchpad": {$ne: null}}, {$set: {"scratchpad.repomd_revision": null}}, {"multi":true})'
rm -rf /var/lib/pulp/content/units/*
// Engineering update
Here are few items to check before doing the ugprade from 6.2.0 to 6.2.7:
1) Verify a qpid queue from 6.1 is actually removed:
# qpid-stat -q --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 | grep event
make sure you only see 1 line in that, similar to:
https://access.redhat.com/node/208995
# foreman-rake console
Loading production environment (Rails 3.2.8)
irb(main):001:0> ForemanTasks::Task.where(:state => :planned).where(:label => "Actions::Katello::Repository::Sync").destroy_all
irb(main):002:0> ForemanTasks::Task.where(:state => :planned).where(:label => "Actions::Katello::System::GenerateApplicability").destroy_all
irb(main):003:0> ForemanTasks::Task.where(:state => :paused).where(:label => "Actions::Host::GenerateApplicability").destroy_all
irb(main):004:0> ForemanTasks::Task.where(:label => "Actions::Candlepin::ListenOnCandlepinEvents").destroy_all
@mccun934
mccun934 / gist:2d5026e49a1f66d503348c359d6b16a5
Last active March 17, 2017 19:13
Reset the metadata resync flag for all repos
The below method can help cases where content is not synchronizing to your satellite or not updating:
1) Login to the UI, go to Content -> Products -> Red Hat Enterprise Linux ->
find the repo that has the 7.3 packages in it and click the details page
2) On details page there is a 'mirror on sync' setting. Ensure that is set to Yes
3) Go to a terminal and execute this from your root shell on the Satellite:
# curl http://people.redhat.com/~mmccune/reset-resync-flag.bash > reset-resync-flag.bash
service httpd restart
service pulp_workers restart
service pulp_celerybeat restart
service pulp_resource_manager restart
service goferd restart
mkdir -p /etc/foreman-installer/applied_hooks/pre
touch /etc/foreman-installer/applied_hooks/pre/fix_katello_settings_file
touch /etc/foreman-installer/applied_hooks/pre/fix_pulp_httpd_conf
touch /etc/foreman-installer/applied_hooks/pre/migrate_candlepin
touch /etc/foreman-installer/applied_hooks/pre/migrate_pulp
touch /etc/foreman-installer/applied_hooks/pre/start_databases
touch /etc/foreman-installer/applied_hooks/pre/start_httpd
touch /etc/foreman-installer/applied_hooks/pre/start_pulp
touch /etc/foreman-installer/applied_hooks/pre/start_qpidd
touch /etc/foreman-installer/applied_hooks/pre/start_tomcat
cd /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-*/
git init; git add -A .; git commit -m original
curl https://patch-diff.githubusercontent.com/raw/theforeman/foreman-tasks/pull/205.patch | patch -p1
git add -A .; git commit -m 'fix for bz 1381352'
foreman-rake db:migrate
# you should see indexes getting added to the instance
katello-service restart
# foreman
1) Edit /var/lib/pgsql/data/postgresql.conf
2) Change log_min_duration_statement to 500:
log_min_duration_statement = 500 # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds
This will log any query that runs longer than .5 seconds
# sudo -u postgres psql -d foreman
psql (9.2.15)
Type "help" for help.
foreman=# create index foreman_tasks_tasks_state_temp_idx on foreman_tasks_tasks ((state <> 'stopped'));
CREATE INDEX
foreman=# analyze;
ANALYZE
foreman=#