Container state recovery method and system based on queue, medium, equipment and product

By saving container layer data that has been successfully run multiple times in the container layer data storage queue, the state corruption problem in container applications caused by misoperation or failure is solved, and the container failure recovery and error tolerance are achieved, reducing user recovery cost.

CN119473510APending Publication Date: 2025-02-18HOTDIGIT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411674924.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In container applications that are used intermittently for a long time, users' misoperation or abnormal conditions cause container status data to be damaged, resulting in container status failure. Users need to construct container status environment from scratch, which consumes a lot of energy and may not be reproduced.

Method used

By building a container layer data storage queue and selecting the appropriate state data from the successfully running container layer data when the container fails, a new container layer is constructed, thereby rolling back to the normal state, realizing container failure recovery and error-tolerant operation.

Benefits of technology

The fault tolerance capability of container failures and misoperation is realized, and users can quickly restore to their previous normal state, reducing losses caused by failures or misoperation during operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473510A_ABST
    Figure CN119473510A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of container-based cloud computing, and discloses a queue-based container state recovery method and system, a medium, equipment and a product, and the method comprises the following steps: in response to a renewable container fault instruction, establishing a blank directory as a read-write container layer; reading timestamps of all elements in the container layer data storage queue, and selecting one timestamp from the timestamps; for an element corresponding to the selected timestamp, extracting pointer data, searching for container layer packed data according to the pointer data, unpacking the container layer packed data to a read-write container layer, and regenerating container state data of the renewable container when the selected timestamp exits; wherein the container layer packed data is obtained by packing the container layer data containing the container state when the renewable container exits, elements are established when the renewable container exits, and the elements comprise timestamps when the renewable container exits and pointers pointing to the container layer packed data. And the fault-tolerant capability under the conditions of faults, misoperation and the like is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of container-based cloud computing, and in particular to a queue-based container state recovery method, system, medium, device and product. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] The general design concept of containers is stateless. After a running container stops, it can be reloaded from the image it depends on when it is needed again. However, in some container applications that provide long-term intermittent services to users, such as but not limited to providing cloud desktop services and research and development environments to users through containers, the user's operations in the container, such as installing new software packages and modifying system configurations, are the basis for future use by the user. Therefore, a method for implementing regenerable containers has been specially developed: for container services that require long-term intermittent use, when the user exits the container intermittently without using the container, the container layer containing the user's changes to the container is saved during the container destruction process, thereby releasing server resources; when the user needs to resume the use of the container, the container layer data saved at the last exit is used to build the container layer during the process of creating the container based on the dependent image, thereby regenerating all the user's changes to the container.

[0004] Renewable containers are an extension of traditional container technology, which provide intermittent but long-term support for individual users, and can inherit the container status of the last use in each stage of use. This enables containers to construct container service applications for individual users such as desktop clouds, development environments, and research environments.

[0005] However, during the use of the user, there are often some misoperations and other abnormal situations, which damage the state data of the container, making it impossible for the container to run normally when it is rebuilt based on the saved container layer data content. This will cause the personalized container environment that the user has built for a long time to continue to run, and the state environment of the container has to be rebuilt from scratch based on the image, which will cost a lot of energy and may even be impossible to reproduce, causing irreparable losses.

[0006] To this end, for this stateful long-term container application model, on the basis of achieving the reproducibility of containers at each stage of use, solutions should be further designed to deal with problems such as usage failures and misoperations that destroy the sustainable operation of containers. Summary of the invention

[0007] In order to solve the above problems, the present invention provides a queue-based container state recovery method, system, medium, device and product. By constructing a container layer data storage queue and saving the container layer data of the most recent successful runs of a renewable container, after a container failure occurs, a new container layer can be constructed by selecting the container layer data of the previous successful runs, thereby rolling back to a normal state and restoring operation, thereby achieving fault tolerance for failures and misoperations.

[0008] In order to achieve the above object, the present invention adopts the following technical solution: A first aspect of the present invention provides a queue-based container state recovery method, comprising: In response to the reproducible container failure instruction, a blank directory is established as a readable and writable container layer; Read the timestamps of each element in the container layer data storage queue and select a timestamp from them; For the element corresponding to the selected timestamp, extract the pointer data, search for the container layer packaged data according to the pointer data, unpack the container layer packaged data to the readable and writable container layer, and regenerate the container state data of the regenerable container when the selected timestamp is exited; The container layer packaged data is obtained by packaging the container layer data including the container state when the regenerable container exits, and the element is established when the regenerable container exits, and the element includes the timestamp when the regenerable container exits and a pointer to the container layer packaged data.

[0009] Furthermore, it also includes: in response to the regenerable container running instruction again, establishing a blank directory as a readable and writable container layer; reading the tail element of the container layer data storage queue, and finding the container layer packaged data when the regenerable container was last exited according to the pointer data contained in the tail element; unpacking the container layer packaged data when the regenerable container was last exited to the readable and writable container layer, and regenerating the container status data of the regenerable container when it was last exited.

[0010] Furthermore, when the renewable container exits, if the container layer data storage queue is full, the head element in the container layer data storage queue is dequeued, and the container layer packaged data pointed to by the pointer in the head element is deleted, and the created element is queued into the container layer data storage queue as the tail element.

[0011] Furthermore, when the reproducible container exits, the union file system of the reproducible container is unmounted, and the readable and writable container layer is deleted.

[0012] Furthermore, when the reproducible container is run for the first time, an empty persistent container layer data storage queue is established.

[0013] Furthermore, it also includes: using each image layer of the image as a read-only layer, the read-write container layer as a read-write layer, and the joint file system as the file system of the reproducible container, loading the process according to the setting of the reproducible container, and running the reproducible container.

[0014] A second aspect of the present invention provides a queue-based container state recovery system, comprising: A directory creation module, configured to: create a blank directory as a readable and writable container layer in response to a reproducible container failure instruction; A timestamp reading module is configured to: read the timestamp of each element in the container layer data storage queue and select a timestamp therefrom; A container state regeneration module is configured to: extract pointer data for an element corresponding to a selected timestamp, search for container layer packaged data according to the pointer data, unpack the container layer packaged data to the readable and writable container layer, and regenerate container state data of the regenerable container when the selected timestamp is exited; The container layer packaged data is obtained by packaging the container layer data including the container state when the regenerable container exits, and the element is established when the regenerable container exits, and the element includes the timestamp when the regenerable container exits and a pointer to the container layer packaged data.

[0015] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the queue-based container state recovery method as described above.

[0016] A fourth aspect of the present invention provides a computer device, comprising a computer-readable storage medium, a processor, and a computer program stored on the computer-readable storage medium and executable on the processor, wherein when the processor executes the program, the steps in the queue-based container state recovery method described above are implemented.

[0017] A fifth aspect of the present invention provides a computer program product, which is a computer program product containing a computer program. When a processor executes the computer program, the steps in the queue-based container state recovery method as described above are implemented.

[0018] Compared with the prior art, the present invention has the following beneficial effects: The present invention constructs a container layer data storage queue and saves the container layer data of the most recent successful runs of the regenerative container. After a container failure occurs, a new container layer can be constructed by selecting the container layer data of the previous successful runs, so as to roll back to a normal state and resume operation, thereby achieving fault tolerance for failures and erroneous operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings, which constitute a part of the specification of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but do not constitute limitations of the present invention.

[0020] Figure 1 is a flowchart of a queue-based container state recovery method according to Embodiment 1 of the present invention; Figure 2 It is a schematic diagram of the container exiting and re-operating according to the first embodiment of the present invention; Figure 3 is a schematic diagram of the current implementation of a renewable container; Figure 4 It is a structural diagram of a computer device according to a fourth embodiment of the present invention. DETAILED DESCRIPTION

[0021] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0022] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0023] In the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other. The present invention is further described below with reference to the accompanying drawings and embodiments.

[0024] Terminology explanation: mount: The mount command can mount a partition to a folder in Linux (operating system), thereby linking the partition to the directory. Therefore, as long as you access this folder, it is equivalent to accessing the partition.

[0025] umount: Unmount file system command.

[0026] Union File System UnionFS: A file system in which multiple source directories are stacked in a hierarchical manner to provide aggregated content. Except for the top layer of the stacked source directory, which is readable and writable, all other layers are read-only. Specific implementations include but are not limited to AUFS and Overlay2, which are specific implementations of the Union File System.

[0027] AUFS, the full name of Advanced Multi-layered Unification File System, is a file system that implements union mount. It was originally implemented as the UnionFS file system, which can transparently stack different types of file systems together to achieve an efficient layered file system. AUFS allows files and directories of different file systems to coexist in a unified view, and users can operate these united file systems like a single file system.

[0028] Overlay2 is a union file system that can stack multiple directories or file systems together and add a writable layer on top to achieve efficient file access and modification.

[0029] Embodiment 1 The purpose of this first embodiment is to provide a queue-based container status recovery method.

[0030] like Figure 3 As shown in the figure, the current renewable container is created based on the image, and can inherit the container status of the last use in each stage of use. However, the container layer data of the renewable container is persistently stored. During the long-term intermittent use of the renewable container, users will constantly adjust the container configuration, install new software packages, run various programs, etc. It is difficult to avoid misoperation and software failure, which will cause errors in the container layer data and make the container unable to regenerate and run.

[0031] The present embodiment provides a queue-based container state recovery method, which saves the container layer data of the most recent multiple successful runs of a renewable container, so that after a container failure occurs, a new container layer can be constructed by selecting the container layer data of the previous successful runs, so as to roll back to a normal state and resume operation, thereby achieving fault tolerance for failures and misoperations.

[0032] This embodiment provides a queue-based container state recovery method, including the following steps: Step 1: Implement multiple state preservation of renewable containers.

[0033] Step 101: When user A creates a reproducible container called C based on image B for the first time, the following operations are performed: (1) In response to the first run instruction of the reproducible container, a blank directory is created as a readable and writable container layer directory, and an empty persistent container layer data storage queue D is created at the same time. The queue length is n, and the queue elements contain a timestamp and a pointer to the packaged data; (2) Use the image layer directories of image B as read-only layers and the created container layer directory as a read-write layer. Mount these layers as the file system of the reproducible container in the form of a union file system, and load the corresponding processes according to the settings of the reproducible container to realize the first run of the reproducible container. During the operation of the container, because the union file system is used as the container file system, the operations on the container to add, modify, and delete files in the file system are all saved in the container layer, and the data of the container layer containing the container status is obtained.

[0034] Step 102: Figure 2 As shown in the figure, when user A normally exits the reproducible container C created based on image B, the following operations are performed: (1) In response to a renewable container exit instruction, the renewable container stops running and enters a stopped state; (2) Pack and store the data of the container layer as E, and obtain the container layer data pack E; (3) Create an element F for the container layer data storage queue, which contains the current time and a pointer to the container layer data package E; (4) If the container layer data storage queue D is full, the first element of the queue is dequeued and the container layer packaged data pointed to by the pointer in the first element of the queue is deleted; (5) Element F is added to the container-level data storage queue D and becomes the tail element. In this way, the renewable container of the user can store at most the container-level data of the most recent n times of exiting the renewable container. (6) Continue to destroy the container, umount the container's union file system, and delete the container layer directory.

[0035] Step 2: Re-enter the regenerable container, regenerate the container running state, and restore the state when it was last exited.

[0036] Specifically, Figure 2 As shown, when the user runs the reproducible container again, the following operations are performed: (1) In response to the instruction to re-run the reproducible container, a blank directory is created as a readable and writable container layer, the tail element F of the container layer data storage queue D is read, and the container layer packaged data E when the container was last exited is found according to the pointer data contained therein, and the content of E is unpacked into the container layer directory, thereby regenerating the container state data when the container was last exited; (2) Use each image layer of image B as a read-only layer, and the established container layer as a readable and writable layer. Mount it as a union file system as the file system of the container, and load the corresponding process according to the settings of the container to realize the re-running of the regenerable container and regenerate and restore the state when it was last exited.

