Secure container capacity setting method and device and related equipment
By setting the data write capacity limit of the file system in a secure container, the problem of full disk space in a multi-tenant environment is solved, and the isolation effect between tenants is improved.
Patent Information
- Application Number
- CN202410994832.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-26
AI Technical Summary
Currently, secure containers have poor isolation between different tenants in a multi-tenant environment, resulting in full disk space and affecting the use of other tenants.
By obtaining the identification information of the target file in the file system, determining the namespace information to which it belongs, and setting the data writing capacity corresponding to the namespace to a preset value, avoiding the continuous writing of data and causing the disk space to be filled.
Enhanced the isolation effect of secure containers between different tenants, preventing disk space from being filled and ensuring normal use of other tenants.
Smart Images

Figure CN119025260A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of cloud computing technology, and in particular to a method and apparatus for setting the capacity of a secure container and related equipment. Background Art
[0002] With the continuous development of cloud computing technology, multiple tenants usually need to share the resources of the host node, and currently, secure containers are usually introduced to increase the isolation between different tenants. However, when a tenant continuously writes data in the secure container, the disk space may be filled up, which will affect the use of disk space by other tenants. It can be seen that the current secure container has a poor effect on the isolation between different tenants. Summary of the invention
[0003] The embodiments of the present invention provide a method, an apparatus and related equipment for setting the capacity of a security container to solve the problem that the current security container has a poor isolation effect on different tenants.
[0004] To solve the above problems, the present invention is achieved as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for setting capacity of a secure container, comprising:
[0006] Obtain identification information of M target files in the file system, the target files corresponding to the identification information one-to-one, and the M target files are files corresponding to the first security container;
[0007] When it is determined that N pieces of identification information among the M pieces of identification information all include target namespace information, setting a sum of data write capacities of N target files corresponding to the N pieces of identification information to a first preset value;
[0008] Wherein, M and N are both positive integers, and N is less than or equal to M.
[0009] In a second aspect, an embodiment of the present invention further provides a device for setting the capacity of a safety container, comprising:
[0010] A first acquisition module is used to acquire identification information of M target files in the file system, where the target files correspond to the identification information one by one, and the M target files are files corresponding to the first security container;
[0011] A setting module, configured to set the sum of data write capacities of N target files corresponding to the N identification information to a first preset value when it is determined that N identification information among the M identification information all include target namespace information;
[0012] Wherein, M and N are both positive integers, and N is less than or equal to M.
[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; the processor is used to read the program in the memory to implement the steps in the method described in the first aspect above.
[0014] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium for storing a program, wherein the program, when executed by a processor, implements the steps in the method described in the first aspect.
[0015] In a fifth aspect, an embodiment of the present invention further provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps in the method described in the first aspect above.
[0016] In an embodiment of the present invention, identification information of M target files in a file system is obtained, the target files correspond to the identification information one by one, and the M target files are files corresponding to the first security container; when it is determined that N of the M identification information all include target namespace information, the sum of the data write capacities of the N target files corresponding to the N identification information is set to a first preset value; wherein M and N are both positive integers, and N is less than or equal to M. In this way, the sum of the data write capacities of the N target files can be set to the first preset value, thereby avoiding the phenomenon that the disk space is filled up due to continuous data writing, and then the use of the disk space by other tenants is affected, that is, the isolation effect of the security container on different tenants is enhanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0018] Figure 1 It is a flowchart of a method for setting the capacity of a secure container provided by an embodiment of the present invention;
[0019] Figure 2 It is a functional schematic diagram of DIR namespace provided by an embodiment of the present invention;
[0020] Figure 3 is one of the corresponding relationship diagrams between the first user and the virtual shadow user provided in the embodiment of the present invention;
[0021] Figure 4This is the second corresponding relationship diagram between the first user and the virtual shadow user provided by the embodiment of the present invention;
[0022] Figure 5 It is a structural schematic diagram of a safety container capacity setting device provided by an embodiment of the present invention;
[0023] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] The terms "first", "second" etc. in the embodiments of the present invention are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. In addition, the terms "include" and "have" and any variation thereof are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units need not be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. In addition, "and / or" is used in the present application to represent at least one of the connected objects, such as A and / or B and / or C, which represents 7 situations including single A, single B, single C, and A and B all exist, B and C all exist, A and C all exist, and A, B and C all exist.
[0026] It should be noted that when in a serverless scenario, multiple tenants share host node resources, and secure containers need to be used to increase the isolation between different tenants. At present, Kata secure containers generally use virtio-fs and Overlayfs file systems, and the writable layer of the secure container root file system (rootfs) will eventually be mapped and shared to a directory on the host. In the serverless scenario, the rootfs of multi-tenant secure containers will still share the disk space on the host. If no additional capacity limit is imposed on the rootfs of each secure container, once a tenant in a secure container keeps writing data to the rootfs (container file system) in the container, the disk space on the host will eventually be filled up, causing insufficient space for the rootfs of other secure containers sharing the same disk space, thereby affecting the normal use of other tenants. However, there is a lack of known public solutions for limiting the capacity of the rootfs of Kata secure containers based on virtio-fs and Overlayfs file systems.
[0027] In view of the above technical problems, the following embodiments are proposed. Figure 1 , Figure 1 It is a flowchart of a method for setting the capacity of a secure container provided by an embodiment of the present invention. The embodiment of the present invention can be applied to a server, and the server can be understood as a server corresponding to a host node shared by multiple tenants. For example, the server can be a K8S server, and multiple tenants can be referred to as K8S tenants.
[0028] It should be noted that the secure container in the embodiment of the present application may refer to the Kata secure container rootfs based on the virtio-fs and Overlayfs file systems, that is, the scenario of the embodiment of the present application can be applied to the scenario corresponding to the Kata secure container rootfs based on the virtio-fs and Overlayfs file systems. However, there is currently a lack of a file system restriction solution with better performance for the capacity of the Kata secure container rootfs based on the virtio-fs and Overlayfs file system architecture.
[0029] like Figure 1 As shown, the method for setting the capacity of a security container may include the following steps:
[0030] Step 101: Obtain identification information of M target files in the file system, where the target files correspond one-to-one to the identification information, and the M target files are files corresponding to the first security container.
[0031] Among them, the identification information may refer to identification information used to distinguish the target file from other files. For example, the identification information may be the name information of the target file, and the name information may include a directory (Directory, DIR) namespace (namespace) attribute field. Specifically, it may be a DIR namespace identifier (Identifier, ID) attribute field, that is, the above-mentioned DIR namespace ID attribute field may be used to identify the DIR namespace to which the target file belongs.
[0032] It should be noted that the above identification information may be understood as at least part of the information included in the inode data structure (structure) of the target file.
[0033] The M target files may include at least one of the following: a directory file, a subdirectory file, a log file, a storage file, and the like.
[0034] Step 102: When it is determined that N of the M identification information include target namespace information, the sum of the data write capacities of the N target files corresponding to the N identification information is set to a first preset value; wherein M and N are both positive integers, and N is less than or equal to M.
[0035] The target namespace information may be referred to as a DIR namespace ID.
[0036] When the N identification information all include the target namespace information, it means that the N target files corresponding to the N identification information belong to the same category, and the specific content of the above category is not limited here. Optionally, when the N identification information all include the target namespace information, it means that the N target files corresponding to the N identification information belong to files under the same directory. That is, all files under the directory include the target namespace information.
[0037] Among them, the total data write capacity of N target files can be understood as: the sum of the data that can be written into the N target files. For example, if N is 2, the total data write capacity of the two target files can be 10kb (that is, the first preset value can be 10kb). When the total data written into the two target files reaches 10kb, it is prohibited to continue writing data into the above two target files. In this way, it can be avoided that the disk space is filled up due to continuing to write data into the two target files, which in turn causes the use of disk space by other tenants to be affected. This enhances the isolation effect of the secure container on different tenants.
[0038] It should be noted that the specific size of the writable data in the two target files is not limited here. It only needs to ensure that the sum of the writable data in the two target files is less than or equal to the first preset value. For example: 4kb can be written into one target file and 6kb can be written into the other target file; or, 3kb can be written into one target file and 7kb can be written into the other target file.
[0039] It should be noted that setting the sum of the data writing capacities of N target files to the first preset value can be called an extended file system project quota mechanism (i.e., limiting the maximum disk quota of N target files (where N target files may refer to a certain directory)).
[0040] In an embodiment of the present invention, through steps 101 to 102, the total data write capacity of N target files can be set to a first preset value, thereby avoiding the phenomenon that the disk space is filled up due to continuous data writing, which in turn affects the use of the disk space by other tenants, thereby enhancing the isolation effect of the security container on different tenants.
[0041] As an optional implementation manner, after setting the sum of the data write capacities of the N target files corresponding to the N identification information to a first preset value, the method further includes:
[0042] Obtaining a first sum of written data corresponding to the N target files;
[0043] When the first sum is equal to the first preset value, or the difference between the first sum and the first preset value is less than a preset difference, writing data to the N target files is stopped.
[0044] The first sum of the written data corresponding to the N target files may mean that the sum of the data written into the N target files is the first sum.
[0045] The specific value of the preset difference is not limited here, for example, the preset difference may be 0.1 or 0.001.
[0046] In an embodiment of the present invention, when the first sum is equal to the first preset value, or the difference between the first sum and the first preset value is less than the preset difference, data writing to N target files is stopped. In this way, the flexibility of the method of stopping data writing to N target files is increased.
[0047] As an optional implementation manner, the obtaining identification information of M target files in the file system includes:
[0048] Obtaining the index node data of L sample files in the file system;
[0049] Add identification information to the index node data, wherein the sample file, the index node data and the identification information correspond one to one;
[0050] The identification information of M target files in the file system is obtained, wherein the L sample files include the M target files, and L is an integer greater than or equal to M.
[0051] The index node data may be referred to as an inode data structure or an inode data structure.
[0052] In the implementation manner of the present invention, by adding identification information to the index node data, the M target files can be classified, managed and retrieved more conveniently.
[0053] It should be noted that, since the name information can include the DIR namespace attribute field, and setting the total data writing capacity of N target files to a first preset value can be called an extended file system project quota mechanism, the technical solution provided in the embodiment of the present invention can be called a solution based on DIR namespace and extended file system quota project directory restrictions.
[0054] That is, this embodiment provides a method of isolating a full directory at a certain level and dividing it into partial directories visible in a specified DIR namespace. The parent directory of the isolated directory remains unchanged, and the files and all corresponding subdirectories in the isolated directory will inherit and follow its parent directory (that is, the isolated directory) and be divided into corresponding DIR namespaces. Figure 2 As shown (i.e. Figure 2 As shown in the schematic diagram B in the figure, the DIR namespace is isolated and divided for the next level directory of dir (including dir1 to dir6), and two DIR ns are isolated, namely DIR ns 1 and DIR ns 2. Entering DIR ns 1, you can see that the dir directory includes dir1, dir2 and dir3 and the corresponding files under the directory. You can also see all the subdirectories and files in the directory of dir1. Similarly, entering DIR ns 2 is similar, which is similar to the method in the related art that all files under the directory can be seen (i.e. Figure 2Compared with the schematic diagram shown in Figure 1, in this embodiment, when a process enters the namespace DIR ns 1, it can only see the files included in DIR ns 1; or when a process enters the namespace DIR ns 2, it can only see the files included in ns 2. That is, through the DIR namespace, the process can only see some files, but not all files (i.e., dir1 to dir6), thereby enhancing the isolation of the target files.
[0055] The above implementation mode is described below with an example of a specific embodiment:
[0056] Step 1: First, expand the inode data structure (i.e., index node data) of the file / directory (i.e., sample file) in the file system (i.e., obtain the file system), and add the DIR namespace ID attribute (i.e., identification information) to identify the DIR namespace to which the corresponding file / directory belongs. This attribute is designed to be enabled by configuring parameters when the file system is mounted (mount) or in the configuration file, and is disabled by default.
[0057] Step 2: After a directory in the file system is opened and the attribute value is set, all subdirectories and files in the directory (including newly created files / directories in the directory) will also inherit the same DIR namespace ID.
[0058] Step 3. In conjunction with the existing restriction function of the file system project, the total write data block limit value can be further set for the directory / file in each DIR namespace space (that is, the N identification information all include the target namespace information) according to different DIRnamespace IDs (that is, the total data write capacity of the N target files is set to the first preset value).
[0059] With the DIR namespace ID and limit value, the file system counts the total data block sizes of all files with the same DIR namespace ID and compares it with the set limit value. When the total size of all files reaches the limit value, the file system does not allow more data to be written (that is, when the first total is equal to the first preset value, stop writing data to N target files).
[0060] In this way, after entering the corresponding DIR namespace on the host side (i.e., the server), the total capacity of the non-full directories under the same level directory is limited by using the extended file system project quota mechanism.
[0061] The specific steps are as follows:
[0062] Step 1: Get the container ID numbers of all Kata security containers (i.e., the corresponding security containers on the server) in the newly created container group (pod);
[0063] Step 2: Use mount to locate and query the unified parent directory path / path / to / fs corresponding to the writable layer directory of the container layer (upperdir) of each secure container according to the container ID of each secure container in the pod.
[0064] Step 3: Create a new DIR namespace (such as DIR namespace n), and add the upperdir writable layer directories corresponding to all containers in the same pod to the newly created DIR namespace n. You can also specify it by adding the parameter -ns in the file system FS_quota command line tool.
[0065] Step 4: Call the interface to enter DIR namespace n, and limit the total capacity of the parent directory of the upperdir writable layer directory corresponding to the secure container in the pod (that is, N target files). The process involves specifying the project name (conventionally project_limit_kata_n). See the following expression (where the parameter -c is the instruction added later, -p specifies the project name, and block specifies the capacity limit size):
[0066] FS_quota-c-ns=n"limit-p block=xG project_limit_kata_n" / path / to / fs
[0067] As an optional implementation, it also includes:
[0068] Determine H first users in the second secure container, and determine H virtual shadow users corresponding to the H first users in the PodSandbox OS, where the virtual shadow users correspond to the first users one-to-one, and H is a positive integer;
[0069] Obtaining a second sum of written data of the H virtual shadow users;
[0070] When the second total is equal to a preset write threshold of the second secure container, stop the H first users from writing data in the second secure container.
[0071] Since there is a one-to-one correspondence between the first users and the virtual shadow users, the second sum can be obtained by obtaining the sum of the written data of the H first users.
[0072] Among them, PodSandbox OS can be called the operating system of the secure container of the virtual machine.
[0073] The specific types of the H first users are not limited here, and the H first users may include users with root user permissions and ordinary users, and the permissions of the user with root permissions are greater than those of ordinary users.
[0074] In an embodiment of the present invention, by counting the second sum of the written data of H virtual shadow users, it is determined whether it is necessary to stop the writing of data by H first users in the second security container. In this way, it is possible to determine whether it is necessary to stop the writing of data by H first users in the second security container, thereby enhancing the convenience of determination.
[0075] It should be noted that, in the implementation manner of the present invention, the virtual shadow user can be customized and modified with reference to the ordinary user, so as to abstract and virtualize a non-physical user. The virtual shadow user cannot be directly used as an ordinary user, so the virtual shadow user is designed to not have all the functions of a normal user (i.e., an ordinary user) under the operating system (usually a Linux system), but only to retain and utilize the characteristic that it can be subject to the grquota's write data amount constraint for the first user in each virtual user group.
[0076] As an optional implementation manner, determining H virtual shadow users corresponding to the H first users in the PodSandbox OS includes:
[0077] Creating a virtual shadow user corresponding to each of the H first users in the PodSandbox OS;
[0078] Divide the H virtual shadow users into a virtual user group.
[0079] In the implementation manner of the present invention, a virtual shadow user corresponding to each first user is created, and H virtual shadow users are divided into a virtual user group. In this way, the function of limiting the total amount of disk quota can be implemented through the virtual user group.
[0080] It should be noted that the above implementation can be referred to as an extended user mapping restriction solution based on file system disk quota (grpquota).
[0081] For details, please refer to the following description:
[0082] When a tenant's secure container pod is created on the server, it includes n containers, and a total of m users (i.e. H first users) (including root and ordinary users) are created in all containers, all of which fall on a host node. Customize the secure container image, enable the file system disk quota (grquota) feature on the secure container pod side / client virtual machine operating system (Guest OS) (such as a Kata Pod Sandbox, which is essentially a virtual machine) (the total disk quota can be limited for all users in a user group group), create a user group group_i (i.e. virtual user group) in the Guest OS (i.e. virtual machine), and create virtual shadow users VirUser_1~VirUser_n (i.e. H virtual shadow users), see for details. Figure 3 and Figure 4 The virtual shadow user is designed here with reference to the ordinary user for customization and modification. A non-physical user is abstracted and virtualized. It cannot be directly used as an ordinary user, but can be mapped one-to-one with the user in the container (that is, the virtual shadow user corresponds one-to-one with the first user); the file system grpquota is extended to be compatible with the virtual shadow user. The quota attribute value of the virtual shadow user counts the total amount of data written to the disk and can be subject to the capacity limit of the grquota feature of the Guest file system.
[0083] The specific application steps are as follows:
[0084] Step 1: Map each user (i.e., the first user) in each container (i.e., the second secure container) in the secure container Pod to the virtual shadow user in the group_i user group (virtual user group) in the Guest OS (i.e., the virtual machine). Use the user namespace to isolate users in each container in the secure container pod / virtual machine Guest OS. The uid number of each user in the container starts at 0 and is mapped one-to-one to a uid ordinary user number of the virtual shadow user in the Guest OS.
[0085] Step 2: Since the users in the container and the virtual shadow users on the GuestOS side are isolated and mapped one-to-one through the user namespace (Usernamespace); in the secure container scenario, all containers in the Guest pod and the Guest OS will share the same virtual machine kernel, so they will share a set of uid / gid systems. From the perspective of the GuestOS side, the user in the container is actually a virtual shadow user in the GuestOS. In this way, when the user in each container writes data to the container rootfs, the GuestOS side file system can count the total amount of data written to the rootfs by users in all containers in the Pod in real time by counting the quota value of the virtual shadow users mapped one by one (that is, the second sum of the written data of H virtual shadow users).
[0086] Step 3: When the file system counts the quota attribute value / the accumulated total amount of written data of all virtual users in the group_i user group and reaches the total limit value y G capacity set in the pod (that is, when the second sum is equal to the preset write threshold of the second secure container), the Guest OS side file system grpquota disk quota restriction mechanism will be actually triggered, thereby restricting all users in the Kata container to continue writing data in the rootfs file system, and ultimately achieving the purpose of limiting the capacity of the rootfs writable layer of all secure containers in the Pod (that is, stopping the data writing of H first users in the second secure container).
[0087] As an optional implementation manner, the correspondence between the virtual shadow user and the first user is stored in a mapping record table, and the method further includes:
[0088] In the event that a fault occurs in the second secure container, obtaining the mapping record table and the preset write threshold;
[0089] The mapping record table and the preset write threshold are transmitted to a third security container so that the third security container constructs the H first users and the virtual user group, and the write threshold of the third security container is set to the preset write threshold.
[0090] In an implementation manner of the present invention, when a fault occurs in the second security container, the mapping record table and the preset write threshold can be transmitted to the third security container, the construction of H first users and corresponding virtual user groups can be completed in the third security container, and the write threshold of the third security container can be set to the preset write threshold. In this way, the migration of the mapping record table and the preset write threshold from the second security container to the third security container can be completed, ensuring the normal implementation of the limiting function of writing data of the H first users when a fault occurs in the second security container.
[0091] It should be noted that the implementation mode of the present invention can be understood as providing a capacity-limited migration solution after pod cross-node reconstruction, which meets the common scenario of K8S performing cross-node fault migration at the pod granularity and improves system stability.
[0092] The present embodiment is described below with a specific embodiment:
[0093] When the pod encounters a problem (i.e., the second safety container fails) and K8S needs to be re-started across nodes, K8S first reads the user mapping quota record table (i.e., the mapping record table) through the kata-agent in the pod of the problem node (node) (a process that runs in the guest as a super administrator to manage containers and processes in the container) and synchronizes it to the K8S master node (master) for storage, and then destroys the pod on the corresponding node. You can choose to send the quota record table based on user mapping to the corresponding node node pod (i.e., the third safety container) on other nodes. Based on the key information in the table, you can quickly create a Guest OS side user group (group) and a virtual user VirUser in the Pod (i.e., build H first users and virtual user groups) through kata-agent (if there is a conflict between the group name, gid, and the virtual user uid in the Guest OS, take another value), and establish a mapping relationship between VirUser and users in the Kata container. Reset the quota_value value of each user in the newly created Kata container to 0. It can cooperate with K8S to rebuild and pull up a new pod on other nodes, and quickly complete the migration of the original pod total rootfs capacity limitation solution.
[0094] As an optional implementation manner, when it is determined that N identification information among the M identification information all include target namespace information, setting the sum of data write capacities of N target files corresponding to the N identification information to a first preset value includes:
[0095] Receive target scene information;
[0096] When it is determined that the target scene information is the first scene information and it is determined that the N identification information all include target namespace information, the sum of the data write capacities of the N target files corresponding to the N identification information is set to a first preset value.
[0097] Among them, the target scene information may be scene information input by the user, which may be specifically input through an external electronic device, and the first scene information may refer to a scenario in which there are multiple safety containers and the total capacity of the multiple safety containers needs to be limited.
[0098] That is, the first scenario information is a scenario in which no fixed capacity limit is imposed on a single security container among multiple security containers.
[0099] In an implementation manner of the present invention, when it is determined that the target scene information is the first scene information, the total data write capacity of the N target files corresponding to the N identification information is set to the first preset value. In this way, the accuracy of setting the total data write capacity of the N target files to the first preset value is improved, and the occurrence of erroneous settings is reduced.
[0100] As an optional implementation, the method further includes:
[0101] When it is determined that the target scene information is the second scene information and it is determined that the N identification information all include target namespace information, the data writing capacity of each target file corresponding to the N identification information is set to a second preset value.
[0102] The second scenario information may refer to a scenario in which a fixed capacity limit is imposed on each container.
[0103] In an embodiment of the present invention, when it is determined that the target scene information is the second scene information, the data writing capacity of each target file corresponding to the N identification information is set to the second preset value, which can improve the accuracy of setting the data writing capacity of each target file to the second preset value and also reduce the occurrence of erroneous settings.
[0104] The present embodiment is described below with an example of a specific embodiment:
[0105] Step 1: Get the containerd ID number of one or more containers (i.e., the first security container) corresponding to the newly created pod.
[0106] Step 2: Through mount, you can locate and query the upperdir writable layer directory of the corresponding container (conventionally / path / to / RW_layer_dir) according to the containerd ID of each container.
[0107] Step 3: Use the file system (such as XFS) quota project to create a project for the upperdir writable layer directory of each secure container, which involves setting different project identification numbers (that can be set to n), specifying the project name (can be set to project_limit_kata_m), and initializing the project name.
[0108] Step 4: Configure the limit according to the agreed limit size value (that is, set the data writing capacity of each target file to the second preset value). Design the file system quota command line tool FS_quota and the corresponding parameters as follows (where the parameter -c is the command to be added later, -p specifies the project name, and block specifies the capacity limit size):
[0109] FS_quota-c"limit-p block=xG project_limit_kata_m" / path / to / RW_layer_dir.
[0110] See also Figure 5 , Figure 2 1 is a structural diagram of a safety container capacity setting device provided by an embodiment of the present invention. Figure 5 As shown, the safety container capacity setting device 500 includes:
[0111] A first acquisition module 501 is used to acquire identification information of M target files in a file system, where the target files correspond to the identification information one by one, and the M target files are files corresponding to the first security container;
[0112] A setting module 502 is used to set the sum of data writing capacities of N target files corresponding to the N identification information to a first preset value when it is determined that N identification information among the M identification information all include target namespace information;
[0113] Wherein, M and N are both positive integers, and N is less than or equal to M.
[0114] As an optional implementation, it also includes:
[0115] A second acquisition module is used to acquire a first sum of written data corresponding to the N target files;
[0116] The first stop writing module is used to stop writing data to the N target files when the first sum is equal to the first preset value or the difference between the first sum and the first preset value is less than a preset difference.
[0117] As an optional implementation, the first acquisition module 501 includes:
[0118] A first acquisition submodule is used to acquire index node data of L sample files in the file system;
[0119] An adding submodule, used for adding identification information to the index node data, wherein the sample file, the index node data and the identification information correspond one to one;
[0120] The second acquisition submodule is used to acquire identification information of M target files in the file system, where the L sample files include the M target files, and L is an integer greater than or equal to M.
[0121] As an optional implementation, it also includes:
[0122] A first determination module is used to determine H first users in the second secure container, and determine H virtual shadow users corresponding to the H first users in the PodSandbox OS, where the virtual shadow users correspond to the first users one-to-one, and H is a positive integer;
[0123] A third acquisition module, configured to acquire a second sum of written data of the H virtual shadow users;
[0124] The second stop writing module is used to stop the H first users from writing data in the second security container when the second sum is equal to a preset writing threshold of the second security container.
[0125] As an optional implementation manner, the first determining module includes:
[0126] A creation submodule, used to create a virtual shadow user corresponding to each of the H first users in the PodSandbox OS;
[0127] The division submodule is used to divide H virtual shadow users into one virtual user group.
[0128] As an optional implementation, it also includes:
[0129] a fourth acquisition module, configured to acquire the mapping record table and the preset write threshold value when a fault occurs in the second secure container;
[0130] A writing module is used to transfer the mapping record table and the preset writing threshold to a third security container, so that the third security container constructs the H first users and the virtual user group, and sets the writing threshold of the third security container to the preset writing threshold.
[0131] As an optional implementation, the setting module 502 includes:
[0132] A receiving submodule, used for receiving target scene information;
[0133] The first setting submodule is used to set the total data writing capacity of N target files corresponding to the N identification information to a first preset value when it is determined that the target scene information is the first scene information and it is determined that the N identification information all include target namespace information.
[0134] As an optional implementation, it also includes:
[0135] The second setting submodule is used to set the data writing capacity of each target file corresponding to the N identification information to a second preset value when it is determined that the target scene information is the second scene information and it is determined that the N identification information all include target namespace information.
[0136] The safety container capacity setting device 500 can realize the embodiment of the present invention. Figure 1 The various processes of the method embodiment and the same beneficial effects are achieved, and will not be described again here to avoid repetition.
[0137] The embodiment of the present invention also provides an electronic device. Figure 6 , the electronic device may include a processor 601, a memory 602, and a program 6021 stored in the memory 602 and executable on the processor 601. When the program 6021 is executed by the processor 601, Figure 1 Any steps in the corresponding method embodiments and achieving the same beneficial effects will not be repeated here.
[0138] A person skilled in the art can understand that all or part of the steps of implementing the above-mentioned embodiment method can be completed by hardware related to program instructions, and the program can be stored in a readable medium. The embodiment of the present invention also provides a readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned Figure 1 Any steps in the corresponding method embodiments can achieve the same technical effect and will not be repeated here to avoid repetition.
[0139] The storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0140] The embodiment of the present invention also provides a computer program product, including computer instructions, which can achieve the above-mentioned Figure 1 Any steps in the corresponding method embodiments can achieve the same technical effect, and will not be repeated here to avoid repetition.
[0141] The above is a preferred implementation of the embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for setting the capacity of a safety container, characterized in that: include: Obtain identification information of M target files in the file system, the target files corresponding to the identification information one-to-one, and the M target files are files corresponding to the first security container; When it is determined that N pieces of identification information among the M pieces of identification information all include target namespace information, setting a sum of data write capacities of N target files corresponding to the N pieces of identification information to a first preset value; Wherein, M and N are both positive integers, and N is less than or equal to M.
2. The method according to claim 1, characterized in that After setting the sum of the data writing capacities of the N target files corresponding to the N identification information to a first preset value, the method further includes: Obtaining a first sum of written data corresponding to the N target files; When the first sum is equal to the first preset value, or the difference between the first sum and the first preset value is less than a preset difference, writing data to the N target files is stopped.
3. The method according to claim 1, characterized in that The obtaining identification information of M target files in the file system includes: Obtaining the index node data of L sample files in the file system; Adding identification information to the index node data, wherein the sample file, the index node data and the identification information correspond one to one; The identification information of M target files in the file system is obtained, wherein the L sample files include the M target files, and L is an integer greater than or equal to M.
4. The method according to any one of claims 1 to 3, characterized in that Also includes: Determine H first users in the second secure container, and determine H virtual shadow users corresponding to the H first users in the PodSandbox OS, where the virtual shadow users correspond to the first users one-to-one, and H is a positive integer; Obtaining a second sum of written data of the H virtual shadow users; When the second total is equal to a preset write threshold of the second secure container, stop the H first users from writing data in the second secure container.
5. The method according to claim 4, characterized in that The determining of the H virtual shadow users corresponding to the H first users in the PodSandboxOS includes: Creating a virtual shadow user corresponding to each of the H first users in the PodSandbox OS; Divide the H virtual shadow users into a virtual user group.
6. The method according to claim 5, characterized in that The correspondence between the virtual shadow user and the first user is stored in a mapping record table, and the method further includes: In the event that the second secure container fails, obtaining the mapping record table and the preset write threshold; The mapping record table and the preset write threshold are transmitted to a third security container so that the third security container constructs the H first users and the virtual user group, and the write threshold of the third security container is set to the preset write threshold.
7. The method according to any one of claims 1 to 3, characterized in that The step of setting the sum of data write capacities of N target files corresponding to the N identification information to a first preset value when it is determined that N identification information among the M identification information all include the target namespace information comprises: Receive target scene information; When it is determined that the target scene information is the first scene information and it is determined that the N identification information all include target namespace information, the sum of the data write capacities of the N target files corresponding to the N identification information is set to a first preset value.
8. The method according to claim 7, characterized in that The method further comprises: When it is determined that the target scene information is the second scene information and it is determined that the N identification information all include target namespace information, the data writing capacity of each target file corresponding to the N identification information is set to a second preset value.
9. A safety container capacity setting device, characterized in that: include: A first acquisition module is used to acquire identification information of M target files in the file system, the target files correspond to the identification information one by one, and the M target files are files corresponding to the first security container; A setting module, configured to set the sum of data write capacities of N target files corresponding to the N identification information to a first preset value when it is determined that N identification information among the M identification information all include target namespace information; Wherein, M and N are both positive integers, and N is less than or equal to M.
10. An electronic device comprising: A transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; wherein the processor is used to read the program in the memory to implement the steps in the method for setting the capacity of a secure container as described in any one of claims 1 to 8.
11. A readable storage medium for storing a program, characterized in that: When the program is executed by a processor, the steps in the method for setting the capacity of a secure container as described in any one of claims 1 to 8 are implemented.
12. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps in the method for setting the capacity of a safety container as described in any one of claims 1 to 8.
