Skip to content

Instantly share code, notes, and snippets.

View pracucci's full-sized avatar

Marco Pracucci pracucci

View GitHub Profile
@pracucci
pracucci / gist:a5a390fe0cb3da5222208fffac92fcf7
Created July 25, 2023 15:37
Label names and values query implementation in Mimir (updated: 2023-07-25)
### Get label names
- Ingester
- TSDB LabelNames()
- Head
- Without matchers:
- Read from MemPostings -> fast
- With matchers:
- PostingsForMatchers() (like any query)
@pracucci
pracucci / spacer.yaml
Created May 6, 2022 08:25
Kubernetes deployment used as spacer, just to preallocate some resources in the cluster
apiVersion: apps/v1
kind: Deployment
metadata:
name: spacer
labels:
name: spacer
spec:
replicas: 1
selector:
matchLabels:
=== RUN TestWaitGroup_Race
==================
WARNING: DATA RACE
Write at 0x00c000128208 by goroutine 7:
internal/race.Write()
/usr/local/Cellar/go@1.14/1.14.9/libexec/src/internal/race/race.go:41 +0x114
sync.(*WaitGroup).Wait()
/usr/local/Cellar/go@1.14/1.14.9/libexec/src/sync/waitgroup.go:128 +0x115
github.com/cortexproject/cortex/pkg/util/concurrency.TestWaitGroup_Race()
/Users/marco/workspace/src/github.com/cortexproject/cortex/pkg/util/concurrency/waitgroup_test.go:19 +0xa6
@pracucci
pracucci / hub-next-pr-number.sh
Last active June 23, 2021 12:01
Run this script in any location containing a GitHub repository checkout/clone and it will guess the next PR number if you're going to open it shortly
#!/bin/bash
LAST_PR=$(hub pr list --state all -L 1 --format '%I')
LAST_ISSUE=$(hub issue --format '%I' -L 1)
if [ "$LAST_PR" == "" -a "$LAST_ISSUE" == "" ]; then
echo "Unable to get last PR and/or Issue number. Is your current working directory a public GitHub repository?"
exit 1
elif [ "$LAST_PR" -gt "$LAST_ISSUE" ]; then
echo `expr $LAST_PR + 1`

Keybase proof

I hereby claim:

  • I am pracucci on github.
  • I am pracucci (https://keybase.io/pracucci) on keybase.
  • I have a public key ASCVBazMo7Xgos06mnl6wk-eV9jJfMEpzDDzwIuQx3vdiwo

To claim this, I am signing this object:

@pracucci
pracucci / aws-ec2-nitro-instance-halt.md
Created August 12, 2019 16:44
Notes on differences on the "halt" command on AWS EC2 Nitro instances

The halt command on EC2 Nitro instances doesn't poweroff the instance, so the OS will shutdown but the instance will be in the running state indefinitely (until you force a "stop" or "termination" via EC2 console / API). This is because the hypervisor has changed and the shutdown signaling between OS and the hypervisor behaves differently.

Works (the instance switches to "stopped" or "terminated"):

  • halt --poweroff
  • shutdown now (defaults to --poweroff)

Doesn't work (the instance hungs into a "running" state):

  • halt
  • shutdown --halt
#!/bin/bash
#
# On 2018-08-21 we found out the existance of a bug in the Kubernetes cluster
# which leaves stale / dangling cgroups on the system related to secret volume
# mounts.
#
# The root cause of this bug is not clear yet, even if it's likely to be a systemd
# bug because the kubelet runs `systemd-run` command to mount secret volumes and,
# according to logs, successfully `unmount` such volumes once the pods terminates.
#
@pracucci
pracucci / gist:7ba56cdb4b74c1818cfa43775fdf929e
Created October 24, 2018 07:41
Bookmarklet to switch GitHub PR Files page width to 100%
javascript:(function()%7B%20var%20container%20%3D%20document.getElementsByClassName(%22new-discussion-timeline%22)%5B0%5D%3B%20if%20(container)%20%7B%20container.style.cssText%20%3D%20%22width%3A%20auto%3B%20margin-left%3A%2020px%3B%20margin-right%3A%2020px%22%3B%20%7D%7D)()
@pracucci
pracucci / spark-job-server-bootstrap.sh
Created May 23, 2018 17:16
Installation script for Spark JobServer on EMR
#!/bin/bash
#
# This is the script run on master as bootstrap action.
#
set -e
# Config
SJS_VERSION=0.8.0
EMR_VERSION=5.13.0
@pracucci
pracucci / Dockerfile
Created May 23, 2018 16:29
Compile and run Spark JobServer for Amazon EMR
FROM ubuntu:16.04
# Config
ARG SBT_VERSION=0.13.12
ARG SJS_VERSION=0.8.0
ARG EMR_VERSION=5.13.0
ARG SPARK_VERSION=2.3.0
# Install JDK 8 and some dependencies
RUN apt-get update -qq && apt-get install -y -qq openjdk-8-jdk wget python python-pip