[0037] Step 3: When a regenerative container fails, the fault-tolerant operation is restored to the previous correct state.

[0038] Specifically, Figure 1 As shown in the figure, when user A uses the renewable container C, the container crashes due to misoperation, failure, etc., and the current container layer data can no longer be regenerated and run, the following operations are performed to roll back the container state to achieve fault-tolerant operation: (1) In response to a reproducible container failure instruction, a blank directory is created as a readable and writable container layer; (2) List the timestamps of each element in the container layer data storage queue D, so as to select and restore the container to a certain state; (3) For the element where the selected recovery timestamp is located, find the container layer packaged data E when the container is exited based on the pointer data it contains, unpack the content of E to a readable and writable container layer directory, and thus regenerate the container state data when the container is exited; (4) Use each image layer of image B as a read-only layer, and the established readable and writable container layer as a readable and writable layer. Mount it as a union file system as the file system of the container, and load the corresponding process according to the settings of the container to realize the re-running of the reproducible container and regenerate and restore the state at the previous exit.

[0039] This embodiment provides a method for saving the state of a container after multiple runs: construct a storage queue for the container layer content containing the container state when a regenerable container exits, the queue length n is greater than 1, and the container layer data when the most recent n regenerable container exits is saved in chronological order, thereby saving the state of the container after multiple successful runs.

[0040] This embodiment provides a method for operating a queue when a renewable container exits: each time a renewable container exits, the current container layer data is inserted into the tail of the storage queue, wherein if the queue element is full when the queue is to be inserted, the earliest container layer data at the head of the queue is removed, and then the current container layer data is inserted into the queue.

[0041] This embodiment provides a method for re-starting the container layer construction of a regenerable container: when re-constructing the regenerable container, the latest container layer data saved when the last regenerable container was exited is read from the tail element of the storage queue, and the container layer of the current container is constructed, thereby restoring the state of the last container.

[0042] This embodiment provides an operation method for achieving fault tolerance by rollback when a regenerable container fails: when an erroneous operation, failure, or other factor occurs in the container during use, causing the container to exit abnormally, when the regenerable container is reconstructed, the containers previously saved in the storage queue are listed, and one is selected from them to construct a container layer using its data, thereby replacing the container layer data containing errors, and rolling back to the correct container state, providing fault tolerance for the regenerable container.

[0043] The present embodiment provides a queue-based container state recovery method, which enables a stateful container to have a certain fault tolerance capability in each regeneration use stage. That is, when a failure or misoperation causes the container to be unsustainable, the container is provided with the ability to roll back to a previous normal working state, thereby reducing or eliminating the loss caused by the operation failure or misoperation.

[0044] The queue-based container state recovery method provided in this embodiment provides a fault-tolerant capability for dealing with failures and misoperations during long-term intermittent use of a renewable container.

[0045] Embodiment 2 The purpose of the second embodiment is to provide a queue-based container status recovery system, including: A directory creation module, configured to: create a blank directory as a readable and writable container layer in response to a reproducible container failure instruction; A timestamp reading module is configured to: read the timestamp of each element in the container layer data storage queue and select a timestamp therefrom; A container state regeneration module is configured to: extract pointer data for an element corresponding to a selected timestamp, search for container layer packaged data according to the pointer data, unpack the container layer packaged data to the readable and writable container layer, and regenerate container state data of the regenerable container when the selected timestamp is exited; The container layer packaged data is obtained by packaging the container layer data including the container state when the regenerable container exits, and the element is established when the regenerable container exits, and the element includes the timestamp when the regenerable container exits and a pointer to the container layer packaged data.

[0046] It should be noted here that each module in this embodiment corresponds to each step in Example 1 one by one, and the specific implementation process is the same, which will not be repeated here.

[0047] Embodiment 3 This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the queue-based container state recovery method described in the first embodiment are implemented.

[0048] Embodiment 4 This embodiment provides a computer device, such as Figure 4 As shown, it includes a computer-readable storage medium 1003, a processor 1001, a communication interface 1002, and a computer program stored on the computer-readable storage medium 1003 and executable on the processor 1001, wherein the processor 1001, the communication interface 1002, and the computer-readable storage medium 1003 may be connected via a bus or other means. The communication interface 1002 is used to receive and send data, and when the processor 1001 executes the program, the steps in the queue-based container state recovery method described in the first embodiment are implemented.

[0049] Embodiment 5 This embodiment provides a computer program product, which is a computer program product containing a computer program. When a processor executes the computer program, the steps in the queue-based container state recovery method described in the above embodiment 1 are implemented.

[0050] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0051] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. A queue-based container state recovery method, characterized in that: include: In response to the reproducible container failure instruction, a blank directory is established as a readable and writable container layer; Read the timestamps of each element in the container layer data storage queue and select a timestamp from them; For the element corresponding to the selected timestamp, extract the pointer data, search for the container layer packaged data according to the pointer data, unpack the container layer packaged data to the readable and writable container layer, and regenerate the container state data of the regenerable container when the selected timestamp is exited; The container layer packaged data is obtained by packaging the container layer data including the container state when the regenerable container exits, and the element is established when the regenerable container exits, and the element includes the timestamp when the regenerable container exits and a pointer to the container layer packaged data.

2. A queue-based container state recovery method as claimed in claim 1, characterized in that: Also includes: In response to the re-running instruction of the regenerable container, a blank directory is established as a readable and writable container layer; the tail element of the container layer data storage queue is read, and according to the pointer data contained in the tail element, the container layer packaged data when the regenerable container was last exited is found; the container layer packaged data when the regenerable container was last exited is unpacked to the readable and writable container layer, and the container state data of the regenerable container when it was last exited is regenerated.

3. A queue-based container state recovery method as claimed in claim 1, characterized in that: When the renewable container exits, if the container layer data storage queue is full, the head element in the container layer data storage queue is dequeued, and the container layer packaged data pointed to by the pointer in the head element is deleted, and the created element is queued into the container layer data storage queue and becomes the tail element.

4. A queue-based container state recovery method as claimed in claim 1, characterized in that: When the reproducible container exits, the reproducible container's union file system is unmounted and the read-write container layer is deleted.

5. A queue-based container state recovery method as claimed in claim 1, characterized in that: When the reproducible container is run for the first time, an empty persistent container-level data storage queue is established.

6. A queue-based container state recovery method as claimed in claim 1, characterized in that: Also includes: Each image layer of the image is used as a read-only layer, the read-write container layer is used as a read-write layer, the joint file system is used as the file system of the reproducible container, the setting loading process of the reproducible container is followed, and the reproducible container is run.

7. A queue-based container state recovery system, characterized in that: include: A directory creation module, configured to: create a blank directory as a readable and writable container layer in response to a reproducible container failure instruction; A timestamp reading module is configured to: read the timestamp of each element in the container layer data storage queue and select a timestamp therefrom; A container state regeneration module is configured to: extract pointer data for an element corresponding to a selected timestamp, search for container layer packaged data according to the pointer data, unpack the container layer packaged data to the readable and writable container layer, and regenerate container state data of the regenerable container when the selected timestamp is exited; The container layer packaged data is obtained by packaging the container layer data including the container state when the regenerable container exits, and the element is established when the regenerable container exits, and the element includes the timestamp when the regenerable container exits and a pointer to the container layer packaged data.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the queue-based container state recovery method as described in any one of claims 1 to 6 are implemented.

9. A computer device comprising a computer-readable storage medium, a processor, and a computer program stored on the computer-readable storage medium and executable on the processor, characterized in that: When the processor executes the program, the steps in the queue-based container state recovery method according to any one of claims 1 to 6 are implemented.

10. A computer program product, which is a computer program product containing a computer program, characterized in that When the processor executes the computer program, the steps in the queue-based container state recovery method according to any one of claims 1 to 6 are implemented.