MCPcopy Create free account
hub / github.com/PostHog/duckgres / parseK8sMemory

Function parseK8sMemory

controlplane/control.go:1456–1484  ·  view source on GitHub ↗

parseK8sMemory parses a Kubernetes memory string (e.g., "360Gi", "8Gi", "512Mi", "4GB") into bytes. Supports both IEC (Ki/Mi/Gi/Ti) and SI (KB/MB/GB/TB) units.

(s string)

Source from the content-addressed store, hash-verified

1454 msg = fmt.Sprintf("database %q does not exist", requestedCatalog)
1455 }
1456 sessionStart.Finish("error", observe.SessionStartReasonMetadataStore)
1457 _ = server.WriteErrorResponse(writer, "FATAL", "3D000", msg)
1458 _ = writer.Flush()
1459 return
1460 }
1461 duckLakeAttached = true
1462 database = visibleCatalogName(logicalCatalog, effectiveCatalog)
1463 defer destroySessionOnExit()
1464 // No slow pre-ready acquisition to watch: ReadyForQuery follows the
1465 // initial parameters immediately, so the disconnect watcher would only
1466 // contend with a client that pipelines its first query.
1467 } else {
1468 var admissionCtx context.Context
1469 admissionCtx, disconnectWatcher = startPreReadyDisconnectWatcher(preReadyCtx, tlsConn, reader)
1470 defer disconnectWatcher.Stop()
1471 createdPID, exec, err := createSessionWithRegisteredCancel(
1472 admissionCtx,
1473 cp.srv,
1474 cp.cfg.WorkerQueueTimeout,
1475 server.BackendKey{Pid: pid, SecretKey: secretKey},
1476 func(ctx context.Context) (int32, *flightclient.FlightExecutor, error) {
1477 return sessions.CreateSession(ctx, username, pid, memLimit, threads, initialProfile)
1478 },
1479 )
1480 executor = exec
1481 if cp.isDraining() {
1482 err = ErrSessionManagerDraining
1483 }
1484 if err != nil {
1485 // Session creation may have committed at the same instant a CancelRequest,
1486 // client FIN/RST, or drain canceled its context. Never retain that raced
1487 // session without a live client to own it.

Callers 3

workerDuckDBLimitsMethod · 0.85
parseK8sMemoryMiBFunction · 0.85
TestParseK8sMemoryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseK8sMemoryFunction · 0.68