<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by zero_backend_bro on Medium]]></title>
        <description><![CDATA[Stories by zero_backend_bro on Medium]]></description>
        <link>https://medium.com/@zero_backend_bro?source=rss-dad09a583d48------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GyeeWchtDn2ug4Cj</url>
            <title>Stories by zero_backend_bro on Medium</title>
            <link>https://medium.com/@zero_backend_bro?source=rss-dad09a583d48------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:55:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zero_backend_bro/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Fix Docker COPY Failed: stat no source files specified]]></title>
            <link>https://medium.com/@zero_backend_bro/how-to-fix-docker-copy-failed-stat-no-source-files-specified-b9617d4fe9f0?source=rss-dad09a583d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9617d4fe9f0</guid>
            <dc:creator><![CDATA[zero_backend_bro]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 06:15:20 GMT</pubDate>
            <atom:updated>2026-07-18T06:15:20.225Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Incident (What Does the Error Mean?)</h3><p>Raw error output from docker build:</p><pre>&gt; [build 3/6] COPY  /app:<br>------<br>COPY failed: stat no source files were specified</pre><p>or the variant:</p><pre>COPY failed: stat /var/lib/docker/tmp/buildkit-mount123456/src: no such file or directory</pre><p>Docker’s BuildKit evaluates the COPY instruction at build time by resolving each source path <strong>relative to the build context</strong> sent to the daemon. When the source argument is blank, a glob matches nothing, or the path sits outside the context root, BuildKit has nothing to stat() and throws a fatal error. <strong>The image layer is never written. The build exits non-zero. Your pipeline is dead.</strong></p><h3>The Attack Vector / Blast Radius</h3><p>This is not a runtime error — it’s a <strong>build-time hard failure</strong>, which means:</p><ul><li><strong>Every downstream stage in a multi-stage build is skipped.</strong> A broken COPY in stage 1 means your final production image is never produced.</li><li><strong>CI/CD pipelines fail and block deployments.</strong> In a trunk-based workflow, a single bad Dockerfile commit can lock an entire release train.</li><li><strong>Silent </strong><strong>.dockerignore exclusions are the most dangerous variant.</strong> A developer adds src/ to .dockerignore to speed up local builds, pushes the change, and the remote CI runner — which has no cached layers — hits this error with zero obvious connection to the .dockerignore change. Root-causing this across a team costs 30–90 minutes of wasted engineering time per occurrence.</li><li><strong>Parameterized </strong><strong>COPY via </strong><strong>ARG is a second common vector.</strong> If a --build-arg is not passed at build time, the ARG resolves to empty string, and COPY $SRC_PATH /app becomes COPY /app — exactly the error above.</li></ul><h3>How to Fix It (The Solution)</h3><h3>Root Cause Checklist</h3><p>Before touching code, run through these in order:</p><ol><li><strong>Is the source path spelled correctly and relative to the build context?</strong> COPY src/app.py /app/ requires src/app.py to exist at &lt;build-context&gt;/src/app.py.</li><li><strong>Is the file excluded by </strong><strong>.dockerignore?</strong> Run cat .dockerignore and check for glob patterns that swallow your source.</li><li><strong>Is an </strong><strong>ARG used as the source and not passed via </strong><strong>--build-arg?</strong> An unset ARG is an empty string.</li><li><strong>Is the build context path correct in your </strong><strong>docker build command?</strong> docker build -f infra/Dockerfile . vs docker build -f infra/Dockerfile ./infra/ — the trailing path is the context root.</li></ol><h3>Basic Fix — Empty or Mistyped Source</h3><pre>- COPY  /app/<br>+ COPY src/ /app/</pre><pre>- COPY ./buid/output/ /app/<br>+ COPY ./build/output/ /app/</pre><h3>Enterprise Best Practice — ARG-Driven COPY with Validation</h3><p>Never use a bare ARG as a COPY source without a default and a guard.</p><pre>- ARG SOURCE_DIR<br>- COPY $SOURCE_DIR /app/</pre><pre>+ ARG SOURCE_DIR=src<br>+ # Validate ARG is non-empty before COPY<br>+ RUN test -n &quot;$SOURCE_DIR&quot; || (echo &quot;ERROR: SOURCE_DIR build-arg is required&quot; &amp;&amp; exit 1)<br>+ COPY ${SOURCE_DIR}/ /app/</pre><p><strong>Multi-stage build — ensure context files are present before the COPY stage:</strong></p><pre>FROM node:20-alpine AS builder<br>  WORKDIR /build<br>- COPY . .<br>- RUN npm ci &amp;&amp; npm run build</pre><pre>+ # Be explicit. Never COPY the entire context blindly.<br>+ COPY package.json package-lock.json ./<br>+ RUN npm ci<br>+ COPY src/ ./src/<br>+ RUN npm run build</pre><pre>  FROM nginx:1.25-alpine<br>- COPY --from=builder /build/dist /usr/share/nginx/html<br>+ COPY --from=builder /build/dist/ /usr/share/nginx/html/</pre><p><strong>Fix a </strong><strong>.dockerignore over-exclusion:</strong></p><pre>- src/<br>+ # src/ removed — required by COPY src/ /app/<br>+ node_modules/<br>+ .git/<br>+ *.log</pre><h3>Prevention in CI/CD</h3><p><a href="https://stackengine.dev/docker-copy-stat-no-source-files#prevention-in-ci-cd">https://stackengine.dev/docker-copy-stat-no-source-files#prevention-in-ci-cd</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9617d4fe9f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing AKS NodePressure Memory Eviction with Azure Disk CSI: Root Cause & Recovery Guide]]></title>
            <link>https://medium.com/@zero_backend_bro/fixing-aks-nodepressure-memory-eviction-with-azure-disk-csi-root-cause-recovery-guide-1fd6923dea17?source=rss-dad09a583d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd6923dea17</guid>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[zero_backend_bro]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 02:51:15 GMT</pubDate>
            <atom:updated>2026-07-17T02:51:15.367Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Incident (What Does the Error Mean?)</h3><p>You will see this in kubectl describe pod &lt;pod-name&gt;:</p><pre>Status:     Failed<br>Reason:     Evicted<br>Message:    The node was low on resource: memory.<br>            Threshold quantity: 100Mi, available: 42Mi.<br>            Container &lt;name&gt; was using 1.9Gi, request is 0.</pre><p>And on the node:</p><pre>kubectl describe node &lt;node-name&gt;</pre><pre>Conditions:<br>  Type                 Status<br>  MemoryPressure       True     # &lt;-- kubelet has declared war<br>  DiskPressure         False<br>  PIDPressure          False<br>  Ready                False</pre><p><strong>Immediate consequence:</strong> Kubelet terminates pods in priority order — BestEffort first (no requests/limits set), then Burstable, then Guaranteed. If your pod had no resources.requests, it is BestEffort and dies first, every time. The Azure Disk CSI driver then fails to detach the PersistentVolume cleanly because the pod was force-killed, leaving a VolumeAttachment object in Terminating state that blocks the pod from starting on a new node.</p><h3>The Attack Vector / Blast Radius</h3><p>This is not a single-pod problem. The cascade goes:</p><ol><li><strong>One noisy-neighbor pod</strong> (no memory limit) balloons and consumes node memory.</li><li><strong>Kubelet evicts BestEffort pods</strong> — likely your stateful workloads with CSI disks, since those are often misconfigured.</li><li><strong>Azure Disk CSI </strong><strong>VolumeAttachment gets stuck</strong> — the external-attacher sidecar in the CSI controller can&#39;t issue a ControllerUnpublishVolume to the Azure API fast enough before the node is marked NotReady.</li><li><strong>Pod reschedule is blocked</strong> — Kubernetes scheduler sees the PV still attached to the dead node. The pod sits in ContainerCreating or Pending indefinitely with Multi-Attach error for volume.</li><li><strong>If you have no PodDisruptionBudget</strong>, a rolling eviction can take down your entire Deployment simultaneously.</li><li><strong>Node pool autoscaler</strong> may spin up a new node, but the stuck VolumeAttachment prevents the PV from binding to it — so you now have a new node and still a broken pod.</li></ol><p><strong>Blast radius:</strong> Full service outage for any stateful workload (databases, message queues, file processors) running on the affected node pool.</p><h3>How to Fix It</h3><h3>Step 1: Unblock the Stuck VolumeAttachment (Immediate)</h3><p>If your pod is stuck in ContainerCreating on a new node:</p><pre># Identify the stuck attachment<br>kubectl get volumeattachment</pre><pre># Force-delete the finalizer — do this ONLY if the source node is confirmed dead/drained<br>kubectl patch volumeattachment &lt;va-name&gt; \<br>  -p &#39;{&quot;metadata&quot;:{&quot;finalizers&quot;:null}}&#39; \<br>  --type=merge</pre><p><strong>Warning:</strong> Only remove the finalizer if you have confirmed the Azure Disk is not actually attached to any running VM. Check in the Azure Portal under the disk’s “Managed by” field.</p><h3>Step 2: Fix the Root Cause — Resource Requests &amp; Limits</h3><p>The BestEffort QoS class is the direct cause of priority eviction. Every container needs explicit requests.</p><pre>apiVersion: apps/v1<br> kind: Deployment<br> metadata:<br>   name: my-stateful-app<br> spec:<br>   template:<br>     spec:<br>       containers:<br>       - name: app<br>         image: myrepo/app:1.4.2<br>-        # No resources defined — BestEffort QoS, evicted first<br>+        resources:<br>+          requests:<br>+            memory: &quot;512Mi&quot;<br>+            cpu: &quot;250m&quot;<br>+          limits:<br>+            memory: &quot;1Gi&quot;<br>+            cpu: &quot;1000m&quot;</pre><p><strong>Enterprise Best Practice:</strong> Use Guaranteed QoS by setting requests == limits. This makes kubelet treat your pod as the last resort for eviction.</p><pre>resources:<br>           requests:<br>-            memory: &quot;512Mi&quot;<br>-            cpu: &quot;250m&quot;<br>+            memory: &quot;1Gi&quot;<br>+            cpu: &quot;500m&quot;<br>           limits:<br>             memory: &quot;1Gi&quot;<br>-            cpu: &quot;1000m&quot;<br>+            cpu: &quot;500m&quot;<br>+        # requests == limits =&gt; Guaranteed QoS class</pre><h3>Step 3: Tune Kubelet Eviction Thresholds via AKS KubeletConfig</h3><p>The default memory.available&lt;100Mi hard eviction threshold is dangerously low for nodes running CSI workloads. Raise the soft threshold so kubelet starts reclaiming memory gracefully before hitting the hard wall.</p><pre>apiVersion: v1<br> kind: ConfigMap<br> metadata:<br>   name: kubelet-config<br> # Apply via AKS node pool KubeletConfig in the ARM template or Bicep:<br>---<br> apiVersion: 2023-01-01<br> type: Microsoft.ContainerService/managedClusters/agentPools<br> properties:<br>   kubeletConfig:<br>-    # Default: no custom eviction thresholds<br>+    evictionSoft:<br>+      memory.available: &quot;300Mi&quot;<br>+      nodefs.available: &quot;10%&quot;<br>+    evictionSoftGracePeriod:<br>+      memory.available: &quot;2m&quot;<br>+      nodefs.available: &quot;2m&quot;<br>+    evictionHard:<br>+      memory.available: &quot;150Mi&quot;<br>+      nodefs.available: &quot;5%&quot;<br>+    evictionMaxPodGracePeriod: 90</pre><p>Apply via Azure CLI:</p><pre>az aks nodepool update \<br>  --resource-group &lt;rg&gt; \<br>  --cluster-name &lt;cluster&gt; \<br>  --name &lt;nodepool&gt; \<br>  --kubelet-config kubelet-config.json</pre><h3>Step 4: Add a PodDisruptionBudget</h3><pre>+apiVersion: policy/v1<br>+kind: PodDisruptionBudget<br>+metadata:<br>+  name: my-stateful-app-pdb<br>+spec:<br>+  minAvailable: 1<br>+  selector:<br>+    matchLabels:<br>+      app: my-stateful-app</pre><h3>Prevention in CI/CD</h3><h3>OPA/Gatekeeper Policy — Block BestEffort QoS at Admission</h3><p>Deploy this ConstraintTemplate to reject any pod without resource requests:</p><pre>apiVersion: templates.gatekeeper.sh/v1<br>kind: ConstraintTemplate<br>metadata:<br>  name: requireresourcelimits<br>spec:<br>  crd:<br>    spec:<br>      names:<br>        kind: RequireResourceLimits<br>  targets:<br>    - target: admission.k8s.gatekeeper.sh<br>      rego: |<br>        package requireresourcelimits<br>        violation[{&quot;msg&quot;: msg}] {<br>          container := input.review.object.spec.containers[_]<br>          not container.resources.requests.memory<br>          msg := sprintf(&quot;Container &#39;%v&#39; missing memory request. BestEffort QoS is prohibited.&quot;, [container.name])<br>        }</pre><h3>Checkov — Scan IaC Before Apply</h3><pre># In your CI pipeline (GitHub Actions, Azure DevOps)<br>checkov -d ./k8s-manifests \<br>  --check CKV_K8S_11 \ # CPU limits<br>  --check CKV_K8S_13 \ # Memory limits<br>  --check CKV_K8S_10 \ # CPU requests<br>  --check CKV_K8S_12    # Memory requests</pre><h3>Node Pool Sizing — Right-Size Before You Tune Thresholds</h3><pre># Check actual memory consumption vs allocatable<br>kubectl describe node &lt;node&gt; | grep -A5 &quot;Allocated resources&quot;</pre><pre># If requests &gt; 80% of allocatable memory, scale the node pool<br>az aks nodepool scale \<br>  --resource-group &lt;rg&gt; \<br>  --cluster-name &lt;cluster&gt; \<br>  --name &lt;nodepool&gt; \<br>  --node-count &lt;n+2&gt;</pre><p><strong>Rule of thumb:</strong> Keep total pod memory requests below 70% of node allocatable memory to leave headroom for kubelet, system daemons, and CSI driver sidecars (which themselves consume 50–150Mi per node).</p><p><strong>Related Diagnostics :</strong></p><p><a href="https://stackengine.dev/aks-node-info-scale-up-failure">Fixing AKS ‘Failed to Get Node Info’ During NodePool Scale-Up: Root Cause &amp; Resolution</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd6923dea17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fix PostgreSQL ‘cannot execute CREATE TABLE in a read-only transaction’ Error]]></title>
            <link>https://medium.com/@zero_backend_bro/how-to-fix-postgresql-cannot-execute-create-table-in-a-read-only-transaction-error-0fb44666c449?source=rss-dad09a583d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fb44666c449</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[zero_backend_bro]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 09:34:10 GMT</pubDate>
            <atom:updated>2026-06-15T09:34:10.570Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Incident</h3><pre>ERROR:  cannot execute CREATE TABLE in a read-only transaction<br>CONTEXT:  SQL function &quot;migrate_schema&quot; during inlining</pre><p>Postgres enforces a hard wall: no DDL, no DML writes, no sequence increments are permitted inside a read-only transaction. The moment the executor hits CREATE TABLE, it throws and rolls back the entire transaction block. If this fires mid-migration (Flyway, Liquibase, Alembic, Django), your schema is left in a partial state — the migration tool may mark the version as failed, requiring manual repair of the migration history table before the next deploy can proceed.</p><h3>The Attack Vector / Blast Radius</h3><p>This is not a security exploit in the traditional sense — but the blast radius in a production pipeline is severe:</p><ol><li>Replica misrouting (most common prod incident): A connection pooler (PgBouncer, RDS Proxy, HAProxy) routes the migration runner to a read replica instead of the primary. Every DDL fails. The migration tool may retry in a loop, hammering the replica and spiking its replication lag.</li><li>default_transaction_read_only = on at the role or database level: A DBA hardened a reporting role or an entire database cluster with ALTER ROLE reporter SET default_transaction_read_only = on. If your migration runner inherits this role or connects to that DB, every transaction opens read-only silently. No warning. Just the error at DDL time.</li><li>Explicit SET TRANSACTION READ ONLY in a wrapper: A shared DB utility function or ORM hook sets SET TRANSACTION READ ONLY for &quot;safe&quot; read operations and the DDL accidentally executes inside that context.</li><li>RDS/Aurora Multi-AZ failover window: During failover, the old primary becomes a replica. Connections that survive the failover are now on a read-only node. Migrations queued during this window fail with exactly this error.</li></ol><p>Cascading risk: Liquibase/Flyway lock the DATABASECHANGELOGLOCK table at migration start. If the transaction fails mid-flight, the lock row may remain set to TRUE, blocking all future migration runs until manually cleared.</p><h3>How to Fix It</h3><h3>Basic Fix — Verify and Override Transaction Mode</h3><pre>- -- Implicit read-only context inherited from role or pooler<br>- BEGIN;<br>- CREATE TABLE orders (id SERIAL PRIMARY KEY, total NUMERIC);<br>- COMMIT;</pre><pre>+ -- Explicitly assert READ WRITE before DDL<br>+ BEGIN;<br>+ SET LOCAL default_transaction_read_only = off;  -- override session GUC for this txn<br>+ SET TRANSACTION READ WRITE;                      -- belt-and-suspenders<br>+ CREATE TABLE orders (id SERIAL PRIMARY KEY, total NUMERIC);<br>+ COMMIT;</pre><blockquote>Note: SET LOCAL only survives the current transaction block. This is intentional — do not use SET (session-level) in a shared connection pool.</blockquote><h3>Verify You Are on the Primary</h3><pre>- -- Blindly running migration against pool VIP<br>- psql -h db-pool.internal -U migrator -d appdb -f migrate.sql</pre><pre>+ -- Confirm primary before running DDL<br>+ psql -h db-pool.internal -U migrator -d appdb \<br>+   -c &quot;SELECT CASE WHEN pg_is_in_recovery() THEN &#39;REPLICA - ABORT&#39; ELSE &#39;PRIMARY - OK&#39; END AS node_role;&quot;<br>+ # Only proceed if output is &#39;PRIMARY - OK&#39;<br>+ psql -h db-pool.internal -U migrator -d appdb -f migrate.sql</pre><h3>Enterprise Best Practice — Role Hygiene + Connection Routing</h3><pre>- -- Migration runner uses shared &#39;app_user&#39; role with read-only default<br>- ALTER ROLE app_user SET default_transaction_read_only = on;</pre><pre>+ -- Dedicated migration role, never read-only, explicitly scoped<br>+ CREATE ROLE migrator NOINHERIT LOGIN PASSWORD &#39;...&#39;;<br>+ GRANT CREATE, CONNECT ON DATABASE appdb TO migrator;<br>+ -- DO NOT set default_transaction_read_only on this role<br>+ -- In PgBouncer: route migrator to primary_dsn ONLY<br>+ ; pgbouncer.ini<br>+ [databases]<br>+ appdb_migrate = host=primary.db.internal port=5432 dbname=appdb auth_user=migrator<br>+ appdb         = host=pool.db.internal   port=5432 dbname=appdb</pre><p>In RDS/Aurora, always resolve the cluster writer endpoint (cluster.cluster-xxxx.rds.amazonaws.com) — never the reader endpoint — for migration runners. Enforce this in your Terraform:</p><pre>- db_host = aws_rds_cluster.main.reader_endpoint<br>+ db_host = aws_rds_cluster.main.endpoint  # writer/primary endpoint</pre><h3>Prevention in CI/CD</h3><p>1. Pre-migration node role check (shell gate):</p><pre>#!/bin/bash<br>ROLE=$(psql &quot;$DATABASE_URL&quot; -tAc &quot;SELECT pg_is_in_recovery();&quot;)<br>if [ &quot;$ROLE&quot; = &quot;t&quot; ]; then<br>  echo &quot;FATAL: Connected to a replica. Aborting migration.&quot;<br>  exit 1<br>fi</pre><p>Drop this as a pre-step in your GitHub Actions / GitLab CI job before Flyway or Alembic runs.</p><p>2. Checkov / kics policy for Terraform RDS:</p><p>Ensure your Terraform never wires a migration runner to a reader endpoint. Write a custom Checkov check or use OPA:</p><pre># OPA: deny migration jobs targeting reader endpoints<br>deny[msg] {<br>  input.resource.type == &quot;kubernetes_deployment&quot;<br>  input.resource.spec.template.spec.containers[_].env[e]<br>  e.name == &quot;DATABASE_URL&quot;<br>  contains(e.value, &quot;reader&quot;)<br>  msg := &quot;Migration workload must not target a reader/replica endpoint.&quot;<br>}</pre><p>3. Liquibase / Flyway — fail fast on read-only:</p><p>Flyway 9+: set flyway.connectRetries=0 and flyway.validateOnMigrate=true. Do not let it retry silently into a replica loop.</p><p>4. Audit role defaults in your IaC:</p><pre># Detect any role with read-only default in your DB<br>psql -c &quot;SELECT rolname, rolconfig FROM pg_roles WHERE &#39;default_transaction_read_only=on&#39; = ANY(rolconfig);&quot;</pre><p>Run this as a nightly CI job and alert if your migration role appears in the output.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fb44666c449" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>