Skip to content

Instantly share code, notes, and snippets.

View shoenig's full-sized avatar
🪁
lets Go

Seth Hoenig shoenig

🪁
lets Go
View GitHub Profile
@shoenig
shoenig / hclfmt.nomad.hcl
Created June 6, 2024 19:17
seths traefik job file june 2024
job "hclfmt" {
datacenters = ["nyc3"]
type = "service"
group "format" {
network {
mode = "host"
port "http" {
host_network = "internal"
}
@shoenig
shoenig / codec.diff
Created October 10, 2023 15:48
codec diff
➜ diff main/codecgen-pkg-100.generated.go numa/codecgen-pkg-100.generated.go
1018c1018
< var t198 RaftServer
---
> var t198 NUMA
1023c1023
< var t199 RaftConfigurationResponse
---
> var t199 LegacyNodeCpuResources
1028c1028
@shoenig
shoenig / a.diff
Created October 3, 2023 14:51
cluster id
diablo nomad.ent/nomad on main [m]
➜ go test -tags=ent -v -run _UpgradeMigration
=== RUN TestAutopilotEnterprise_UpgradeMigration
CLUSTERID id=a59eb8bb-556c-186c-48ec-80effdbca495 error=<nil>
--- PASS: TestAutopilotEnterprise_UpgradeMigration (0.33s)
PASS
ok github.com/hashicorp/nomad/nomad 0.353s
diablo nomad.ent/nomad on main [m]
➜ git diff
@shoenig
shoenig / cgdump.sh
Created August 18, 2023 18:23
script for inspecting nomad cgroup partitions
#!/usr/bin/env bash
root=/sys/fs/cgroup
echo "[root]"
echo " cpuset.cpus.effective: $(cat $root/cpuset.cpus.effective)"
echo ""
echo "[nomad.slice]"
echo " cpuset.cpus.partition: $(cat $root/nomad.slice/cpuset.cpus.partition)"
echo " cpuset.cpus: $(cat $root/nomad.slice/cpuset.cpus)"
@shoenig
shoenig / eg.json
Created March 27, 2023 16:04
json example
{
"JobHCL":"variable \"X\" {\n type = string\n}\n\nvariable \"Y\" {\n type = number\n}\n\nvariable \"Z\" {\n type = bool\n}\n \njob \"demo\" {\n type = \"sysbatch\"\n group \"group\" {\n task \"task\" {\n driver = \"raw_exec\"\n\n config {\n command = \"echo\"\n args = [\"X ${var.X}, Y ${var.Y}, Z ${var.Z}\"]\n }\n\n resources {\n cpu = 10\n memory = 16\n }\n }\n }\n}\n",
"Variables": {
"X": "x",
"Y": 42,
"Z": true
},
"Canonicalize":true
}
@shoenig
shoenig / opaque.go
Created March 10, 2023 20:45
Better Go opaque map comparison
// net yet used because
// 1. very slow (like 10x worse than DeepEqual)
// 2. terrifying - i mean what even is this
var (
cmpOptIgnorePrivate = ignoreUnexportedAlways()
cmpOptNilIsEmpty = cmpopts.EquateEmpty()
)
// ignoreUnexportedAlways is a derivative of go-cmp.IgnoreUnexported, but this one
@shoenig
shoenig / cgroups.txt
Created February 27, 2023 19:06
nomad raw_exec cores example
fs/cgroup/nomad.slice
➜ cat 416baca9-bc05-d4c4-29f0-d0feec4e355c.task*.scope/cpuset.cpus
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: 416baca9-bc05-d4c4-29f0-d0feec4e355c.task1.scope/cpuset.cpus
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 0-2,8-23
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: 416baca9-bc05-d4c4-29f0-d0feec4e355c.task2.scope/cpuset.cpus
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@shoenig
shoenig / pebble.nomad.hcl
Created February 23, 2023 21:12
hack demo feb 2023
job "pebble" {
type = "service"
group "pebble" {
network {
mode = "host"
port "acme" {
static = 6666
}
port "mgmt" {
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)