cgroups | cgroups package for Go

 by   containerd Go Version: v3.0.1 License: Apache-2.0

kandi X-RAY | cgroups Summary

kandi X-RAY | cgroups Summary

cgroups is a Go library. cgroups has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Go package for creating, managing, inspecting, and destroying cgroups. The resources format for settings on the cgroup uses the OCI runtime-spec found here.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              cgroups has a medium active ecosystem.
              It has 958 star(s) with 212 fork(s). There are 29 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 12 open issues and 49 have been closed. On average issues are closed in 91 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of cgroups is v3.0.1

            kandi-Quality Quality

              cgroups has 0 bugs and 0 code smells.

            kandi-Security Security

              cgroups has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              cgroups code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              cgroups is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              cgroups releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cgroups
            Get all kandi verified functions for this library.

            cgroups Key Features

            No Key Features are available at this moment for cgroups.

            cgroups Examples and Code Snippets

            No Code Snippets are available at this moment for cgroups.

            Community Discussions

            QUESTION

            Linux: let a process fail, if it does opens a file for writing
            Asked 2022-Feb-08 at 11:49

            I would like a command-line-tool to fail if it opens a particular file for writing.

            Is there a way I can modify the environment (maybe via cgroups) of the command-line tool, so that the command/process gets (for example) "permission denied"?

            chmod a-w file does not work. The process seems to unlink() and then re-create the file.

            I know that I can watch the syscalls of a process with strace. But is there a way to alter some calls, so that the process gets a different result?

            Background: unittesting ...

            ANSWER

            Answered 2022-Jan-20 at 15:01

            strace has an option called -e inject or simply --inject which can be used to alter system calls of the tracee. (See manpage here)

            In particular, in can be combined with the -P option to only trace syscalls accessing a specified path.

            Source https://stackoverflow.com/questions/70773791

            QUESTION

            Unable to mount memory cgroup
            Asked 2022-Feb-04 at 19:19

            I'm attempting to mount the memory cgroup with the following command:

            sudo mount -t cgroup none /sys/fs/cgroup/memory -o memory

            I get the error:

            mount: /sys/fs/cgroup/memory: wrong fs type, bad option, bad superblock on none, missing codepage or helper program, or other error.

            I have all the cgroup kernel configuration options enabled and can mount the cpu, cpuset and devices cgroups without issue.

            What am I missing?

            Operating System: Raspberry Pi OS Lite (64-bit)

            Kernel Version: 5.10.95

            ...

            ANSWER

            Answered 2022-Feb-04 at 19:19

            Enabling memory cgroups and disabling cgroupv2 in the kernel commandline file with cgroup_enable=memory systemd.unified_cgroup_hierarchy=0 resolves the issue.

            Source https://stackoverflow.com/questions/70965770

            QUESTION

            Kubelet service is not running. It seems like the kubelet isn't running or healthy
            Asked 2021-Dec-05 at 08:04

            I have configured 1 master 2 workers. after installation successfully kubernetes. It is OK with worker1 joining cluster but I can not join worker2 to the cluster because kubelet service is not running. It seems like the kubelet isn't running or healthy

            sudo kubectl get nodes:

            NAME STATUS ROLES AGE VERSION
            master1 Ready control-plane,master 23m v1.22.2
            node1 NotReady 4m13s v1.22.2

            I want to know why the kubelet service is not running.

            Here kubelet logs.

            ...

            ANSWER

            Answered 2021-Dec-05 at 08:04

            First, check if swap is diabled on your node as you MUST disable swap in order for the kubelet to work properly.

            Source https://stackoverflow.com/questions/70229371

            QUESTION

            Unable to retrieve version information from Elasticsearch nodes. Request timed out
            Asked 2021-Dec-05 at 01:46

            I am installing Kibana and elasticsearch version 7.15.1 as per instructions mentioned in the link Install Kibana with Docker

            The commands I am using are

            ...

            ANSWER

            Answered 2021-Dec-03 at 12:50

            Your kibana service is missing information about elasticsearch user/password.

            Few days ago I tryied to create minimalistic swarm stack and this is result:

            docker-compose.yml

            Source https://stackoverflow.com/questions/69791608

            QUESTION

            How to get a pod name and namespace on a node running that pod?
            Asked 2021-Nov-05 at 15:07

            A node have a plenty of info for metrics collection, under cgroups kubepods.slice for example. but to complete the metric you have to relate a pod metric to a pod name. a name and namespace itself are kind of static metric of a pod, so they are first things alongside with pod uuid that it should have to describe a pod. How can i get this info from a node not using kubectl and not accessing remote kubernetes database of pods?

            i can find only container ids/ pod uuids as the parts of cgroup structure.. where is name and namespace? (ideally a whole yaml manifest, its not that hard to store it on a node that is running pod, right?)

            If its not having this info - why? that violates collection practices, you cannot do instrumentation as a single program that will collect pod metrics - you will require external process that will post-process such metrics, corresponding uuids to pods names and namespaces, and that is definetely not right approach, when you can have 1 small program running on the node itself

            ...

            ANSWER

            Answered 2021-Nov-05 at 15:07

            You may use docker inspect:

            Source https://stackoverflow.com/questions/69636534

            QUESTION

            docker can't connect to docker daemon but socket is created
            Asked 2021-Oct-27 at 09:55

            My problem is that I can use docker with for example Portainer but when I run docker on the machine on sudo docker can't connect to the daemon and tells me about it:

            All commands are done with root.

            ...

            ANSWER

            Answered 2021-Oct-27 at 09:55

            It looks like you have a container configured to bind mount /var/lib/docker.sock and the daemon restarted that container before creating the socket. There's been some tweeks to packaging in recent releases to reduce this chance. Otherwise you may want to mount the entire directory instead of a single file.

            To fix, try stopping docker, deleting the empty directory, and restarting docker to see if the socket gets created first (it's a race condition).

            Source https://stackoverflow.com/questions/69736274

            QUESTION

            What is the difference between cgroups freeze and linux command "Kill - STOP pid" in golang?
            Asked 2021-Sep-30 at 06:01

            I use this cgroups package.

            There are two interfaces I am interested in for type Cgroup. The one is Freeze() error and the other is Thaw() error.The description of them is as follows:

            ...

            ANSWER

            Answered 2021-Sep-30 at 06:01

            Both states were introduced in oct. 2016 in containerd/cgroups commit b3f3344 and refer to cgroup v1 self-state

            The cgroup freezer is hierarchical.

            Freezing a cgroup freezes all tasks beloning to the cgroup and all its descendant cgroups.
            Each cgroup has its own state (self-state) and the state inherited from the parent (parent-state).
            Iff both states are THAWED, the cgroup is THAWED.

            CGroup Freezer states:

            freezer.state is only available in non-root cgroups and has three possible values:

            • FROZEN — tasks in the cgroup are suspended.
            • FREEZING — the system is in the process of suspending tasks in the cgroup.
            • THAWED — tasks in the cgroup have resumed.

            Meaning (here):

            The freezer subsystem is used to suspend and resume processes in the cgroup.

            Freezer has a control file: freezer.state, write FROZEN to this file, you can suspend the process in the cgroup, and write THAWED to this file, you can resume the suspended process.

            Source https://stackoverflow.com/questions/69385740

            QUESTION

            Powershell script to group multiple identical rows with different column
            Asked 2021-Sep-16 at 14:08

            I have the below CSV exported from powershell "objectGUID","sAMAccountName","givenName","SN","Description","mail","memberOf","preferredLanguage","manager","title","company","distinguishedName"

            The only difference is MemberOf. In AD a user is member of multiple AD groups and we want to export the user and his groups, the groups have to be exported in the same column not on different rows.

            The code i wrote to get the output is

            ...

            ANSWER

            Answered 2021-Sep-16 at 14:08

            Thanks for the info about IID2GUID, so I won't bother with that.

            Your code could be optimized by

            1. capture the objects returned in a variable and save that to csv instead of appending to the csv in every iteration
            2. You seem to ask for various user properties where they are never used and/or already returned by default by the various Get-AD* cmdlets
            3. You're building each object 'old school' and by using [PsCustomObject]@{..} I think the readability of the code would improve

            Source https://stackoverflow.com/questions/69173194

            QUESTION

            Popup message on the user interface
            Asked 2021-Aug-25 at 15:08

            [![enter image description here][1]][1] In this method how can I check if the formkey attribute actually has a value and if it does not then change the status from "saving" to "failing" and a popup message to the user that the particular user task has no form key?

            ...

            ANSWER

            Answered 2021-Aug-25 at 15:08

            I would make the formKey required and use the form submit event to save.

            Then the code would not even be executed.

            Otherwise

            Source https://stackoverflow.com/questions/68924535

            QUESTION

            Linux kernel - What is the relationship between page cache, struct address_space, and memory cgroups?
            Asked 2021-Aug-04 at 02:06

            I'm trying to understand the Linux page cache and how it relates to memory cgroups (v2). I know that with cgroupsv1, memory cgroups can be isolated and have independent LRU lists (I assume cgroupsv2 is the same). This and the fact that mm/vmscan.c has many references to mem_cgroups and has a function called shrink_node_memcgs, makes me think that each cgroup has its own page cache. Is this assumption true? Do all pages in a page cache belong to a single cgroup?

            If it is true, I know that a page cache is represented by struct address_space (here). How can you find out what cgroup is associated with a given struct address_space? Would I have to just find the first page in the struct address_space and then find the cgroup from the page?

            ...

            ANSWER

            Answered 2021-Aug-04 at 02:04

            After doing a lot of investigating, there are several issues in my original understanding.

            First, the page cache is a collection of non-contiguous pages residing in memory. It's easy to fall into the trap of thinking about "the page cache" as a single contiguous blocks/pages of memory (similar to a hardware cache), but the page cache is just the collection of some number of pages in memory that is available for future accesses.

            These pages in "the page cache" aren't even stored together virtually. As in, the kernel doesn't keep all pages in the page cache in one global struct or list. Instead, the better way to think about it is that the page cache is actually the union of all LRU lists in the kernel.

            This and the fact that mm/vmscan.c has many references to mem_cgroups and has a function called shrink_node_memcgs, makes me think that each cgroup has its own page cache.

            As mentioned, each cgroup has its own LRU lists. Each cgroup, however, does not have its own page cache. But if you collate all LRUs from all cgroups, you would hold all the pages of the page cache.

            I know that a page cache is represented by struct address_space

            This is incorrect. A struct address_space does represent some number of pages in the page cache, but it isn't itself representative of the entire page cache. struct address_space actually represents cached pages from a single inode (file) or block device (see the host member in the address_space struct). In fact, one of the links in the original post has this quote: "A better name [for struct address_space] is perhaps page_cache_entity or physical_pages_of_a_file." (pg.327, chapter 16)

            How can you find out what cgroup is associated with a given struct address_space?

            Since an address_space corresponds to a single inode (file) and not to a single cgroup, it isn't the case that all pages in this struct are charged to the same cgroup and therefore reside on the same cgroup LRU lists. For instance, imagine that one process in cgroup 1 reads the beginning of a large file, but another process in cgroup 2 reads the end of that file. The pages each process accessed are from the same inode and struct address_space, but some of these pages will be in cgroup 1's LRU lists and others in cgroup 2's.

            So it is not possible to find a cgroup from a struct address_space. Instead, in theory, you could iterate through the struct address_space pages and then find the cgroup that corresponds to each individual page (page->mem_cgroup->css.cgroup).

            Keep in mind that it is possible that a page charged to one cgroup could still be shared/accessed by another process in a different cgroup. See the rules about charging cgroups for shared memory here for v1 (Section 2.3) and here for v2 ("Memory Ownership").

            Addendum:

            During my research, I encountered this article that contributed to my confusion and led me to think an address_space was associated with a single cgroup. Image 4.2 makes it seem like address_space is buried within an mm_struct; and since mm_struct is specific to a process, then this address_space should also correspond to a process and, by extension, that process' cgroup. In reality, the process that this mm_struct corresponds to holds a file descriptor (represented by struct file) of a file and this file descriptor leads to the file inode and its corresponding address_space. This address_space is needed to find pages specifically from this file in the "page cache".

            Source https://stackoverflow.com/questions/68593830

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install cgroups

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/containerd/cgroups.git

          • CLI

            gh repo clone containerd/cgroups

          • sshUrl

            git@github.com:containerd/cgroups.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link