Skip to content

Instantly share code, notes, and snippets.

View frobware's full-sized avatar

Andrew McDermott frobware

  • Red Hat
  • UK
  • 09:26 (UTC +01:00)
View GitHub Profile
@frobware
frobware / README-git-crypt.md
Created June 15, 2024 20:31
git-crypt setup

Initialise Repository with git-crypt

Initialise the repository:

$ git-crypt init

Git Attributes Setup

@frobware
frobware / NE1690.md
Last active May 7, 2024 17:26
NE1690: Analyse Memory Impact of Pre-Allocated Server Slots for Different Numbers of Routes

HAProxy version 2.8.5-aaba8d0 2023/12/07 - https://haproxy.org/

Algorithm=leastconn, Weight=1 maxconn=50000 (T=#Threads B=#Backends)

server-template range: 0..N  T4 B100 RSS (MB)  T4 B1000 RSS (MB)  T4 B10000 RSS (MB)  T64 B100 RSS (MB)  T64 B1000 RSS (MB)  T64 B10000 RSS (MB)
---------------------------  ----------------  -----------------  ------------------  -----------------  ------------------  -------------------
                          0                12                 18                  81                 17                  24                   86
                          1                12                 22                 123                 18                  32                  168
                          2                13                 27                 166                 19                  40                  249
                
@frobware
frobware / OCPBUGS-29690-match-weight-is-0
Created April 11, 2024 14:01
OCPBUGS-29690: Match weight == 0
#!/usr/bin/env perl
use strict;
use warnings;
# Store the current backend block.
my $backend_block = '';
# Flag to start capturing lines into the backend block.
my $capture_block = 0;
@frobware
frobware / OCPBUGS-29690-fix-weight256
Created April 9, 2024 12:33
Replace 'weight 256' with 'weight 1' for backends with a single server entry
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Digest::MD5 qw(md5_hex);
my $obfuscate = 0; # No obfuscation by default.
my $fix_singular_weight256 = 0; # Conditionally rewrite 'weight 256'
@frobware
frobware / OCPBUGS-29690-replace-console-image.md
Last active March 27, 2024 10:33
Replace OpenShift Console image

Prerequisites

Extract the OpenShift Server Version directly from oc version.

$ current_version=$(oc version | grep 'Server Version' | awk '{print $3}')
4.12.45

Record the currently running console image ref:

$ original_console_image=$(oc adm release info $current_version -o json | jq -r '.references.spec.tags[] | select(.name == "console") | .from.name')
@frobware
frobware / OCPBUGS-29690-track-haproxy-config-changes
Created March 15, 2024 13:20
Track haproxy config changes
commit 22b7604a9aa18ac729707f5c0d82b17ad3ea80ab
Author: Andrew McDermott <amcdermo@redhat.com>
Date: Fri Mar 15 13:11:47 2024 +0000
reloads: track changes via diff
diff --git a/images/router/haproxy/reload-haproxy b/images/router/haproxy/reload-haproxy
index e0733ec2..cf94d121 100755
--- a/images/router/haproxy/reload-haproxy
+++ b/images/router/haproxy/reload-haproxy
# set reload interval to default (5s)
# oc patch -n openshift-ingress-operator ingresscontroller/default --type=merge --patch='{"spec":{"tuningOptions":{"reloadInterval":"5s"}}}'
# enable router access logs.
oc patch -n openshift-ingress-operator ingresscontroller/default --type=merge --patch='{"spec":{"logging":{"access":{"destination":{"type":"Container"}}}}}'
# let's concentrate on one router pod only.
oc scale -n openshift-ingress-operator ingresscontroller/default --replicas 1
# We're going to replace the router image and change the configuration
# set reload interval to default (5s)
# oc patch -n openshift-ingress-operator ingresscontroller/default --type=merge --patch='{"spec":{"tuningOptions":{"reloadInterval":"5s"}}}'
# enable router access logs.
oc patch -n openshift-ingress-operator ingresscontroller/default --type=merge --patch='{"spec":{"logging":{"access":{"destination":{"type":"Container"}}}}}'
# let's concentrate on one router pod only.
oc scale -n openshift-ingress-operator ingresscontroller/default --replicas 1
# We're going to replace the router image and change the configuration
@frobware
frobware / jsorder.go
Last active March 8, 2024 22:09
Sorts elements within a JSON document
// The JSON Order Utility sorts the elements within a JSON document,
// ensuring a consistent order of keys in JSON objects and sorting
// string arrays alphabetically. It operates on a generic JSON input,
// dynamically handling both JSON objects (maps) and arrays, including
// nested structures. For JSON objects, it orders the keys
// alphabetically. For arrays containing solely strings, it sorts the
// elements in ascending alphabetical order. Otherwise, it recursively
// processes each element in the array or object to achieve a fully
// ordered structure.
package main