Skip to content

Instantly share code, notes, and snippets.

@bh7cw
bh7cw / Local PR test and merge.md
Created September 4, 2020 16:04 — forked from adam-p/Local PR test and merge.md
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@bh7cw
bh7cw / err
Created August 25, 2020 17:29
/var/cache/dnf/expired_repos.json is empty file
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 67, in main
return _main(base, args, cli_class, option_parser_class)
File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 102, in _main
cli.configure(list(map(ucd, args)), option_parser())
File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 969, in configure
self._configure_repos(opts)
File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 784, in _configure_repos
for rid in self.base._repo_persistor.get_expired_repos():
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: 99-disk-partition
spec:
config:
ignition:
version: 3.1.0
Before disk partition:
sh-4.4# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 120G 0 disk
|-nvme0n1p1 259:1 0 384M 0 part /boot
|-nvme0n1p2 259:2 0 127M 0 part /boot/efi
|-nvme0n1p3 259:3 0 1M 0 part
`-nvme0n1p4 259:4 0 119.5G 0 part
`-coreos-luks-root-nocrypt 253:0 0 119.5G 0 dm /sysroot
@bh7cw
bh7cw / 99_openshift-machineconfig_99-master-ssh.yaml
Last active August 21, 2020 17:32
create from zero, works /var on master node
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: 99-master-ssh
spec:
config:
ignition:
version: 3.1.0
[jingzhan@jing cluster_0715]$ OPENSHIFT_INSTALL_OS_IMAGE_OVERRIDE=ami-0b7dd156ccbd25423 ./openshift-install create manifests
? SSH Public Key /home/jingzhan/.ssh/cluster-0715.pub
? Platform aws
INFO Credentials loaded from the "default" profile in file "/home/jingzhan/.aws/credentials"
? Region us-east-2
? Base Domain devcluster.openshift.com
? Cluster Name cluster-bh7cw-727-06
? Pull Secret [? for help] ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
{
"ignition": {
"version": "3.1.0"
},
"passwd": {
"users": [
{
"name": "core",
"sshAuthorizedKeys": [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRvfOoVVuVw0+Pjv2wMYhr0h2J9LAc2ptz9ghsZXe1beTgYeJrH3ZezEdXLxZsAmgZAgwlf191K74idSJbM+8HhJAFPf5rQcB2EZzwXtwANCMGVnezavtJJlwZsr8+l9Y2xfKQ9bBwuoAQ6Rsp6Llav+QblI2rxYeNOv/4+jNcziwWjDWtsGNor/pcV6lIy6XCRzdgu8Mk9a1Z7itwH/WyNJE2mqEIljch4H5AjZbMA++9jb5jwYjg1RN5Tlmt+/GWgDn5TvQZKMtTt9mlkeE972E8vym9o1R8IQGoixKGuBmDuNEPUZ+b+wSc8+iZU8MIi3pNt6KNm25lJab9iuAB"
@bh7cw
bh7cw / Ignition Partition File
Created July 17, 2020 20:07
Works on FCOS and RHCOS. "device: /dev/vda" depends on the device we are using, maybe vda, sda, xvda
variant: fcos
version: 1.1.0
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCsXe6CfHl45kCIzMF90VhDf2NpBWUyS1+IiTtxm5a83mT9730Hb8xim7GYeJu47kiESw2DAN8vNJ/Irg0apZ217ah2rXXjPQuWYSXuEuap8yLBSjqw8exgqVj/kzW+YqmnHASxI13eoFDxTQQGzyqbqowvxu/5gQmDwBmNAa9bT809ziB/qmpS1mD6qyyFDpR23kUwu3TkgAbwMXBDoqK+pdwfaF9uo9XaLHNEH8lD5BZuG2BeDafm2o76DhNSo83MvcCPNXKLxu3BbX/FCMFO6O8RRqony4i91fEV1b8TbXrbJz1bwEYEnJRvmjnqI/389tQFeYvplXR2WdT9PCKyEAG+j8y6XgecIcdTqV/7gFfak1mp2S7mYHZDnXixsn3MjCP/cIxxJVDitKusnj1TdFqtSXl4tqGccbg/5Sqnt/EVSK4bGwwBxv/YmE0P9cbXLxuEVI0JYzgrQvC8TtUgd8kUu2jqi1/Yj9IWm3aFsl/hhh8YwYrv/gm7PV0TxkM= jingzhan@localhost.localdomain
storage:
disks:
- device: /dev/vda
#!/usr/bin/env bash
rpm -qa | grep -q podman || (echo "podman not installed!" ; exit 1)
podman pull quay.io/coreos-assembler/coreos-assembler
mkdir -p fcos && cd fcos
cosa() {
env | grep COREOS_ASSEMBLER
I am trying to tackle this issue https://issues.redhat.com/browse/GRPA-2086
This is my commit in cosa https://github.com/bh7cw/coreos-assembler/commit/1cf18ba390af2083b16516b9a6da9ac9d446041e
Then, I tested the code:
1) create a trigger on quay.io to build image after Git repo is pushed https://quay.io/repository/bh7cw/coreos-assembler?tab=builds
2) Run the cosa on local machine:
cosa file:
#!/usr/bin/env bash
# this script will use podman, but docker will work too
rpm -qa | grep -q podman || (echo "podman not installed!" ; exit 1)