Skip to content

Instantly share code, notes, and snippets.

View jsturtevant's full-sized avatar
💻
right clicking and viewing the source

James Sturtevant jsturtevant

💻
right clicking and viewing the source
View GitHub Profile
@jsturtevant
jsturtevant / libc-handle-to-rust-ownedhandle.rs
Created May 2, 2024 23:05
convert libc handle to rust OwnedHandle
crates/containerd-shim-wasm/src/sys/windows/stdio.rs
```
pub fn as_owned(&self)-> Option<OwnedHandle> {
if let Some(fd) = self.as_raw_fd() {
return Some(unsafe {OwnedHandle::from_raw_handle(get_osfhandle(fd) as _)});
}
None
#!/usr/bin/env bash
set -e
echo test > test.txt
sudo ctr --debug -n ingest-bug content ingest --expected-size 5 --expected-digest sha256:f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 test-content-foo < test.txt
sudo ctr --debug -n ingest-bug content ls
sudo ctr --debug -n ingest-bug content rm sha256:f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
sudo ctr --debug -n ingest-bug content ingest --expected-size 5 --expected-digest sha256:f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 test-content-foo < test.txt
echo its there!
@jsturtevant
jsturtevant / termination.bat
Created January 4, 2024 20:12
termination-log investigation
PS C:\apps> cmd /c ver
Microsoft Windows [Version 10.0.25398.469]
mkdir C:\var\lib\test
new-item -ItemType file -name termination-log -Path C:\var\lib\test
.\ctr.exe i pull registry.k8s.io/e2e-test-images/busybox:1.36.1-1
.\ctr.exe run -rm --mount="src=c:\termination-log,dst=c:\dev\termination-log" --user ContainerUser registry.k8s.io/e2e-test-images/busybox:1.36.1-1 test cmd
@jsturtevant
jsturtevant / vhd-to-sig.ps1
Created September 28, 2023 23:13
upload a vhd to a sig
$location="eastus"
$galleryName="SigWinTestingImages"
$resourceGroup="annual-channel"
$imageDefinition="capi-windows-annual"
$publisher="sigwincapi"
$offer="annualChannel"
$sku="original"
$storageAccountName="sigwin"
$subscription=""
$storageContainer="annualchvhd"
@jsturtevant
jsturtevant / test.sh
Created August 18, 2023 22:33
run test till failure
#!/usr/bin/env bash
counter=0
while [ $counter -lt 100 ]; do
let counter++
echo "Attempt: $counter"
# Run the command
@jsturtevant
jsturtevant / setting.json
Created August 9, 2023 19:50
vs code wasm-edge settings for rust
{
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.cargo.extraEnv": {
"WASMEDGE_LIB_DIR": "C:\\Program Files\\WasmEdge\\lib",
"WASMEDGE_INCLUDE_DIR": "C:\\Program Files\\WasmEdge\\include"
}
}
@jsturtevant
jsturtevant / launch.json
Last active April 18, 2023 16:17
rust debugging configurations
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(skeleton) Launch",
"type": "cppvsdbg",
"request": "launch",
func windowsCpuAndMemoryStats(stats *types.Metric) (*runtime.WindowsContainerStats, error) {
var cs runtime.WindowsContainerStats
if stats != nil {
s, err := typeurl.UnmarshalAny(stats.Data)
if err != nil {
return nil, fmt.Errorf("failed to extract container metrics: %w", err)
}
wstats := s.(*wstats.Statistics).GetWindows()
if wstats == nil {
return nil, fmt.Errorf("windows stats is empty")
var td TrustDomain
func BenchmarkGetTrustDomains(b *testing.B) {
m := &Manager{
signingIssuer: &issuer{TrustDomain: "cluster.local"},
validatingIssuer: &issuer{TrustDomain: "cluster.local"},
}
var t TrustDomain
b.ReportAllocs()
for n := 0; n < b.N; n++ {