Skip to content

Instantly share code, notes, and snippets.

View cgwalters's full-sized avatar
👍
LGTM

Colin Walters cgwalters

👍
LGTM
View GitHub Profile
apiVersion: v1
kind: ConfigMap
metadata:
name: test-unit
annotations:
bootc.prefix: "/usr/lib/systemd/system"
data:
example.service: |
[Service]
ExecStart=echo hello world
@cgwalters
cgwalters / gist:f5ebebe053bab811b8f173abbc20b791
Last active February 27, 2023 15:33
systemd debug rt pod
Feb 27 15:07:10 cosa-devsh podman[1491]: 2023-02-27 15:07:10.972716987 +0000 UTC m=+0.192006555 container create 0260f6a600eb61b4cf3f1b536c60b13954309da06197188251e0ff1482543434 (image=docker.io/library/busybox:latest, name=loving_driscoll)
Feb 27 15:07:10 cosa-devsh kernel: bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
Feb 27 15:07:10 cosa-devsh NetworkManager[1169]: <info>  [1677510430.9996] manager: (cni-podman0): new Bridge device (/org/freedesktop/NetworkManager/Devices/3)
Feb 27 15:07:11 cosa-devsh podman[1491]: 2023-02-27 15:07:10.917733235 +0000 UTC m=+0.137022821 image pull  busybox
Feb 27 15:07:11 cosa-devsh NetworkManager[1169]: <info>  [1677510431.0286] manager: (veth7c04525f): new Veth device (/org/freedesktop/NetworkManager/Devices/4)
Feb 27 15:07:11 cosa-devsh kernel: cni-podman0: port 1(veth7c04525f) entered blocking state
Feb 27 15:07:11 cosa-devsh kernel: cni-podman0: port 1(veth7c04525f) entered disab
```
-rw-r--r--. 1 walters walters 613M Feb 15 17:16 qcow2.xz
-rw-r--r--. 1 walters walters 669M Feb 15 17:58 qcow2.zstd
$ time xz -d < qcow2.xz >/dev/null
________________________________________________________
Executed in 12.62 secs fish external
usr time 12.51 secs 190.00 micros 12.51 secs
sys time 0.09 secs 69.00 micros 0.09 secs
@cgwalters
cgwalters / try_or_else.rs
Last active July 5, 2022 14:37
try_or_else
#![feature(try_trait_v2)]
use anyhow::Result; // 1.0.57
use core::ops::Try;
trait TryOrElse<T> {
fn try_or_else<R: Try<Output = T>, F: FnOnce() -> R>(self, f: F) -> R;
}
// Proposed new API for Option https://github.com/rust-lang/libs-team/issues/59
@cgwalters
cgwalters / option-result-idioms.md
Last active June 28, 2022 18:00
Option and Result idioms

In Rust, the Option and Result types are really common. Here are a few idioms I've discovered for working with them using combinators which can simplify code:

map(Ok).unwrap_or_else(): Taking Option with fallible fallback to T

    // Our program needs a string for something (e.g. filename, database table name, etc).
    // To start, we can get this as an optional string - here a CLI argument, but it could be anything; e.g.
    // a value parsed from JSON, etc.  The `.nth(1)` call here gives us an `Option<String>`.
    // We want to compute a fallback value, but doing so can fail (e.g. return `Result<String>`).
@cgwalters
cgwalters / ubuntu-core-persistence.md
Last active April 25, 2022 13:04
colin's quick investigation of ubuntu core and persistence

Ubuntu Core investigation

Following up to this tweet.

Setup

I followed the qemu instructions, using ubuntu-core-20-amd64.img.

Investigating the mount/block setup

$ podman pull quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:502f9b8333a88ecee1eb7e904af5cb0c75946e3084a553374079abf862446c70
Trying to pull quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:502f9b8333a88ecee1eb7e904af5cb0c75946e3084a553374079abf862446c70...
Getting image source signatures
Copying blob 1e138cc587ef done  
Copying blob 54183f4a5679 done  
Copying blob fadcf7c660d5 done  
Copying config 10b43b2460 done  
Writing manifest to image destination
Storing signatures
flowchart TB
    subgraph ostreebuild [ostree build]
    quayprevious["previous ostree container"] -->|change detection| container["ostree container"]
    configgit["config git"]-->container
    rpms --> container["ostree container"]
    container --> quay["quay.io"]
    end
    subgraph imagebuild [image build]
 quay --&gt; qemu["qemu image"]
```
$ cosa generate-release-meta --stream-name podman --stream-baseurl https://fedorapeople.org/groups/podman --url https://fedorapeople.org/groups/podman/builds/35.20220208.dev.0/x86_64/meta.json --output stream.json
Downloading https://fedorapeople.org/groups/podman/builds/35.20220208.dev.0/x86_64/meta.json...
podman stream
x86_64 images:
- qemu
Successfully wrote release file at stream.json
$ jq . < stream.json
{
"release": "35.20220208.dev.0",
```
walters@toolbox /v/s/w/b/rhcos-master> oc image info (oc adm release info --image-for=machine-os-content quay.io/openshift-release-dev/ocp-release:4.6.52-x86_64)
Name: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:6ea6c6f23e0fe047c5813c0607c3bed53dc6bcf2c1064f8fc72235236aacc182
Media Type: application/vnd.docker.distribution.manifest.v2+json
Created: 39d ago
Image Size: 1.001GB in 3 layers
Layers: 86.08MB sha256:c2aecb3e557dba3008677634224d2eec02c1ccdf36e29026d57e933095a790a6
1.883kB sha256:65b3ce9d57bf94cef9ca928be2f78a5f61be880670860dbd05111489cac97368
914.5MB sha256:322dbbe859bd09590f8612b9ae0b59a2cc9d4f869c310a4525c86f7d36d7a614
OS: linux