Skip to content

Flake: iptables: create-instance-chains: iptables: Memory allocation problem. #3127

Closed as not planned

Description

@topherbullock

Flake Report

Occasionally it seems like Garden fails here when Concourse is trying to create a task container.

Examples

Observations

Additional Context

@kcmannem has a stack dump from PCI's issue

Version Info

  • Concourse version: 4.2.1 & 5.0.0
  • Deployment type (BOSH/Docker/binary): BOSH
  • Infrastructure/IaaS: GCP
  • Did this used to work? 🤷‍♂️

Activity

  1. kcmannem commented on Jan 23, 2019

    @kcmannem
    Contributor

    Garden team investigated this issue. They said just increase the workers memory. There is no other fix they can provide.

  2. cirocosta commented on Jan 23, 2019

    @cirocosta
    Contributor

    Which seems like a very weird remediation in this case - the workers were all at 20% utilization in our case (w/out limits being provided to the containers) 🤔

  3. vito commented on Jan 23, 2019

    @vito
    Contributor

    Yeah...gotta say I'm pretty skeptical. Our workers never really seem to show high memory usage. They already have 16GB each, I don't think this is a situation where we can just throw hardware at it.

    The only scenario I can imagine is a very quick spike in memory allocation that goes down just as quickly, but I find it hard to imagine a spike big enough to allocate ~12GB of RAM, let alone one that's quick enough to escape our metrics.

  4. kcmannem commented on Jan 23, 2019

    @kcmannem
    Contributor

    Heres what they had to say:

    "A hypothesis we had was that since this is only observed on iptables operations that perhaps the table within kernel memory keeping track of this stuff filled up. I’ve heard from people that iptable is pretty inefficient with memory when it’s persisting rules."

  5. vito commented on Jan 23, 2019

    @vito
    Contributor

    One thing of note is that build runs containers in Docker Compose, in a container. Could iptables rules be sticking around between builds? Or do they get cleaned up properly when the network namespace is destroyed?

  6. topherbullock commented on Jan 24, 2019

    @topherbullock
    ContributorAuthor

    Yeah, I don't think more worker memory will help here; the workers' memory utilization ~15% when the flake occurred.

    @vito Garden should destroy the iptables for the container when the container is destroyed (https://github.com/cloudfoundry/guardian/blob/7536c003d476be01a24401148db6238416f53c02/gardener/gardener_test.go#L830-L835, https://github.com/cloudfoundry/guardian/blob/7536c003d476be01a24401148db6238416f53c02/kawasaki/networker.go#L246-L278). I think any iptables entries created by Docker will go away; we'd probably notice a lot more issues if they were leaking

  7. davidjahn commented on Jan 30, 2019

    @davidjahn

    Just chiming in that we are noticing this flake as well when we are running slightly more containers/worker than usual (~160 on one with highest load).

  8. marco-m commented on Feb 8, 2019

    @marco-m
    Contributor

    We started seeing the same with 5.0 RC54

  9. cirocosta commented on Feb 8, 2019

    @cirocosta
    Contributor

    Hey @marco-m ,

    Do you also see this happening only in workers with more containers than the usual like @davidjahn ?

    thx!

  10. wagdav commented on Feb 8, 2019

    @wagdav
    Contributor

    @cirocosta

    @marco-m and I summarized what we see in #3251

  11. edude03 commented on Feb 23, 2019

    @edude03

    We're seeing this with 5.0.0-rc4 when there are more builds than usual as well.

  12. marco-m commented on Feb 23, 2019

    @marco-m
    Contributor

    To summarize: we are currently using RC78, which contains the fix for #3251. We don't see any more the iptables error. We have a distribution of containers per worker of average 100 (very low because we are currently running overprovisioned).

    @edude03 I strongly suggest to upgrade and to try fewest as container placement srategy; RC4 was pre #3251.

  13. lrstanley commented on Apr 11, 2019

    @lrstanley
    Contributor

    Noticed this today as well.. still running v3.14.1, 16 workers in the environment this happened in, most at about ~120-150, but we cap at 250. I don't think it's necessarily due to the amount of containers (as, we frequently have workers peak over 200 without issue). I think I've only seen it a few times, so hard to say. Def. not seeing any memory issues, disk or inode issues, etc. We currently use random placement strategy as it's not a thing in the version we're running (upgrade is a work in progress.. a bit hard to do with almost 1,900 pipelines and ~240 teams).

  14. 10 remaining items

  15. colmtuohy commented on Jul 17, 2019

    @colmtuohy

    I saw the issue temporally on Concourse 5.2.0 for the email put resource (iptables: create-instance-chains: iptables: Memory allocation problem). Not sure what cleared the issue

  16. Rukenshia commented on Jul 18, 2019

    @Rukenshia

    We just upgraded to concourse 5.3.0 and also experience this problem.

    We use this stemcell in bosh:

    - alias: xenial
      os: ubuntu-xenial
      version: 315.64
    
  17. suhlig commented on Aug 4, 2019

    @suhlig
    Contributor

    Ditto with 5.4.0 using the binaries on Ubuntu 18.04:

    # uname -a
    Linux ci 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    # lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.2 LTS
    Release:        18.04
    Codename:       bionic
    
  18. ddadlani commented on Aug 6, 2019

    @ddadlani
    Contributor

    we're going to push this investigation to after our containerd spike since this might go away if we move to containerd. For now the only lead we have is that it might need a kernel version bump.

  19. jwatson0 commented on Oct 4, 2019

    @jwatson0

    Got this today. Here's my dmesg stack trace in case it helps:

    [4595855.660122] iptables: vmalloc: allocation failure, allocated 0 of 331776 bytes, mode:0x14010c0(GFP_KERNEL|__GFP_NORETRY), nodemask=(null)
    [4595855.660124] iptables cpuset=/ mems_allowed=0
    [4595855.660129] CPU: 1 PID: 13184 Comm: iptables Not tainted 4.15.0-1044-aws #46-Ubuntu
    [4595855.660130] Hardware name: Amazon EC2 c5d.large/, BIOS 1.0 10/16/2017
    [4595855.660131] Call Trace:
    [4595855.660137]  dump_stack+0x63/0x8b
    [4595855.660140]  warn_alloc+0xff/0x1a0
    [4595855.660144]  __vmalloc_node_range+0x170/0x270
    [4595855.660145]  __vmalloc_node_flags_caller+0x47/0x50
    [4595855.660151]  ? xt_alloc_table_info+0x39/0x80 [x_tables]
    [4595855.660154]  kvmalloc_node+0x61/0x80
    [4595855.660156]  xt_alloc_table_info+0x39/0x80 [x_tables]
    [4595855.660159]  do_ipt_set_ctl+0xd0/0x1c0 [ip_tables]
    [4595855.660163]  nf_setsockopt+0x4c/0x80
    [4595855.660165]  ip_setsockopt+0x6c/0x80
    [4595855.660169]  raw_setsockopt+0x34/0x40
    [4595855.660172]  sock_common_setsockopt+0x1a/0x20
    [4595855.660174]  SyS_setsockopt+0x86/0xf0
    [4595855.660178]  do_syscall_64+0x73/0x130
    [4595855.660181]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    [4595855.660183] RIP: 0033:0x7f7eacd56e6a
    [4595855.660184] RSP: 002b:00007fff77e1d598 EFLAGS: 00000202 ORIG_RAX: 0000000000000036
    [4595855.660185] RAX: ffffffffffffffda RBX: 0000000000bc9970 RCX: 00007f7eacd56e6a
    [4595855.660186] RDX: 0000000000000040 RSI: 0000000000000000 RDI: 0000000000000004
    [4595855.660187] RBP: 00007f7ead53e070 R08: 000000000004ff48 R09: 00007f7ead58dc60
    [4595855.660188] R10: 00007f7ead53e010 R11: 0000000000000202 R12: 0000000000bc9978
    [4595855.660189] R13: 0000000000bc9978 R14: 00007f7ead53e010 R15: 0000000000000000
    [4595855.660190] Mem-Info:
    [4595855.660194] active_anon:182253 inactive_anon:31 isolated_anon:0
                      active_file:239432 inactive_file:367465 isolated_file:0
                      unevictable:0 dirty:2280 writeback:130 unstable:0
                      slab_reclaimable:46719 slab_unreclaimable:65974
                      mapped:21603 shmem:1290 pagetables:4703 bounce:0
                      free:21165 free_pcp:65 free_cma:0
    [4595855.660197] Node 0 active_anon:729012kB inactive_anon:124kB active_file:957728kB inactive_file:1469860kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:86412kB dirty:9120kB writeback:520kB shmem:5160kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 0kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
    [4595855.660197] Node 0 DMA free:14920kB min:284kB low:352kB high:420kB active_anon:676kB inactive_anon:0kB active_file:0kB inactive_file:288kB unevictable:0kB writepending:52kB present:15992kB managed:15908kB mlocked:0kB kernel_stack:0kB pagetables:4kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
    [4595855.660201] lowmem_reserve[]: 0 2972 3666 3666 3666
    [4595855.660203] Node 0 DMA32 free:57048kB min:54568kB low:68208kB high:81848kB active_anon:482000kB inactive_anon:48kB active_file:826444kB inactive_file:1291672kB unevictable:0kB writepending:6928kB present:3129320kB managed:3063752kB mlocked:0kB kernel_stack:17400kB pagetables:11032kB bounce:0kB free_pcp:68kB local_pcp:52kB free_cma:0kB
    [4595855.660207] lowmem_reserve[]: 0 0 693 693 693
    [4595855.660209] Node 0 Normal free:12692kB min:12728kB low:15908kB high:19088kB active_anon:246336kB inactive_anon:76kB active_file:131916kB inactive_file:177796kB unevictable:0kB writepending:2564kB present:800768kB managed:714624kB mlocked:0kB kernel_stack:6264kB pagetables:7776kB bounce:0kB free_pcp:192kB local_pcp:192kB free_cma:0kB
    [4595855.660212] lowmem_reserve[]: 0 0 0 0 0
    [4595855.660215] Node 0 DMA: 4*4kB (UMH) 3*8kB (UME) 4*16kB (UME) 3*32kB (MEH) 4*64kB (UEH) 3*128kB (UEH) 3*256kB (UEH) 2*512kB (UE) 4*1024kB (UMEH) 2*2048kB (UE) 1*4096kB (M) = 14920kB
    [4595855.660225] Node 0 DMA32: 7421*4kB (UMEH) 1624*8kB (UMEH) 667*16kB (UMEH) 87*32kB (UMEH) 5*64kB (MH) 6*128kB (H) 1*256kB (H) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 57476kB
    [4595855.660233] Node 0 Normal: 2798*4kB (UMEH) 302*8kB (UMEH) 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 13608kB
    [4595855.660241] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
    [4595855.660242] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
    [4595855.660243] 602190 total pagecache pages
    [4595855.660244] 0 pages in swap cache
    [4595855.660245] Swap cache stats: add 0, delete 0, find 0/0
    [4595855.660245] Free swap  = 0kB
    [4595855.660246] Total swap = 0kB
    [4595855.660246] 986520 pages RAM
    [4595855.660247] 0 pages HighMem/MovableOnly
    [4595855.660247] 37949 pages reserved
    [4595855.660248] 0 pages cma reserved
    [4595855.660248] 0 pages hwpoisoned
    
  20. marco-m commented on Oct 5, 2019

    @marco-m
    Contributor

    @jwatson0 which version of Concourse ?

  21. matt-royal commented on Oct 15, 2019

    @matt-royal

    @suhlig It looks like Ubuntu 18.04.2 doesn't have the version of the kernel with the fix. It ships with kernel 4.18. Ubuntu 18.04.3 ships with kernel 5.0. Let us know if you get a chance to test it with the new kernel.

    Unfortunately, my team deploys our Concourses with bosh and there's no short-term plan to release any Ubuntu stemcell newer than Xenial, so there's little hope of us being able to try with kernel 4.19 or newer.

  22. mreider commented on Jan 22, 2020

    @mreider

    Hell friends. We have the same problem as @matt-royal - so we are curious how the Concourse team is deploying this. Clearly they are not using BOSH, for if they were, the stem cell would cause issues. This is causing a fair amount of churn with our pipelines and making product managers (like me) ask why we are using it in the first place.

  23. jamieklassen commented on Jan 24, 2020

    @jamieklassen

    @mreider we're using the helm chart on k8s (specifically GKE, where node images since v1.15.4-gke.22 have had the necessary kernel)! That said, we do have some pretty hefty integration test suites that use BOSH using the GCP Xenial stemcells from bosh.io -- maybe we're conveniently missing the scenarios where this bug tends to creep up.

  24. deleted a comment from stale on Jun 8, 2020
  25. blairboy362 commented on Jul 24, 2020

    @blairboy362

    Hi friends. We hit this recently and I thought I'd share my conclusions in case it helps anyone.

    It's a memory fragmentation problem. I'm not familiar enough with concourse to know how or why it got worse recently, but I'm confident concourse is responsible for the majority of the fragmentation. Using the example from @jwatson0's comment above:

    [4595855.660122] iptables: vmalloc: allocation failure, allocated 0 of 331776 bytes, mode:0x14010c0(GFP_KERNEL|__GFP_NORETRY), nodemask=(null)
    ...snip...
    [4595855.660233] Node 0 Normal: 2798*4kB (UMEH) 302*8kB (UMEH) 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 13608kB
    

    iptables is attempting to allocate 324 KiB and failing. There are no slabs 512 KiB (or bigger; the next size up from the required 324 KiB) available. cat /proc/buddyinfo gives the same info as the second line above.

    image
    This graph is from our investigation showing the difference in fragmentation between a node running a concourse worker and one that isn't. The metrics come from the prometheus node exporter with the buddy collector enabled.

    In our context we're running concourse on kubernetes (using the helm chart). As one might imagine, and as others have commented on above, the more stuff running on a single node the bigger the iptables configuration and the more likely this problem is to be hit. We've worked around it so far by forcing the worker pods onto their own nodes. But that will only push the problem downstream a bit.

  26. vito commented on Jul 30, 2020

    @vito
    Contributor

    @blairboy362 Thanks for sharing! That sounds like a useful thing to watch out for in the future.

    Giving worker pods their own nodes makes a lot of sense given the current way things work. In the future I think that will be ultimately resolved with our own K8s native runtime, which we're planning to start very soon (possibly next week).

    In the meantime, this may improve with our upcoming containerd worker backend which configures fewer rules (#5534 (comment)).

    TBH if the real problem is that the worker genuinely cannot allocate memory for some other arbitrary reason, I'm not totally sure what we could do. 🤔 I wonder if using some interface other than iptables would help.

    Is anyone still running into this issue in a single-dedicated-worker-VM context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions