Container process updating method and apparatus, storage medium and electronic device
By acquiring and associating process resources during the runtime of the first container process in Kubernetes, starting the second container process, and migrating business resource access information, the problem of poor business continuity during container process upgrades is solved, and fast and smooth container process updates are achieved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2025-09-04
- Publication Date
- 2026-05-07
AI Technical Summary
When updating container processes in Kubernetes, existing technologies result in poor business upgrade continuity, and business requests cannot be processed during process termination.
During the execution of the first container process, by obtaining update requests and associating process resources with the process resource management directory, the second container process is started using the process management component, and business resource access information is sent to the second container process to achieve a smooth upgrade.
It enables rapid and smooth upgrades of container processes, ensuring uninterrupted service before and after the second container process starts, thus improving the continuity of service upgrades.
Smart Images

Figure CN2025118930_07052026_PF_FP_ABST
Abstract
Description
Methods and apparatus for updating container processes, storage media and electronic devices
[0001] Related applications
[0002] This application claims priority to Chinese patent application filed on October 29, 2024, with application number 202411525762.3, entitled "Method and apparatus for updating container processes, storage medium and electronic device", the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of computers, and more specifically, to a method and apparatus for updating container processes, a storage medium, and an electronic device. Background Technology
[0004] Kubernetes (K8s) is an open-source container orchestration platform that provides powerful, scalable, and flexible container orchestration capabilities. It can automate the deployment, scaling, and management of containerized applications, improve the efficiency of development and operations teams, reduce complexity, and ensure high availability and reliability of applications.
[0005] To ensure the continued availability and security of applications, technicians using Kubernetes need to update applications, fix security vulnerabilities, optimize performance, or introduce new features as required, which necessitates updating the container processes within Kubernetes.
[0006] Currently, the typical approach to updating container processes in Kubernetes is to first terminate the container process to be updated and clear all business resources associated with that process. Then, after acquiring the process resources of the updated container process, the updated container process is started and used to take over the business processes required by the containerized application before the update.
[0007] However, during the update process using the above-mentioned container process update method, the containerized application process of the existing business will terminate. During the process termination, it will be unable to receive new business requests and process the business corresponding to the business requests, resulting in a technical problem of poor business upgrade continuity.
[0008] There is currently no effective solution to the above problems. Summary of the Invention
[0009] This application provides a method and apparatus for updating container processes, a storage medium, and an electronic device.
[0010] On the one hand, a method for updating a container process, executed by an electronic device, includes:
[0011] While the first container process is running, an update request for updating the first container process is obtained, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the first process resources are used to update the first container process.
[0012] In response to the update request, the first process resource obtained based on the resource acquisition data is associated with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component;
[0013] The process management component reads the first process resource from the process resource management directory and starts a second container process based on the first process resource, wherein the second container process is an updated container process of the first container process; and
[0014] The resource access information of the business resources managed by the first container process is sent to the running second container process, so that the second container process can obtain the business resources through the resource access information.
[0015] On the other hand, a container process update device is also provided, including:
[0016] The acquisition unit is configured to acquire an update request for updating the first container process while the first container process is running, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the first process resources are used to update the first container process.
[0017] The association unit is configured to, in response to the update request, associate the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component.
[0018] A startup unit is configured to read the first process resource from the process resource management directory using the process management component, and start a second container process based on the first process resource, wherein the second container process is an updated container process of the first container process; and
[0019] The sending unit is used to send the resource access information of the business resources managed by the first container process to the running second container process, so that the second container process can obtain the business resources through the resource access information.
[0020] Furthermore, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the update method of the container process described above at runtime.
[0021] In another aspect, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the update method for the container process described above.
[0022] In another aspect, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to execute the above-described container process update method through the computer program.
[0023] Details of one or more embodiments of this application are set forth in the following drawings and description. Other features, objects, and advantages of this application will become apparent from the specification, drawings, and claims. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the published drawings without creative effort.
[0025] Figure 1 is a schematic diagram of an application environment for an optional container process update method according to an embodiment of this application;
[0026] Figure 2 is a flowchart of an optional container process update method according to an embodiment of this application;
[0027] Figure 3 is a schematic diagram of an optional container process update method according to an embodiment of this application;
[0028] Figure 4 is a schematic diagram of another optional method for updating a container process according to an embodiment of this application;
[0029] Figure 5 is a flowchart of an optional container process update method according to an embodiment of this application;
[0030] Figure 6 is a schematic diagram of an optional container process update device according to an embodiment of this application;
[0031] Figure 7 is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] According to one aspect of the embodiments of this application, a method for updating a container process is provided. Optionally, as an optional implementation, the above-mentioned container process update can be applied to, but is not limited to, the environment shown in FIG1. As shown in FIG1, the terminal device 102 includes a memory 104 for storing various data generated during the operation of the terminal device 102, a processor 106 for processing and calculating the above-mentioned data, and a display 108. The terminal device 102 can interact with the server 112 via a network 110. The server 112 is connected to a database 114, which is used to store various data. The server 112 can be used to run Node nodes in a cloud-native cluster (Kubernetes, or K8s for short), and the terminal device 102 can be used to run a management platform for managing K8s.
[0035] Furthermore, the specific application process of the above method in the environment shown in Figure 1 is as follows:
[0036] In step S102, the terminal device 102 sends an update request for updating the first container process to the server 112 via network 110.
[0037] The first container process is the process running in a container, which can be called the first container.
[0038] In step S104, in response to the update request, server 112 associates the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component.
[0039] In step S106, server 112 uses the process management component to read the first process resource from the process resource management directory and starts the second container process based on the first process resource. The second container process is a container process that is updated from the first container process.
[0040] The second container process is also a process running within a container, which can be called the second container. The first container and the second container can be the same or different.
[0041] In step S108, server 112 sends the resource access information of the business resources managed by the first container process to the running second container process, so that the second container process can obtain business resources through the resource access information.
[0042] In step S110, server 112 sends a notification message indicating that the container process update was successful to terminal device 102 via network 110.
[0043] In this embodiment, while the first container process is running, an update request for updating the first container process is obtained. The update request carries resource acquisition data, which is used to acquire resources for the first process. These resources are then used to update the first container process. Specifically, if the resource acquisition data contains compressed process resources of the first process, a corresponding decompression algorithm (such as a ZIP decompression algorithm) is used to decompress the compressed process resources to obtain the first process resources. If the resource acquisition data contains the resource storage address of the compressed process resources in a cloud storage server, a request message carrying that resource storage address is sent to the cloud storage server. The cloud storage server acquires the compressed process resources based on that address and sends it to the container runtime server used to run the first container process. Upon receiving the compressed process resources, the container runtime server uses a corresponding decompression algorithm to decompress them to obtain the first process resources, which are then used to update the first container process.
[0044] Then, in response to the update request, the first process resource obtained based on the resource acquisition data is associated with the process resource management directory, which is associated with the process resources of at least one container process managed by the process management component. If it is determined to be managed, the access address allocated to the first process resource is obtained from the configuration file or data structure of the process resource management directory. The storage path of the first process resource is symbolically linked to this access address using a symbolic link command provided by the operating system (such as the ln -s command in Linux), thereby associating the first process resource with the process resource management directory, which is associated with the process resources of at least one container process managed by the process management component.
[0045] Next, the process management component reads the first process resource from the process resource management directory and starts the second container process based on it. The second container process is an updated version of the first container process. During the reading process, the process management component checks the file integrity and permissions. If a file corruption error is found, the component resends a request to the cloud storage server to obtain the compressed process resource according to the cloud storage server's interface protocol, and then decompresses it again. If an insufficient permissions error occurs, the component generates a privilege escalation request message containing the required permissions and process identifier, and sends it to the system administrator's management terminal. After successful reading, the process management component parses the startup configuration information (such as startup commands and environment variables) from the first process resource and starts the second container process based on it using the operating system's process startup mechanism (such as the `exec` family of functions in Linux). The second container process is an updated version of the first container process.
[0046] Then, the resource access information of the business resources managed by the first container process is sent to the running second container process, so that the second container process can obtain business resources through the resource access information. The second container process creates a process communication helper object. Taking a domain socket as an example, it uses the socket creation function provided by the operating system (such as the socket function in Linux) to create a domain socket. If creation fails, it checks whether the socket file path is occupied by other processes. This can be determined by querying the file system's usage information. If it is occupied, it is replaced with an unoccupied path and recreated. If creation fails due to insufficient system resources, it uses system resource management tools (such as the top and free commands in Linux) to check resource usage, releases some unnecessary processes or resources, and then tries to create it again. Through this process communication helper object, a process communication connection between the first container process and the second container process is established using the socket connection function (such as the connect function). Before sending the resource access information, a hash algorithm (such as SHA-256) is used to encrypt and calculate the resource access information to generate a hash value. The hash value and resource access information are encapsulated in a data structure, which is then encrypted using the SSL / TLS protocol and sent to the second container process via inter-process communication. Upon receiving the data, the second container process first decrypts it using the SSL / TLS protocol, then recalculates the hash value of the resource access information and compares it with the received hash value. If they match, the data is considered complete, and the resource access information can be used to obtain business resources.
[0047] In other words, by adopting the embodiments of this application, the process resources of the second container process are obtained while the first container process is running, and the process resources of the second container process are associated with the management directory corresponding to the process management component (i.e., the process resource management directory mentioned above). The process management component automatically and quickly starts the second container process, and then sends the resource access information used by the first container to obtain business resources to the second container process, so that the second container process can take over the tasks processed by the first container process. In other words, in the above process, the business is processed by the first container process before the second container process starts, and is immediately migrated to the second container process after the second container process starts. This achieves the purpose of quickly and smoothly upgrading the container process, thereby solving the technical problem of poor business upgrade continuity in the process of upgrading container processes in related technologies, and realizing the technical effect of improving the continuity of business upgrades.
[0048] Optionally, in this embodiment, the terminal device can be a terminal device configured with a client, which may include, but is not limited to, at least one of the following: mobile phone (such as Android phone, iOS phone, etc.), laptop computer, tablet computer, PDA, MID (Mobile Internet Devices), PAD, desktop computer, smart TV, etc. The client can be a video client, instant messaging client, browser client, educational client, etc. The network can include, but is not limited to, wired network and wireless network, wherein the wired network includes: local area network, metropolitan area network and wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that enable wireless communication. The server can be a single server, a server cluster composed of multiple servers, or a cloud server. The above is only an example, and no limitation is made in this embodiment.
[0049] Alternatively, as an alternative solution, as shown in Figure 2, the above-mentioned container process update method includes:
[0050] S202, while the first container process is running, an update request for updating the first container process is obtained, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the resources of the first process are used to update the first container process.
[0051] Resource acquisition data refers to the data included in the request to update the first container process. It clearly indicates the way to obtain the first process resources used to update the first container process. Specifically, it can be reflected in the process compressed resources of the first process itself, or the specific storage address of the process compressed resources in the cloud storage server, etc., providing the necessary basis for obtaining the first process resources.
[0052] Optionally, the above-described methods for updating container processes can be applied, but are not limited to, scenarios involving upgrading container processes within Pods managed by Nodes in a cloud-native cluster (Kubernetes, K8s). Specifically, K8s is an open-source container orchestration engine used for automating the deployment, scaling, and management of containerized applications. It helps users simplify the deployment and management of containerized applications, improving their reliability, scalability, and flexibility. K8s provides a flexible way to manage containerized applications, including automated deployment, scaling, monitoring, and achieving high availability and load balancing. A Node in K8s is a physical or virtual machine in the cluster; it is the basic unit of work used to run applications and services. Each Node has its own resources, such as CPU, memory, and storage. A Pod is the smallest deployment unit in K8s; it is a collection of one or more containers that share network and storage and run together on a Node. A Pod can contain one or more containers that share the same network space and IP address and can communicate with each other. A Pod provides a logical host environment, allowing containers to run as if on the same machine.
[0053] Furthermore, in this embodiment, the update request can be, but is not limited to, sent by the cluster management platform to the Node node where the first container process resides. Specifically, the cluster management platform can be, but is not limited to, used for managing Kubernetes. This platform can be, but is not limited to, configured with a management interface. Professional personnel can use the management interface of the cluster management platform to determine the Pod to be upgraded and the container process within that Pod that needs upgrading. Then, by performing an upgrade determination operation on the container process in the management interface, the upgrade of the container process is triggered. Next, the cluster management will send a request message for upgrading the container process to be upgraded (which can represent the update request) to the Node node where the container process resides, so that the Node node, upon receiving the request, performs an update operation on the container process.
[0054] Optionally, in some embodiments, the candidate process compressed resource package used to update the first container process may include, but is not limited to, compressed files such as binary information, script information, configuration information, log information, etc., that the second container process depends on after updating the first container process. In this embodiment, no limitation is made in this regard.
[0055] S204, in response to the update request, associate the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component.
[0056] The first process resources are a collective term for a series of resources specifically used to update the first container process. They cover various dependent elements necessary for the normal operation of the updated second container process, such as binary information (executable code of the program), script information (scripts used for automated operations), configuration information (settings that determine the process running parameters), and log information (information that records the process running status). They are usually obtained by decompressing the corresponding process compressed resources.
[0057] The process resource management directory is a specific directory that plays a crucial role in the container process management system. Its main function is to associate the process resources of each container process managed by the process management component. Using this directory, the process management component can easily and quickly locate and retrieve the required process resources, thereby enabling operations such as starting, monitoring, and managing container processes. This is a vital foundation for ensuring the orderly operation of container processes.
[0058] Process management components are software components with specific process management functions, such as Runsvdir, Supervisord, and Systemd. The core function of these components is to comprehensively manage container processes, including but not limited to starting new container processes, monitoring process running status, and handling various anomalies that occur during process execution (such as file corruption or insufficient permissions), ensuring that container processes can run stably and efficiently.
[0059] Optionally, in some embodiments, the first process resources mentioned above may include, but are not limited to, binary information, script information, configuration information, log information, etc., which the second container process depends on. In this embodiment, no limitation is made in this regard.
[0060] It should be noted that the process management components mentioned above can be, but are not limited to, components used to instruct specific process management functions. For example, the Runsvdir component, which is a component of the Daemontools package primarily used for process management. Daemontools is a collection of small tools for managing and monitoring Unix / Linux system services, written by Ritchie Brennan. The Runsvdir component's function is to start and manage all sv (service) processes in a directory.
[0061] Optionally, in some embodiments, when the process management component is the Runsvdir component, the process resource management directory may be, but is not limited to, the management directory of the Runsvdir component. Runsvdir continuously monitors the process resource management directory, which is associated with process resources managed by the Runsvdir component.
[0062] It should be noted that, in this embodiment, the first process resource can be associated with the directory by directly storing the first process resource in the process resource management directory, or by linking the storage path of the first process resource to the process resource management directory. This embodiment does not impose any limitations on this.
[0063] S206, the process management component reads the first process resource from the process resource management directory and starts the second container process based on the first process resource, wherein the second container process is a container process that is updated from the first container process.
[0064] The second container process is an updated container process that is started while the first container process is running, by acquiring the resources of the first process. Its main task is to take over the business processes handled by the first container process, and to update and optimize its functions based on the first container process to meet the needs of business development, security fixes, or performance improvements, thereby achieving a smooth upgrade of the container process.
[0065] Specifically, the process management component reads the first process resource from the process resource management directory and starts a second container process based on it. The second container process is an updated version of the first container process. If a file corruption error occurs while reading the first process resource, the process management component can attempt to retrieve and decompress the compressed process resource from the cloud storage server. If an insufficient permissions error occurs, the process management component can send a privilege escalation request to the system administrator. If starting the second container process fails, the process management component can determine whether the problem is a configuration issue or a missing dependency issue based on the error log. If it's a configuration issue, the configuration information can be reread; if it's a missing dependency issue, the missing dependency resources can be retrieved from the cloud storage server.
[0066] A cloud storage server is a storage service device based on cloud computing technology, whose main function is to store various resources. In the scenario of this application, when a request message containing a resource storage address is received, it accurately obtains the process compression resource based on that address and sends it to the container runtime server used to run the first container process, providing the necessary resource support for the update of the container process.
[0067] A container runtime server is a server specifically designed to run the first container process, typically the Node node of the Pod containing the first container. It provides the necessary hardware resources and software environment for the first container process to run, ensuring its stable and efficient operation. It serves as the fundamental support platform for container process execution.
[0068] It should be noted that, in some embodiments, after associating the first process resource with the process resource management directory, the process management component can find the first process resource through the process resource management directory, and then start the second container process based on the first process resource.
[0069] S208, the resource access information of the business resources managed by the first container process is sent to the running second container process so that the second container process can obtain business resources through the resource access information.
[0070] Business resources are the resource information sent by the client to complete a specific business task. This information is the core basis for business processing. Specifically, it includes business processing requests (such as user-submitted operation instructions) and business processing parameters (such as the specific data required for business execution). These are the objects and foundations for the container process to perform business processing.
[0071] Resource access information is a set of key information used to acquire business resources, and it contains several important parts. Among them, the link creation trigger event is used to trigger and create a data transmission link between the client and the container process; the link information of the first data transmission link records the relevant parameters of the data transmission channel established between the first container process and the client; and the historical session messages save the session content that has been transmitted between the client and the first container process. Together, these pieces of information provide the necessary support for the second container process to acquire business resources.
[0072] Specifically, before sending resource access information, a hash algorithm (such as SHA-256) can be used to encrypt the data and generate a hash value. This hash value is then sent along with the resource access information. Upon receiving the data, the second container process recalculates the hash value and compares it with the received hash value. If they match, the data is considered intact. Simultaneously, SSL / TLS protocols are used to encrypt the data during transmission to prevent it from being stolen or tampered with.
[0073] Optionally, in some embodiments, the resource access information may include, but is not limited to, a link creation trigger event, link information of the first data transmission link, and historical session messages. The link creation trigger event is used to create a data transmission link between the client and the container process when a link creation request is triggered. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0074] It should be noted that the aforementioned business resources may be used, but are not limited to, to instruct the resource information sent by the client for processing business, such as business processing requests, business processing parameters, etc., and no limitations are imposed on them in this embodiment.
[0075] Optionally, in some embodiments, sending the resource access information of the business resources managed by the first container process to the running second container process may include, but is not limited to, creating a process communication auxiliary object for the second container process, wherein the process communication auxiliary object is used to provide communication services between container processes. If the creation of the process communication auxiliary object fails, such as the domain socket creation failing, it can be checked whether the socket file path is occupied. If it is occupied, the path can be changed and the socket can be recreated. If the creation fails due to insufficient system resources, some system resources can be released and the creation can be attempted again.
[0076] Then, a process communication connection is established between the first container process and the second container process through a process communication helper object. Subsequently, resource access information of the business resources managed by the first container process is sent to the second container process through the process communication connection.
[0077] It should be noted that, in addition to the Runsvdir component, the process management component mentioned above can also use other process management components with similar functions, such as Supervisord, Systemd, etc. This embodiment does not impose any limitations on this. Supervisord is a process control system used to manage and control processes on Unix-like systems. It allows you to easily start, stop, restart, and monitor multiple processes. Systemd is a widely used initialization system and service manager in Linux systems, used to control the start, stop, restart, and monitoring of processes. When the process management component mentioned above uses Supervisord or Systemd, the process resource management directory mentioned above can be the management directory of Supervisord or Systemd.
[0078] Specifically, the process management flow of the Supervisord component can be illustrated by the following steps: S1, Configure Supervisord by configuring global settings in the global configuration file. S2, Write the process configuration file, specifying the process name, command, user, working directory, and other information. S3, Start and stop the process using the supervisorctl command.
[0079] The process management flow of Systemd components can be referenced in the following example: S1, Create a systemd service unit file (.service file). S2, Write the ExecStart and ExecStop directives: The ExecStart directive specifies the command to be executed when starting the service. This is the main command executed when the service starts. The ExecStop directive specifies the command to be executed when stopping the service. This is the main command executed when the service stops. S3, Enable or stop the service. Use the command `systemctl enable <service name>.service` to enable the service so that it starts automatically at system startup. Use the command `systemctl start <service name>.service` to start the service.
[0080] It should be noted that the aforementioned candidate process compressed resource package can also be obtained from the cloud storage area after the Node receives the aforementioned update request, and this embodiment does not impose any limitations on this.
[0081] Optionally, in some embodiments, before obtaining the update request for updating the first container process when the first container process of the first container object is running, the method may further include: determining the process management component as the master container process in the container object cluster where the first container process and the second container process reside.
[0082] Optionally, as an alternative example, taking the Node where the first and second container processes reside as Node-1 and the Pod as Pod1, and assuming the process management component is runsvdir, the update method for the container processes can be illustrated using the following steps, but is not limited to:
[0083] As shown in Figure 3, in Node-1, the first storage path of the second process resource of the first container process in Pod-1 is symbolically linked to the first link path in the process resource management directory managed by runsvdir, and the second storage path of the first process resource of the second container process in Pod-1 is symbolically linked to the second link path in the process resource management directory managed by runsvdir. This allows runsvdir to obtain the second process resource and the first process resource through the process resource management directory, thereby managing the first and second container processes. Specifically, after symbolically linking the first storage path of the second process resource to the process resource management directory managed by runsvdir, runsvdir is used to start the first container process; correspondingly, after symbolically linking the second storage path of the first process resource to the process resource management directory managed by runsvdir, runsvdir is used to start the second container process. Furthermore, still as shown in Figure 3, the first and second container processes can establish a communication connection through a communication auxiliary object to achieve the migration of resource access information.
[0084] It should be noted that the above examples are optional examples provided to facilitate the explanation of the above container process update method, and there are no limitations on the specific implementation of the above container process update method.
[0085] In this embodiment, while the first container process is running, an update request for updating the first container process is obtained. The update request carries resource acquisition data, which is used to acquire resources for the first process. These resources are then used to update the first container process. In response to the update request, the first process resources obtained based on the resource acquisition data are associated with a process resource management directory. This directory is associated with process resources of at least one container process managed by a process management component. The process management component reads the first process resources from the process resource management directory and starts a second container process based on these resources. This second container process is an updated version of the first container process. Resource access information for the business resources managed by the first container process is sent to the running second container process, enabling the second container process to acquire business resources through the resource access information. In other words, by adopting the embodiments of this application, the process resources of the second container process are obtained while the first container process is running, and the process resources of the second container process are associated with the management directory corresponding to the process management component (i.e., the process resource management directory mentioned above). The process management component automatically and quickly starts the second container process, and then sends the resource access information used by the first container to obtain business resources to the second container process, so that the second container process can take over the tasks processed by the first container process. In other words, in the above process, the business is processed by the first container process before the second container process starts, and is immediately migrated to the second container process after the second container process starts. This achieves the purpose of quickly and smoothly upgrading the container process, thereby solving the technical problem of poor business upgrade continuity in the process of upgrading container processes in related technologies, and realizing the technical effect of improving the continuity of business upgrades.
[0086] Optionally, as an alternative approach, sending resource access information of the business resources managed by the first container process to the running second container process includes:
[0087] S1, create a process communication auxiliary object for the second container process, whereby the process communication auxiliary object is used to provide communication services between container processes.
[0088] S2, create a process communication connection between the first container process and the second container process through a process communication helper object.
[0089] S3 sends the resource access information of the business resources managed by the first container process to the running second container process through the process communication connection.
[0090] Optionally, in some embodiments, the inter-process communication auxiliary object is a domain socket, which is a socket used for inter-process communication under the same operating system kernel. An inter-process communication auxiliary object is an object specifically designed to provide communication services between container processes. Its purpose is to build a data transmission bridge between container processes, ensuring effective information exchange between them. A common example is the Unix Domain Socket (UDS), which allows different processes under the same operating system kernel to communicate efficiently and reliably, and is an important tool for implementing inter-process communication in containers.
[0091] It should be noted that, in some embodiments, the process communication connection between the first container process and the second container process may be used, but is not limited to, to indicate the Socket connection created between the first container process and the second container process through the shared socket file after the second container process starts UDS. This embodiment does not limit this.
[0092] Optionally, in some embodiments, the resource access information may include, but is not limited to, a link creation trigger event, link information of the first data transmission link, and historical session messages. The link creation trigger event is used to create a data transmission link between the client and the container process when a link creation request is triggered. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0093] A link creation trigger event is a specific event that, when triggered, initiates the creation of a data transmission link between the client and the container process. For example, `listen-fd` serves as a specific link creation trigger event. The container process can use it to capture data transmission link creation requests sent by the client, thereby establishing a valid communication link between the client and the container process, enabling data transmission and interaction.
[0094] Furthermore, sending the resource access information of the business resources managed by the first container process to the second container process via inter-process communication (IPC) may include, but is not limited to, sending the link creation trigger event included in the resource access information to the second container process via IPC. This link creation trigger event is used to create a data transmission link between the client and the container process when a link creation request is triggered. If the second container process determines that a link creation request has been triggered based on the link creation trigger event, it creates a second data transmission link between the client and the second container process. If creating the second data transmission link fails, such as when conn-fd creation fails, the second container process can check if the client connection request is valid; if invalid, it can refuse the connection. If creation fails due to network congestion, it can wait for a period of time and then retry creation, while simultaneously sending a network optimization request to the network administrator.
[0095] The second data transmission link is a new data transmission channel established between the client and the second container process when the second container process determines that a link creation request has been triggered based on the received link creation trigger event. For example, the conn-fd created between the client and the second container process provides a new way for data transmission between the client and the second container process, enabling the second container process to communicate smoothly with the client and thus take over the business processing work of the first container process.
[0096] The link information of the first data transmission link and historical session messages included in the resource access information are sent to the second container process through the process communication connection. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0097] In this embodiment, a process communication auxiliary object is created for the second container process. This auxiliary object provides communication services between container processes. Then, a process communication connection is established between the first and second container processes through the auxiliary object. Subsequently, resource access information of the business resources managed by the first container process is sent to the running second container process via the process communication connection. By using this embodiment, the method of transmitting resource access information from the old container process to the new container process allows the new container process to quickly obtain the access information of the business resources. This enables the new process to quickly take over the services corresponding to the business resources, ensuring business continuity and preventing service interruptions and data loss.
[0098] Optionally, as an alternative approach, sending resource access information of the business resources managed by the first container process to the running second container process via a process communication connection includes:
[0099] S1 sends the link creation trigger event included in the resource access information to the running second container process through the process communication connection. The link creation trigger event is used to create a data transmission link between the client and the container process when the link creation request is triggered.
[0100] S2, if the second container process determines that a link creation request has been triggered based on the link creation trigger event, a second data transmission link is created between the client and the second container process.
[0101] It should be noted that, in some embodiments, the aforementioned link creation triggering event may, but is not limited to, be used to indicate listen-fd, where listen-fd is a descriptor used to obtain the data transmission link creation request sent by the client. For example, the container process can obtain the data transmission link creation request sent by the client through listen-fd, and then create a data transmission link between the client and the container process, thereby enabling the client and the container process to communicate through the created data transmission link.
[0102] Optionally, in some embodiments, the aforementioned second data transmission link may, but is not limited to, being used to indicate the conn-fd created between the client and the second container process. When a client connects to the second container process via a link creation trigger event, the second container process can accept the connection and create a new socket for that connection. This new socket has a unique file descriptor, namely conn-fd. The second container process can then use this file descriptor to read data sent by the client or write data to the client.
[0103] In this embodiment, a link creation trigger event included in the resource access information is sent to a running second container process via a process communication connection. This link creation trigger event is used to create a data transmission link between the client and the container process when a link creation request is triggered. Then, when the second container process determines that a link creation request has been triggered based on the link creation trigger event, a second data transmission link is created between the client and the second container process. In other words, by using this embodiment to send the link creation trigger event of the first container process to the second container process via a communication connection, the second container process can establish a communication link with a new client based on the link creation trigger event. It can then use this communication link to obtain the service resources sent by the client and process the service corresponding to those resources. This achieves rapid takeover of the service corresponding to the service resources, ensuring service continuity and avoiding service interruptions and data loss.
[0104] Optionally, as an alternative approach, sending the resource access information of the business resources managed by the first container process to the running second container process via inter-process communication connection further includes:
[0105] The link information of the first data transmission link and historical session messages included in the resource access information are sent to the second container process through the process communication connection. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0106] Optionally, in some embodiments, the aforementioned first data transmission link may be used, but is not limited to, to indicate the conn-fd created between the first container process and the client before the update, and the aforementioned historical session message may be used, but is not limited to, to indicate historical communication messages between the client and the first container process. It should be noted that after the second container process receives the link information of the first data transmission link, it will reconstruct the session object to achieve the migration of the first data transmission link.
[0107] In this embodiment of the application, the link information of the first data transmission link and the historical session messages included in the resource access information are sent to the running second container process through the process communication connection. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0108] In a specific example, the link information of the first data transmission link (such as the conn-fd of the first container process) and historical session messages, included in the resource access information, are sent to the running second container process via inter-process communication (IPC) connection. Upon receiving this information, the second container process first parses the link information to obtain the key parameters of the first data transmission link (such as IP address, port number, file descriptor, etc.). Based on these parameters, a new session object is created using a network programming library (such as Python's socket library). The session state, data cache, and other information from the historical session messages are copied into the new session object. Simultaneously, the connection mapping between the client and the container processes is updated, changing the connection information that originally pointed to the first container process to point to the second container process, thereby migrating the first data transmission link.
[0109] In other words, by using the embodiments of this application, the link information and historical session messages of the first data transmission link already established between the first container process and the client are sent to the second container process through a communication connection. This allows the second container process to migrate the link established between the first container process and the client to the second container process, thereby ensuring that the second container process can smoothly process services. This avoids the service interruption problem that exists in the container process update method provided by related technologies during the container process update process, and achieves the technical effect of improving the continuity of business upgrades.
[0110] Optionally, as an optional solution, after sending the resource access information of the business resources managed by the first container process to the running second container process via inter-process communication connection, the method further includes:
[0111] Create a trigger event for the first container process to terminate the link, and adjust the first data transmission link to the terminated communication state.
[0112] In this embodiment, a trigger event is created for the termination link of the first container process, and the first data transmission link is adjusted to a terminated communication state. In other words, by adopting this embodiment, after the resource access information has been sent to the second container process, the system resources occupied by the first container process are released by decoupling the first container process from the business resources, thereby achieving the technical effect of saving system resources.
[0113] Optionally, as an alternative approach, associating the first process resources obtained based on resource acquisition data with the process resource management directory includes:
[0114] S1, obtain the storage path of the first process's resources.
[0115] S2, if it is determined that the first process resource is managed by the process management component, obtain the access address allocated to the first process resource from the process resource management directory.
[0116] S3 associates the storage path with the access address.
[0117] Optionally, in some embodiments, associating the storage path with the access address may include, but is not limited to, linking the storage path to the access address.
[0118] For example, but not limited to, the above steps can be illustrated using the following example: Obtain the storage path of the first process resource in the Node: path 1. Then, if it is determined that the first process resource is managed by the process management component, obtain the access address allocated to the first process resource from the process resource management directory: address 2. Then, use the ln -s command to create a symbolic link to address 2 for the storage path. It should be noted that the steps shown in the above example can be automatically implemented using scripts or code pre-written into the control panel corresponding to the Node.
[0119] It should be noted that the above examples are optional examples provided to facilitate the explanation of the above container process update method, and there are no limitations on the specific implementation of the above container process update method.
[0120] In this embodiment, the storage path of the first process resource is obtained. Then, if it is determined that the first process resource is managed by a process management component, the access address allocated to the first process resource is obtained from the process resource management directory. Next, the storage path is associated with the access address. In other words, by associating the storage path of the first process resource with the access address allocated to the first process resource in the process resource management directory, the first process resource can be quickly read through the process resource management directory, thereby achieving the technical effect of improving the update efficiency of the container process.
[0121] Optionally, as an optional solution, after sending the resource access information of the business resources managed by the first container process to the running second container process so that the second container process can obtain the business resources through the resource access information, the solution further includes:
[0122] S1, if it is determined that the process resource management directory is associated with the second process resource of the first container process, the association between the second process resource and the process resource management directory is terminated.
[0123] S2, if the association between the second process resource and the process resource management directory is successfully removed, the first container process is terminated using the process management component.
[0124] Optionally, in some embodiments, the above-mentioned removal of the association between the second process resource and the process resource management directory may include, but is not limited to, one of the following: removing the second process resource stored in the process resource management directory, or removing the soft link created between the storage path of the second process resource and the process resource management directory. In this embodiment, no limitation is made on this.
[0125] Optionally, as an alternative approach, before obtaining the update request for updating the first container process, the method further includes:
[0126] S1, determine the first container to run the first container process.
[0127] S2 configures the process management component as the master container in the container cluster where the first container resides. The master container is used to manage the various containers in the container cluster.
[0128] The main container is configured as the core container in a container cluster, playing a dominant role in the cluster's management system. Its primary responsibility is to manage all containers within the cluster, running the core business logic or services of the Pod, and providing crucial support for the normal operation of the Pod. Kubernetes comprehensively manages the lifecycle of the main container, including starting, stopping, and restarting it, ensuring its stable operation to guarantee the normal implementation of the Pod's business functions.
[0129] A container cluster is a collection of multiple containers, such as a Pod managed by a Node in Kubernetes. Within this cluster, the containers share the same network space and IP address, enabling them to easily communicate and collaborate to complete specific business tasks. This is an important way to achieve large-scale, distributed application deployment and management.
[0130] The specific configuration method is as follows: In the container cluster management system (such as Kubernetes API Server), by calling the corresponding API interface, add the relevant configuration information of the process management component (such as container image, resource requirements, startup commands, etc.) to the definition of the main container. At the same time, update the container cluster scheduling policy to ensure that the process management component is correctly deployed to the specified node to run as the main container, so as to achieve the management of each container in the container cluster.
[0131] It should be noted that the aforementioned "first container" can be, but is not limited to, a container within a Pod managed by a Node in Kubernetes. A Pod can contain one or more containers that share the same network space and IP address, and they can communicate with each other. Furthermore, the container cluster containing the aforementioned "first container" can, but is not limited to, indicate the Pod containing the first container, and the aforementioned "master container" can, but is not limited to, indicate the master container within the Pod. The master container within a Pod has the following characteristics: 1) The master container is responsible for running the core business logic or service of the Pod and is a critical part of the Pod's definition. Without the master container, the Pod has no actual business functionality. 2) Kubernetes manages the lifecycle of the master container, including starting, stopping, and restarting it. 3) When the master container crashes or exits, Kubernetes will attempt to restart it until the Pod reaches its defined stable state. The resource configuration of a Pod (such as CPU and memory) is usually based on the needs of the master container. Although resources can also be allocated to other containers within a Pod, the master container typically receives the majority of the resources. 4) K8s can monitor the health status of the main container through probes (such as LivenessProbe and ReadinessProbe). Only when the main container passes the health check is the Pod considered "ready".
[0132] In this embodiment, a first container is determined for running the first container process. Then, the process management component is configured as the master container in the container cluster where the first container resides. The master container manages all containers within the container cluster. In other words, by configuring a process management component (such as Runsvdir) as the master container in a container cluster (such as a Pod in a Kubernetes cluster), unified management and control of all containers within the cluster can be achieved. The master container can dynamically monitor and manage the process status within the container, including creation, upgrades, and shutdowns. This provides a foundation for hot upgrades of containerized processes, enhancing the stability and maintainability of the entire container cluster. It avoids situations where other containers are used as master containers, but the processes within those master containers cannot effectively manage the container cluster during updates.
[0133] Optionally, as an alternative approach, after obtaining the update request for updating the first container process, the method further includes:
[0134] If the resource acquisition data includes compressed process resources of the first process, the compressed process resources are decompressed to obtain the first process resources; or
[0135] If the resource acquisition data includes the resource storage address of the compressed process resource of the first process on the cloud storage server, a request message for the compressed process resource is sent to the cloud storage server. Upon receiving the request message, the cloud storage server retrieves the compressed process resource based on the resource storage address carried in the request message and sends it to the container runtime server, which is the server used to run the first container process. Upon receiving the compressed process resource from the cloud storage server, the compressed process resource is decompressed to obtain the first process resource. The request message format can be an HTTP request, and its content includes a request method (such as GET), request headers (containing authentication information, user agent, etc.), and a request body (containing the resource storage address).
[0136] It should be noted that the aforementioned process compression resources may be, but are not limited to, the compression resources used to indicate the resources of the aforementioned first process, and the aforementioned cloud storage server is a cloud server used for storing resources. The aforementioned container runtime server may be, but is not limited to, the Node node used to indicate the Pod where the first container resides, and the aforementioned first container is a container used to run the first container process.
[0137] In this embodiment, when the resource acquisition data includes compressed process resources of the first process resource, the compressed process resource is decompressed to obtain the first process resource. If decompression fails, the compressed file can be checked for corruption. If corrupted, the compressed process resource can be retrieved again from the cloud storage server. If the decompression algorithm is incompatible, other compatible decompression algorithms can be tried.
[0138] Alternatively, if the resource acquisition data includes the resource storage address of the compressed process resource of the first process resource in the cloud storage server, a request message for requesting the compressed process resource is sent to the cloud storage server. Upon receiving the request message, the cloud storage server acquires the compressed process resource based on the resource storage address carried in the request message and sends it to the container runtime server (the server used to run the first container process). Upon receiving the compressed process resource from the cloud storage server, the compressed process resource is decompressed to obtain the first process resource. In other words, this application embodiment provides two methods for acquiring the first process resource: directly acquiring the compressed resource and decompressing it, or acquiring it through the cloud storage server. This allows the system to intelligently select the most suitable resource acquisition path based on the current network conditions and resource availability, improving the flexibility and efficiency of resource acquisition. Directly decompressing local resources is suitable when the resource already exists locally, reducing network transmission overhead; while acquiring it through cloud storage is suitable when the resource is stored remotely, ensuring resource availability and timeliness.
[0139] Alternatively, as an optional example, the above steps can be illustrated by referring to the following example shown in Figure 4:
[0140] Execute step S402 to create a session connection between the first container process 402 and the second container process 404. The session connection may, but is not limited to, be used to represent the process communication connection created for the first container process and the second container process through the process communication auxiliary object.
[0141] Next, step S404 is executed, sending the listen-fd of the first container process 402 to the second container process 404. The listen-fd can be used to represent the link creation trigger event. The link creation trigger event is used to create a data transmission link between the client and the container process when the link creation request is triggered.
[0142] Next, step S406 is executed, in which the second container process 404 sends a prompt message to the first container process 402 indicating that the listen-fd has been received when the listen-fd is received.
[0143] Then, step S408 is executed, and the first container process 402 closes listen-fd.
[0144] Then, step S410 is executed, sending the conn-fd of the first container process 402 and the historical session messages to the second container process 404. The conn-fd is used to represent the first data transmission link. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0145] Next, step S412 is executed, in which the second container process 404 sends a prompt message to the first container process 402 indicating that it has received the conn-fd and historical session messages when it receives the conn-fd and historical session messages.
[0146] Then, step S414 is executed, and the first container process 402 shuts down conn-fd.
[0147] Next, step S416 is executed, where the second container process 404 closes the session connection with the first container process 402.
[0148] It should be noted that the above examples are optional examples provided to facilitate the explanation of the above container process update method, and there are no limitations on the specific implementation of the above container process update method.
[0149] In this embodiment, when it is determined that the process resource management directory is associated with a second process resource of the first container process, the association between the second process resource and the process resource management directory is severed. Then, with the association successfully severed, the first container process is terminated using the process management component. In other words, using this embodiment, after successfully migrating the business to the second container process, by severing the association between the second process resource of the first container process and the process resource management directory, the process management component can quickly terminate the first container process, thereby releasing system resources.
[0150] Optionally, as an alternative example, the above-described container process update method can be explained in its entirety through the following steps shown in Figure 5:
[0151] Step S502: If the first container process of the first container object is running, obtain an update request for updating the first container process.
[0152] Step S504: Based on the container process information carried in the update request, obtain the candidate process compressed resource package for updating the first container process from the cloud storage terminal.
[0153] Specifically, based on the container process information carried in the update request, and according to the pre-configured cloud storage access interface and authentication information, a resource acquisition request containing container process information (such as process identifier, version number, etc.) is sent to the cloud storage terminal. After receiving the request, the cloud storage terminal retrieves and obtains the candidate process compressed resource package for updating the first container process according to the information in the request, and returns it.
[0154] The candidate process compressed resource package is a collection of compressed resources specifically prepared for updating the first container process. It contains compressed files of various key information that the second container process depends on after the first container process is updated. Specifically, this includes compressed binary information, compressed script information, compressed configuration information, and compressed log information. It is an important source of resources for the first process, facilitating resource storage and transmission.
[0155] Step S506: Decompress the process compressed resource package to obtain the first process resource;
[0156] Step S508: Create a symbolic link to the first process resource in the process resource management directory;
[0157] Step S510: Use the process management component to read the first process resource from the process resource management directory, and start the second container process based on the first process resource;
[0158] Step S512: Create a UDS for the second container process, wherein the UDS is used to represent the aforementioned communication auxiliary object;
[0159] Step S514: The first container process creates a Socket connection with the second container process through a shared socket file, wherein the Socket connection is used to represent the process communication connection between the first container process and the second container process.
[0160] Step S516: The first container process sends listen-fd to the second container process via a Socket connection. The listen-fd can be used to represent the link creation trigger event. The link creation trigger event is used to create a data transmission link between the client and the container process when the link creation request is triggered.
[0161] Step S518: The first container process sends conn-fd and historical session messages to the second container process through a Socket connection. Here, conn-fd is used to represent the first data transmission link. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
[0162] Step S520: The first container process closes listen-fd and conn-fd;
[0163] Step S522: Remove the symbolic link between the second process resource and the process resource management directory so that the process management component terminates the first container process.
[0164] The second process resource is a process resource closely associated with the first container process. During the container process update process, when it is determined that the first container process needs to be updated, the association between the second process resource and the process resource management directory will be severed. Then, the first container process will be terminated using the process management component to achieve reasonable resource allocation and smooth upgrade of the container process.
[0165] Using the above example, the business is handled by the first container process before the second container process starts. After the second container process starts, the business is immediately migrated to the second container process for processing, thereby achieving the goal of fast and smooth upgrade of the container process. This solves the technical problem of poor business upgrade continuity in the process of upgrading container processes in related technologies, and achieves the technical effect of improving the continuity of business upgrades.
[0166] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0167] According to another aspect of the embodiments of this application, a container process updating apparatus for implementing the above-described container process updating method is also provided. As shown in FIG6, the apparatus includes:
[0168] The acquisition unit 602 is used to acquire an update request for updating the first container process when the first container process is running. The update request carries resource acquisition data, which is used to acquire resources of the first process and the first process resources are used to update the first container process.
[0169] The association unit 604 is used to associate the first process resource obtained based on the resource acquisition data with the process resource management directory in response to the update request, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component.
[0170] The startup unit 606 is used to read the first process resource from the process resource management directory using the process management component, and start the second container process based on the first process resource, wherein the second container process is a container process that is updated from the first container process.
[0171] The sending unit 608 is used to send the resource access information of the business resources managed by the first container process to the running second container process, so that the second container process can obtain business resources through the resource access information.
[0172] Optionally, in this embodiment, the sending unit includes: a first creation module, used to create a process communication auxiliary object for the second container process, wherein the process communication auxiliary object is used to provide communication services between container processes; a second creation module, used to create a process communication connection between the first container process and the second container process through the process communication auxiliary object; and a sending creation module, used to send the resource access information of the business resources managed by the first container process to the running second container process through the process communication connection.
[0173] Optionally, in this embodiment, the above-mentioned sending creation module is further configured to send the link creation trigger event included in the resource access information to the running second container process through a process communication connection. The link creation trigger event is used to create a data transmission link between the client and the container process when the link creation request is triggered; and to create a second data transmission link between the client and the second container process when the second container process determines that the link creation request has been triggered based on the link creation trigger event.
[0174] In a specific example, the link creation trigger event (such as `listen-fd`) included in the resource access information is sent to the running second container process via inter-process communication (IPC) connection. Upon receiving `listen-fd`, the second container process uses the operating system's network programming interface (such as the `accept` function in Linux) to monitor client connection requests. When a client initiates a connection request via the link creation trigger event, the second container process accepts the connection, creates a new socket using the `socket` function, and the operating system allocates a unique file descriptor (i.e., `conn-fd`) to this socket. This `conn-fd` becomes the second data transmission link. If creating the second data transmission link fails, such as if `conn-fd` creation fails, the second container process checks whether the client's connection request format and parameters meet the requirements; if invalid, the connection is rejected. If creation fails due to network congestion, network monitoring tools (such as `ping` and `traceroute` commands) are used to check the network status, and after waiting for a period of time (such as setting a wait time of 5 seconds), the process retryes creation while simultaneously sending a network optimization request containing network status information to the network administrator.
[0175] Optionally, in this embodiment, the above-mentioned sending creation module is further configured to send the link information of the first data transmission link and the historical session message included in the resource access information to the running second container process through the process communication connection. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that a link creation request has been triggered based on the link creation trigger event. The historical session message is used to indicate the session messages that have been transmitted between the client and the first container process.
[0176] Optionally, in this embodiment, the above-mentioned device further includes: a first termination processing unit, configured to create a trigger event for the termination link of the first container process and adjust the first data transmission link to a terminated communication state.
[0177] Optionally, in this embodiment, the above-mentioned association unit includes: a first acquisition module, used to acquire the storage path of the first process resource; a second acquisition module, used to acquire the access address allocated to the first process resource from the process resource management directory when it is determined that the first process resource is managed by the process management component; and an association module, used to associate the storage path with the access address.
[0178] Optionally, in this embodiment, the above-mentioned device further includes: a second termination processing unit, configured to, when it is determined that the process resource management directory is associated with a second process resource of the first container process, remove the association between the second process resource and the process resource management directory; and, when the association between the second process resource and the process resource management directory is successfully removed, terminate the first container process using the process management component.
[0179] Optionally, in this embodiment, the above-mentioned apparatus further includes: a determining unit, configured to determine a first container for running the first container process; and a configuring unit, configured to configure the process management component as the master container in the container cluster where the first container is located, wherein the master container is used to manage each container in the container cluster.
[0180] Optionally, in this embodiment, the above-mentioned apparatus further includes: a first decompression processing unit, configured to decompress the process compressed resource to obtain the first process resource when the resource acquisition data includes the process compressed resource of the first process resource; and a second decompression processing unit, configured to send a request message for requesting the process compressed resource to a cloud storage server when the resource acquisition data includes the resource storage address of the process compressed resource of the first process resource in a cloud storage server, wherein, upon receiving the request message, the cloud storage server acquires the process compressed resource based on the resource storage address carried in the request message and sends the process compressed resource to a container runtime server, the container runtime server being a server used to run the first container process; and upon receiving the process compressed resource sent by the cloud storage server, decompresses the process compressed resource to obtain the first process resource.
[0181] For specific implementation examples, please refer to the examples shown in the container process update method above. This embodiment will not be repeated here.
[0182] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described container process update method is also provided. This embodiment uses a server as an example to illustrate the electronic device. As shown in FIG7, the electronic device includes a memory 702 and a processor 704. The memory 702 stores a computer program, and the processor 704 is configured to execute the steps of any of the above-described method embodiments through the computer program.
[0183] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0184] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0185] S1, while the first container process is running, obtain an update request for updating the first container process, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the resources of the first process are used to update the first container process.
[0186] S2, in response to the update request, associate the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component;
[0187] S3, use the process management component to read the first process resource from the process resource management directory, and start the second container process based on the first process resource, wherein the second container process is a container process that is updated from the first container process;
[0188] S4. Send the resource access information of the business resources managed by the first container process to the running second container process so that the second container process can obtain business resources through the resource access information.
[0189] Optionally, those skilled in the art will understand that the structure shown in Figure 7 is merely illustrative, and the electronic device may also be a smartphone (such as an Android phone, iOS phone, etc.), tablet computer, PDA, mobile internet device (MID), PAD, and other terminal devices. Figure 7 does not limit the structure of the aforementioned electronic device. For example, the electronic device may also include more or fewer components (such as network interfaces) than shown in Figure 7, or have a different configuration than that shown in Figure 7.
[0190] The memory 702 can be used to store software programs and modules, such as the program instructions / modules corresponding to the container process update method and apparatus in this embodiment. The processor 704 executes various functional applications and data processing by running the software programs and modules stored in the memory 702, thereby implementing the container process update method described above. The memory 702 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 702 may further include memory remotely located relative to the processor 704, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. As an example, as shown in FIG7, the memory 702 may include, but is not limited to, the acquisition unit 602, association unit 604, startup unit 606, and sending unit 608 in the container process update apparatus described above. In addition, it may include, but is not limited to, other module units in the container process update apparatus described above, which will not be described in detail in this example.
[0191] Optionally, the transmission device 706 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 706 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 706 is a radio frequency (RF) module, used for wireless communication with the Internet.
[0192] In addition, the aforementioned electronic device also includes a display 708 and a connection bus 710 for connecting the various module components in the aforementioned electronic device.
[0193] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a point-to-point network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this point-to-point network.
[0194] According to one aspect of this application, a computer program product is provided, comprising a computer program / instructions containing program code for performing the methods described above. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit, it performs various functions provided in the embodiments of this application.
[0195] According to one aspect of this application, another computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the methods in various embodiments of this application.
[0196] According to one aspect of this application, a computer-readable storage medium is provided, wherein a processor of an electronic device reads computer instructions from the computer-readable storage medium, and executes the computer instructions to cause the electronic device to perform the above-described method.
[0197] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0198] S1, while the first container process is running, obtain an update request for updating the first container process, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the resources of the first process are used to update the first container process.
[0199] S2, in response to the update request, associate the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component;
[0200] S3, use the process management component to read the first process resource from the process resource management directory, and start the second container process based on the first process resource, wherein the second container process is a container process that is updated from the first container process;
[0201] S4, the resource access information of the business resources managed by the first container process is sent to the running second container process, so that the second container process can obtain the business resources through the resource access information. Optionally, in this embodiment, the term "module" or "unit" refers to a computer program or part of a computer program with a predetermined function, which works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially by using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0202] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0203] In summary, this application provides a method, apparatus, computer-readable storage medium, computer program product, and electronic device for updating container processes. The method involves obtaining an update request while the first container process is running, the request carrying resource acquisition data for acquiring resources used to update the first container process. The first process resources are associated with a process resource management directory, which in turn associates the process resources of container processes managed by a process management component. This allows the process management component to quickly locate and manage the resources of each container process using a unified index, reducing the time complexity of resource lookup and improving resource management efficiency. The process management component reads the first process resources and starts the updated second container process. Finally, the resource access information of the business resources managed by the first container process is sent to the second container process, enabling it to acquire the business resources. This approach avoids the business interruption caused by terminating the container process to be updated and then starting a new process, as is done in traditional methods. By preparing the resources of the second container process and starting it while the first container process is running, a smooth migration of business processes is achieved, reducing context switching overhead during business processing and improving the overall system throughput.
[0204] Furthermore, when sending resource access information of business resources managed by the first container process to the second container process, a process communication auxiliary object is first created for the second container process to provide communication services. Then, a process communication connection between the first and second container processes is established through this object, and finally, the resource access information is sent through this connection. The process communication auxiliary object provides a stable channel for communication between container processes. The communication mechanism based on this channel reduces the error rate and retransmission count during data transmission, ensuring that resource access information can be transmitted accurately and quickly. In this way, the second container process can quickly obtain business resource access information, take over business in a timely manner, reduce the queuing time for business processing, and improve the real-time performance of business processing.
[0205] Furthermore, the auxiliary object for inter-process communication is the domain socket, which is a socket used for inter-process communication within the same operating system kernel. Domain sockets, based on the efficient scheduling mechanism of the operating system kernel, avoid the multi-layered encapsulation and decapsulation process of the network protocol stack, reducing the overhead of data transmission and improving communication efficiency and reliability. Processes within the same operating system kernel using domain sockets for communication can avoid packet loss and latency issues in network transmission, ensuring the stability of information exchange between container processes and providing a guarantee for continuous business processing.
[0206] Furthermore, the link creation trigger event from the resource access information is sent to the second container process via inter-process communication. When the second container process determines to trigger the link creation request, a second data transmission link is established between the client and the second container process. The link creation trigger event provides a triggering mechanism for establishing a communication link between the client and the container process, allowing the second container process to respond to client requests promptly and quickly establish a communication link. This approach enables the second container process to quickly establish contact with the client, acquire business resources, reduce client request response time, and improve the system's concurrent processing capabilities.
[0207] Furthermore, the link information of the first data transmission link and historical session messages from the resource access information are sent to the second container process via inter-process communication connections. Upon receiving this information, the second container process can accurately understand the communication status and historical interactions between the first container process and the client, thus seamlessly migrating the connection between the first container process and the client. This avoids client connection interruptions and session loss caused by container process updates, reduces the overhead of client re-establishing connections and restoring sessions, ensures the continuity of business processing, and improves system stability and reliability.
[0208] Furthermore, after sending resource access information to the second container process, a termination link creation trigger event is created for the first container process, and the first data transmission link is adjusted to a terminated communication state. The termination link creation trigger event prevents the first container process from continuing to receive new service requests, avoiding ineffective resource allocation. Adjusting the first data transmission link to a terminated communication state releases related system resources, such as network ports and memory, reducing system resource occupancy, improving system resource utilization, and providing more resource support for other service processing.
[0209] Furthermore, when associating the first process resource with the process resource management directory, its storage path is first obtained. After confirming that it is managed by the process management component, the allocated access address is retrieved from the directory, and then the storage path is associated with that address. This association method allows the process management component to quickly locate and read the first process resource through the process resource management directory, reducing the time overhead of resource lookup. Fast resource reading accelerates the startup speed of the second container process, shortens business migration time, reduces business processing latency, and improves the efficiency of container process updates.
[0210] Furthermore, after the second container process acquires business resources through resource access information, if it is determined that the process resource management directory is associated with the second process's resources belonging to the first container process, the association between the second process and the first container process is severed. Upon successful severance, the first container process is terminated using the process management component. Desevering the association allows the process management component to accurately identify that the first container process has completed its business migration and terminate it promptly. Terminating the first container process releases the system resources it occupies, such as CPU, memory, and disk space, optimizing system resource allocation, reducing resource contention, and improving overall system performance and resource utilization.
[0211] Furthermore, before obtaining update requests, the first container running the first container process is identified, and then the process management component is configured as the master container in the container cluster where the first container resides. The master container holds a central position in the container cluster, enabling unified management and control of all containers within the cluster. The process management component, running as the master container, can monitor and manage the process status within containers in real time, including processes such as creation, upgrades, and termination. This unified management approach reduces communication overhead and coordination costs between containers, improves the management efficiency of the container cluster, and enhances the cluster's stability and maintainability.
[0212] Furthermore, after obtaining the update request, if the resource acquisition data includes the compressed process resources of the first process, it is decompressed to obtain the first process resources. Directly decompressing the local compressed process resources avoids the network latency and uncertainty of obtaining resources remotely. The local decompression operation can quickly obtain the first process resources, speeding up the startup preparation work of the second container process, reducing the waiting time during the startup process, improving the efficiency of resource acquisition, and providing a guarantee for the rapid migration of business.
[0213] Furthermore, after obtaining the update request, if the resource acquisition data contains the resource storage address of the compressed process resource of the first process in the cloud storage server, a request message is sent to the cloud storage server to obtain the compressed process resource. Upon receiving the request, the compressed process resource is decompressed to obtain the first process resource. The cloud storage server has high reliability and large-capacity storage capabilities, ensuring secure storage and fast access to the compressed process resource. Obtaining resources through the cloud storage server allows the system to adapt to different resource storage environments, improving the system's flexibility and scalability. Simultaneously, the distributed architecture of the cloud storage server provides efficient resource transfer services, reducing the time overhead of resource acquisition and ensuring that the second container process can start in a timely manner, reducing business processing latency.
[0214] Furthermore, when using the process management component to read the first process resource from the process resource management directory, if a file corruption error occurs, the process management component will resend the request to the cloud storage server to obtain the compressed process resource according to the cloud storage server's interface protocol, and then decompress it again. If an insufficient permissions error occurs, the process management component will generate a privilege escalation request message, containing the required permission information and process identifier, and send it to the system administrator's management terminal. This error handling mechanism enhances the system's fault tolerance, ensuring that the first process resource can still be obtained even in the event of abnormal situations such as file corruption or insufficient permissions, guaranteeing the normal startup of the second container process and improving the system's reliability and stability.
[0215] When creating inter-process communication auxiliary objects (such as domain sockets), if creation fails, the system checks whether the socket file path is occupied by another process. If it is, it replaces the path with an unoccupied one and recreates the object. If creation fails due to insufficient system resources, the system resource management tool is used to check resource usage, and some unnecessary processes or resources are released before attempting creation again. This fault-tolerance mechanism ensures that inter-process communication auxiliary objects can be successfully created, providing a guarantee for communication between container processes, avoiding business interruptions caused by communication object creation failures, and improving system stability and business processing continuity.
[0216] Before sending resource access information, a hash algorithm (such as SHA-256) is used to encrypt the information, generating a hash value. This hash value and the resource access information are then encapsulated in a data structure, which is encrypted using the SSL / TLS protocol. This data structure is then sent to the second container process via inter-process communication. Upon receiving the data, the second container process first decrypts it using SSL / TLS, then recalculates the hash value of the resource access information and compares it with the received hash value. If they match, the data is considered intact. This data encryption and integrity verification mechanism ensures the security and integrity of resource access information during transmission, preventing data theft or tampering and improving system security and data transmission reliability.
[0217] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more electronic devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0218] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0219] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0220] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0221] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0222] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0223] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for updating a container process, executed by an electronic device, comprising: While the first container process is running, an update request for updating the first container process is obtained, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the first process resources are used to update the first container process. In response to the update request, the first process resource obtained based on the resource acquisition data is associated with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component; The process management component reads the first process resource from the process resource management directory and starts a second container process based on the first process resource, wherein the second container process is an updated container process of the first container process; and The resource access information of the business resources managed by the first container process is sent to the running second container process, so that the second container process can obtain the business resources through the resource access information.
2. The method according to claim 1, wherein sending the resource access information of the business resources managed by the first container process to the running second container process comprises: Create a process communication auxiliary object for the second container process, wherein the process communication auxiliary object is used to provide communication services between container processes; A process communication connection between the first container process and the second container process is created through the process communication auxiliary object; The resource access information of the business resources managed by the first container process is sent to the running second container process through the inter-process communication connection.
3. The method according to claim 2, wherein the process communication auxiliary object is a domain socket, and the domain socket is a socket used for inter-process communication under the same operating system kernel.
4. The method according to claim 2 or 3, wherein sending the resource access information of the business resources managed by the first container process to the running second container process via the process communication connection comprises: The link creation trigger event included in the resource access information is sent to the running second container process through the process communication connection. The link creation trigger event is used to create a data transmission link between the client and the container process when a link creation request is triggered. If the second container process determines that the link creation request has been triggered based on the link creation trigger event, a second data transmission link is created between the client and the second container process.
5. The method according to claim 4, wherein sending the resource access information of the business resources managed by the first container process to the running second container process via the process communication connection further includes: The link information of the first data transmission link and historical session messages included in the resource access information are sent to the running second container process through the process communication connection. The first data transmission link is a data transmission link created between the client and the first container process when the first container process determines that the link creation request has been triggered based on the link creation trigger event. The historical session messages are used to indicate the session messages that have been transmitted between the client and the first container process.
6. The method according to claim 5, further comprising, after sending the resource access information of the business resources managed by the first container process to the running second container process through the process communication connection: A trigger event is created to terminate the link for the first container process, and the first data transmission link is adjusted to a terminated communication state.
7. The method according to any one of claims 1 to 6, wherein associating the first process resource obtained based on the resource acquisition data to the process resource management directory comprises: Obtain the storage path of the resources of the first process; If it is determined that the first process resource is managed by the process management component, the access address allocated to the first process resource is obtained from the process resource management directory; Associate the storage path with the access address.
8. The method according to any one of claims 1 to 7, further comprising, after sending the resource access information of the business resources managed by the first container process to the running second container process so that the second container process can obtain the business resources through the resource access information: If it is determined that the process resource management directory is associated with a second process resource of the first container process, the association between the second process resource and the process resource management directory is terminated. If the association between the second process resource and the process resource management directory is successfully severed, the first container process is terminated using the process management component.
9. The method according to any one of claims 1 to 8, further comprising, before obtaining the update request for updating the first container process: Determine a first container for running the first container process; The process management component is configured as the master container in the container cluster where the first container resides, wherein the master container is used to manage each container in the container cluster.
10. The method according to any one of claims 1 to 9, further comprising, after obtaining the update request for updating the first container process: If the resource acquisition data includes the process compressed resource of the first process resource, the process compressed resource is decompressed to obtain the first process resource.
11. The method according to any one of claims 1 to 9, further comprising, after obtaining the update request for updating the first container process: If the resource acquisition data includes the resource storage address of the compressed process resource of the first process resource in the cloud storage server, a request message for requesting the compressed process resource is sent to the cloud storage server. Upon receiving the request message, the cloud storage server acquires the compressed process resource based on the resource storage address carried in the request message and sends the compressed process resource to the container runtime server, which is a server used to run the first container process. Upon receiving the compressed process resource sent by the cloud storage server, the compressed process resource is decompressed to obtain the first process resource.
12. An apparatus for updating a container process, comprising: The acquisition unit is configured to acquire an update request for updating the first container process while the first container process is running, wherein the update request carries resource acquisition data, the resource acquisition data is used to acquire resources of the first process, and the first process resources are used to update the first container process. The association unit is configured to, in response to the update request, associate the first process resource obtained based on the resource acquisition data with the process resource management directory, wherein the process resource management directory is associated with the process resources of at least one container process managed by the process management component. A startup unit is configured to read the first process resource from the process resource management directory using the process management component, and start a second container process based on the first process resource, wherein the second container process is an updated container process of the first container process; and The sending unit is used to send the resource access information of the business resources managed by the first container process to the running second container process, so that the second container process can obtain the business resources through the resource access information.
13. A computer-readable storage medium comprising a stored program, wherein, The program is executed by the processor to perform the method described in any one of claims 1 to 11.
14. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 11.
15. An electronic device comprising a memory and a processor, the memory storing a computer program, the processor being configured to perform the method of any one of claims 1 to 11 via the computer program.