Application upgrade method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202310357026.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-04
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-04-04
AI Technical Summary
[0005]本申请的主要目的在于提供一种应用的升级方法、装置、存储介质及电子设备,以解决相关技术中应用处理业务时由于应用升级影响业务处理效率的问题
[0014]This application employs the following steps: identifying the application to be upgraded, wherein the application to be upgraded contains multiple nodes, and each node contains multiple containers; obtaining the application type of the application to be upgraded, and determining the node information of the application to be upgraded based on the application type; determining the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade; setting the target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; determining the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes, and upgrading the application to be upgraded according to the upgrade batches, thus solving the problem in related technologies where application upgrades affect the efficiency of business processing when processing business. By upgrading the containers deployed on each node of the application according to the upgrade batches, the minimum number of containers required to maintain the operation of each node is guaranteed to operate normally during the upgrade, thereby achieving the effect of still being able to process business during application upgrades and improving the efficiency of application business processing.
Smart Images

Figure CN116382736B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing, and more specifically, to an application upgrade method, apparatus, storage medium, and electronic device. Background Technology
[0002] With the rapid development of cloud computing technology, some stateful applications have been fully containerized, such as MySQL (Relational Database Management System) and ElasticSearch (distributed full-text search engine). Since stateful applications need to keep the URL and stored content fixed, the container needs to be fixed to run on a host machine.
[0003] In related technologies, to ensure high availability of stateful applications, the number of nodes of various types in a stateful application is often more than one. The size of the application determines the number of nodes. Furthermore, the startup / upgrade order of nodes in a stateful application is strictly required. For example, a MySQL application first creates the master database for upstream applications to read and write, then creates slave databases to establish a synchronous connection with the master. An Elasticsearch application first creates data nodes responsible for data writing, then creates client nodes for task distribution to data nodes, and finally creates the master node for cluster state management. A subsequent node can only start after the previous node has started and is providing normal services; cross-level startup is not supported. Additionally, node upgrades in stateful applications have strict sequential requirements; they can only be performed one node at a time according to a fixed upgrade order. Upgrades require deleting containers from nodes and then creating new containers for the upgrade, which consumes significant time and impacts the application's business processing efficiency.
[0004] There is currently no effective solution to the problem of application upgrades affecting business processing efficiency in related technologies. Summary of the Invention
[0005] The main objective of this application is to provide an application upgrade method, apparatus, storage medium, and electronic device to solve the problem in the related art where application upgrades affect the efficiency of business processing.
[0006] To achieve the above objectives, according to one aspect of this application, an application upgrade method is provided. The method includes: determining an application to be upgraded, wherein the application to be upgraded includes multiple nodes, and each node includes multiple containers; obtaining the application type of the application to be upgraded, and determining the node information of the application to be upgraded based on the application type; determining the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade; setting a target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; determining upgrade batches for all containers based on the target number of containers to be upgraded in each batch for all nodes, and upgrading the application to be upgraded according to the upgrade batches.
[0007] Optionally, determining the minimum number of containers for each type of node in the application to be upgraded based on the node information includes: extracting the various types of nodes included in the application to be upgraded and the number of containers deployed on each type of node from the node information; obtaining the historical container failure ratio for each type of node and calculating the product of the number of containers deployed and the historical container failure ratio; calculating the difference between the number of containers deployed and the product, and setting the minimum number of containers based on the difference, wherein the difference is greater than or equal to the minimum number of containers, and the minimum number of containers is greater than or equal to one.
[0008] Optionally, setting the target number of containers to be upgraded in each batch in a node based on the minimum number of containers in the node includes: setting the target number of containers to be upgraded in each batch in each node, wherein the difference between the number of deployed containers and the target number is greater than or equal to the minimum number of containers.
[0009] Optionally, determining the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes includes: for each node, determining the number of each container deployed in the node, and determining the target number of containers deployed in the node as the first upgrade batch in ascending order of the numbers; determining a preset number of other containers as the Nth upgrade batch in ascending order of the numbers, where N is an integer, N is greater than or equal to one, the preset number is less than or equal to the target number, and the other containers are containers deployed in the node other than the first upgrade batch.
[0010] Optionally, upgrading the application to be upgraded according to the upgrade batch includes: determining the container to be upgraded for each type of node in the same upgrade batch, thus obtaining the container to be upgraded for each upgrade batch; and upgrading the containers to be upgraded batch by batch in ascending order of upgrade batch size.
[0011] Optionally, upgrading containers in batches according to the order of the upgrade batches from smallest to largest includes: determining whether all containers in each upgrade batch have been successfully upgraded; if all containers in the current upgrade batch have been successfully upgraded, executing the upgrade process for the next upgrade batch; if not all containers in the current upgrade batch have been successfully upgraded, reverting all containers in the current upgrade batch to the historical version before the upgrade process.
[0012] Optionally, determining whether all containers in each upgrade batch have been successfully upgraded includes: after the containers in the target upgrade batch have been upgraded, writing test data to each type of node and determining whether the client node of the application to be upgraded has obtained the test data; if the client node has obtained the test data, determining that all containers in the target upgrade batch have been successfully upgraded; if the client node has not obtained the test data, determining that all containers in the target upgrade batch have not been successfully upgraded.
[0013] To achieve the above objectives, according to another aspect of this application, an application upgrade apparatus is provided. The apparatus includes: a first determining unit for determining an application to be upgraded, wherein the application to be upgraded includes multiple nodes, and each node includes multiple containers; an obtaining unit for obtaining the application type of the application to be upgraded and determining node information of the application to be upgraded based on the application type; a second determining unit for determining the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade of the application; a setting unit for setting a target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; and a third determining unit for determining the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes, and performing upgrade processing on the application to be upgraded according to the upgrade batches.
[0014] This application employs the following steps: identifying the application to be upgraded, wherein the application to be upgraded contains multiple nodes, and each node contains multiple containers; obtaining the application type of the application to be upgraded, and determining the node information of the application to be upgraded based on the application type; determining the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade; setting the target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; determining the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes, and upgrading the application to be upgraded according to the upgrade batches, thus solving the problem in related technologies where application upgrades affect the efficiency of business processing when processing business. By upgrading the containers deployed on each node of the application according to the upgrade batches, the minimum number of containers required to maintain the operation of each node is guaranteed to operate normally during the upgrade, thereby achieving the effect of still being able to process business during application upgrades and improving the efficiency of application business processing. Attached Figure Description
[0015] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0016] Figure 1 This is a flowchart of an application upgrade method provided according to an embodiment of this application;
[0017] Figure 2 This is a structural diagram of the orchestration management tool provided according to the embodiments of this application;
[0018] Figure 3 This is a schematic diagram of node information in a distributed full-text search engine provided according to an embodiment of this application;
[0019] Figure 4 This is a schematic diagram of node information in a relational database management system provided according to an embodiment of this application;
[0020] Figure 5 This is a flowchart of an optional application upgrade method provided according to an embodiment of this application;
[0021] Figure 6 This is a schematic diagram of an application upgrade device provided according to an embodiment of this application;
[0022] Figure 7 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0023] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] 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 for the embodiments of this application 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.
[0026] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0027] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of an application upgrade method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0028] Step S101: Determine the application to be upgraded, wherein the application to be upgraded contains multiple nodes, and each node contains multiple containers.
[0029] Specifically, the application to be upgraded can be a stateful application, such as Elasticsearch and MySQL. The application to be upgraded is managed through an orchestration management tool, which can be Kubernetes (K8s, an orchestration management tool for portable containers).
[0030] It should be noted that the application to be upgraded contains various types of nodes, and different types of applications may contain different node types. Upgrading the application requires upgrading the containers on each node of the application using Kubernetes. Each node contains multiple containers. A container is a virtual device that encapsulates all the necessary details for running the application, such as the operating system the application depends on. In this embodiment, the containers can be stateful containers. A stateful container is a container that records historical requests or operations processed when the application is used, which has an impact on current or future operations and needs to record historical data, such as a MySQL container.
[0031] Figure 2 This is a structural diagram of the orchestration management tool provided according to the embodiments of this application, such as... Figure 2 As shown, Kubernetes (K8s) is a portable container orchestration and management tool designed for container services. K8s is deployed in a cluster mode, consisting of a Master node, Node nodes, and Etcd nodes. The Master node, also known as the management node, manages and controls the entire cluster. Node nodes, also known as worker nodes, are assigned some workload (i.e., containers) by the Master node. When a Node node fails, its workload is automatically transferred to other nodes by the Master node. Etcd nodes, also known as storage nodes, are highly available distributed key-value databases used to store metadata for the target management tool.
[0032] Step S102: Obtain the application type of the application to be upgraded, and determine the node information of the application to be upgraded based on the application type.
[0033] Specifically, application types can include Elasticsearch and MySQL. Node information can include node type, the number of containers within the node, and container IDs. The nodes in the application to be upgraded differ depending on the application type. For example, MySQL consists of two types of nodes: master and slave. The master provides read and write operations, while the slave provides read operations. Elasticsearch consists of master nodes, data nodes, and client nodes. The master node manages the cluster node status, data nodes handle data writing and querying, and client nodes handle task distribution and result aggregation, reducing the load on the data nodes. These various nodes in a stateful application collaborate to provide services.
[0034] It should be noted that, Figure 3 This is a schematic diagram of node information in a distributed full-text search engine provided according to an embodiment of this application, such as... Figure 3As shown, a distributed full-text search engine can be ElasticSearch. ElasticSearch consists of three types of nodes: data nodes, which include four containers (data-0 to data-3); client nodes, which include two containers (client-0 to client-1); and master nodes, which include three containers (master-0 to master-2). Figure 4 This is a schematic diagram of node information in a relational database management system provided according to an embodiment of this application, such as... Figure 4 As shown, the relational database management system is MySQL. MySQL consists of two types of nodes: master nodes (4 containers: master-0 to master-3) and slave nodes (6 containers: slave-0 to slave-5). In related technologies, when upgrading Elasticsearch, you can only upgrade the data nodes first. After the four data nodes are upgraded (in the order of data-0 to data-4), the client nodes (in the order of client-0 to client-1) are upgraded. After the two client nodes are upgraded, the master nodes (in the order of master-0 to master-2) are upgraded. Similarly, when upgrading MySQL, you can only upgrade the master nodes first (in the order of master-0 to master-3), and then upgrade the slave nodes (in the order of slave-0 to slave-5).
[0035] Step S103: Determine the minimum number of containers for each type of node in the application to be upgraded based on the node information. The minimum number of containers is the number of containers required for the node to maintain operation during the upgrade of the application.
[0036] Specifically, the minimum number of containers can be the minimum guarantee for each node to maintain normal operation. For example, the minimum number of containers for data nodes, client nodes, and master nodes in Elasticsearch are 2, 1, and 1, respectively. When upgrading Elasticsearch, it is necessary to ensure that data nodes, client nodes, and master nodes retain at least 2, 1, and 1 containers to maintain the normal operation of their respective nodes, so that Elasticsearch can continue to provide services when upgrading.
[0037] Step S104: For each type of node, set the target number of containers to be upgraded in each batch in the node based on the minimum number of containers in the node.
[0038] Specifically, to ensure that each node retains a minimum number of containers to maintain normal operation during the upgrade of the application, it is necessary to set the upgrade order, upgrade batches, and target number of containers to be upgraded in each batch based on the minimum number of containers for each type of node. For example, the upgrade order for MySQL is master node > slave node, and the upgrade order for Elasticsearch is data node > client node > master node. This order is automatically determined, but it can also be forced through configuration files. A MySQL master node contains 4 containers, with a minimum of 2 containers per master node, and a slave node contains 6 containers, with a minimum of 1 container per slave node. Upgrading one container from the master node and two containers from the slave nodes in each batch results in 3 remaining master node containers (greater than the minimum of 2 containers) and 4 remaining slave node containers (greater than the minimum of 1 containers per slave node) after each batch upgrade. This ensures that MySQL can still provide services during the upgrade.
[0039] Step S105: Determine the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes, and perform upgrade processing on the applications to be upgraded according to the upgrade batches.
[0040] Specifically, after determining the target number of containers to be upgraded in each batch across all nodes in the application to be upgraded, the containers to be upgraded in each batch on each node are determined based on the container number and the target number in each node. After determining the upgrade batches for all containers on all nodes, the containers are upgraded batch by batch in ascending order.
[0041] The application upgrade method provided in this application embodiment obtains the application type of the application to be upgraded and determines the node information of the application to be upgraded based on the application type; determines the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade of the application; sets the target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; determines the upgrade batches of all containers based on the target number of containers to be upgraded in each batch of all nodes, and upgrades the application to be upgraded according to the upgrade batches. This solves the problem in related technologies where application upgrades affect the efficiency of business processing when processing business. By upgrading the containers deployed on each node in the application according to the upgrade batches, the minimum number of containers required to maintain the operation of each node is guaranteed to run normally during the upgrade, thereby achieving the effect of still being able to process business during application upgrades and improving the efficiency of application business processing.
[0042] The minimum number of containers is determined based on the number of containers deployed in the node and the historical container failure ratio. Optionally, in the application upgrade method provided in this application embodiment, determining the minimum number of containers for each type of node in the application to be upgraded based on the node information includes: extracting the various types of nodes included in the application to be upgraded and the number of containers deployed on each type of node from the node information; obtaining the historical container failure ratio of each type of node and calculating the product of the number of containers deployed and the historical container failure ratio; calculating the difference between the number of containers deployed and the product, and setting the minimum number of containers based on the difference, wherein the difference is greater than or equal to the minimum number of containers, and the minimum number of containers is greater than or equal to one.
[0043] Specifically, the historical container failure rate can be defined as the ratio of the number of failed containers that simultaneously failed in the historical work records of each node to the total number of containers deployed on that node. For example, if an ElasticSearch data node has 4 deployed containers and the historical container failure rate is 25%, it means that one container may fail during the operation of a data node. Each node needs to maintain operation by retaining at least one container, so the minimum number of containers for a data node can be set to 2 or 3. Setting a minimum number of containers ensures that the node can maintain normal operation during node upgrades.
[0044] The target number of each node to be upgraded in each batch is determined based on the minimum number of containers. Optionally, in the upgrade method of the application provided in this application embodiment, setting the target number of containers to be upgraded in each batch of the node based on the minimum number of containers in the node includes: setting the target number of containers to be upgraded in each batch of each node, wherein the difference between the number of deployed containers and the target number is greater than or equal to the minimum number of containers.
[0045] Specifically, to ensure the application can continue operating normally during the upgrade process, the containers on each node of the application will be upgraded in batches. Each batch can upgrade a target number of containers on a node. When upgrading the target number of containers in each batch, it is necessary to ensure that the number of remaining containers on the node excluding those being upgraded in that batch is greater than or equal to the minimum number of containers. For example, if the ElasticSearch data node has 4 deployed containers and the minimum number of containers on the data node is 2, then the target number can be set to 1 or 2. By setting the target number of containers to be upgraded in each batch, the application can be upgraded in batches.
[0046] After determining the target quantity, upgrade batches for all containers are set according to the target quantity. Optionally, in the upgrade method of the application provided in this application embodiment, determining the upgrade batches for all containers based on the target quantity of each batch of containers to be upgraded for all nodes includes: for each node, determining the number of each container deployed in the node, and determining the target quantity of containers deployed in the node as the first upgrade batch in ascending order of the numbers; determining a preset number of other containers as the Nth upgrade batch in ascending order of the numbers, where N is an integer, N is greater than or equal to one, the preset number is less than or equal to the target quantity, and the other containers are containers deployed in the node other than the first upgrade batch.
[0047] Specifically, the container number can be determined according to the order in which containers are deployed in the node, for example, such as... Figure 4 As shown, the Elasticsearch data nodes contain four containers (data-0 to data-4), with a target of 2 data nodes, 1 client node, and 1 master node. The Elasticsearch cluster serving as the application to be upgraded contains four containers (data-0 to data-4) on the data nodes, two containers (client-0 to client-1) on the client nodes, and three containers (master-0 to master-2) on the master nodes. In the first upgrade batch, the containers to be upgraded on the data nodes are data-0 and data-1, on the client nodes is client-0, and on the master nodes is master-0. In the second upgrade batch, the containers to be upgraded on the data nodes are data-2 and data-3, on the client nodes is client-1, and on the master nodes is master-1. By determining the upgrade batches for all containers in the application to be upgraded, the application can be upgraded in batches, ensuring the business processing efficiency of the application to be upgraded.
[0048] The application to be upgraded is upgraded in ascending order of upgrade batches. Optionally, in the application upgrade method provided in this application embodiment, upgrading the application to be upgraded in ascending order of upgrade batches includes: determining the container to be upgraded for each type of node in the same upgrade batch to obtain the container to be upgraded for each upgrade batch; and upgrading the containers to be upgraded batch by batch in ascending order of upgrade batches.
[0049] For example, the application to be upgraded has three upgrade batches: the first batch, the second batch, and the third batch. The containers to be upgraded are upgraded first, then the containers from the second batch, and finally the containers from the third batch. By upgrading the application batch by batch in ascending order, sufficient capacity for other batches to process business is ensured during each upgrade, thus improving the business processing efficiency of the application to be upgraded.
[0050] When upgrading an application, if a batch of containers fails to upgrade, optionally, in the application upgrade method provided in this application embodiment, upgrading the containers to be upgraded batch by batch in ascending order of upgrade batches includes: determining whether all containers in each upgrade batch have been successfully upgraded; if all containers in the current upgrade batch have been successfully upgraded, executing the upgrade process for the next upgrade batch; if not all containers in the current upgrade batch have been successfully upgraded, reverting all containers in the current upgrade batch to the historical version before the upgrade process.
[0051] Specifically, when upgrading containers in batches, it's necessary to determine whether all containers in each batch have successfully upgraded. If any container in a batch is deemed to have failed, a rollback operation is performed on all containers in that batch, reverting them to their previous versions before the upgrade, ready for the next upgrade. If all containers in a batch are deemed to have successfully upgraded, the upgrade process continues with the next batch. After each batch's upgrade is successful, it's determined whether it was the last batch for the application to be upgraded. If so, the upgrade process proceeds to the next application; otherwise, the next batch continues. By checking the success of each batch, the stability of all container versions within the application to be upgraded is ensured, preventing application malfunctions due to partial container upgrade failures.
[0052] The method for determining whether all containers in the target upgrade batch have been successfully upgraded is achieved by judging whether the client node can obtain the test data written to the node. Optionally, in the application upgrade method provided in this application embodiment, judging whether all containers in each upgrade batch have been successfully upgraded includes: after the containers in the target upgrade batch have undergone upgrade processing, writing test data to each type of node, and judging whether the client node of the application to be upgraded has obtained the test data; if the client node has obtained the test data, it is determined that all containers in the target upgrade batch have been successfully upgraded; if the client node has not obtained the test data, it is determined that all containers in the target upgrade batch have not been successfully upgraded.
[0053] Specifically, after the upgrade process for each batch is completed, test data is written to all nodes of the application to be upgraded. Then, the client node of the application to be upgraded accesses each node to determine whether the test data has been obtained. If the client node obtains the test data, it proves that the upgrade batch has been successfully upgraded. For example, a test log data is stored in the data node of ElasticSearch, and then the client node tries to obtain the data. If the data is successfully obtained, it proves that the data node has been successfully upgraded. If the test log data is not obtained, it means that the data node has failed to upgrade.
[0054] According to another embodiment of this application, an optional application upgrade method is also provided. Figure 5 This is a flowchart of an optional application upgrade method provided according to embodiments of this application. For example... Figure 5 As shown, the method includes:
[0055] Step S501: Define the upgrade order, upgrade ratio, and maximum number of unavailable nodes according to different types of stateful applications.
[0056] For example, the upgrade order for MySQL is master node > slave node, while the upgrade order for Elasticsearch is data node > client node > master node. This order is automatically determined and can also be forced through configuration files. The upgrade ratio refers to the upgrade batches for each type of node; upgrades are performed incrementally according to a set proportion each time. The maximum unavailability is the minimum guarantee for maintaining normal node operation. For example, if the maximum unavailability for Elasticsearch data nodes, client nodes, and master nodes are 2, 1, and 1 respectively, then these nodes must have at least the maximum number of containers that can be unavailable to ensure normal node operation.
[0057] Step S502: Identify the stateful application to be upgraded and obtain node information of various types of nodes in the stateful application.
[0058] Specifically, for example, if the stateful application to be upgraded is MySQL, obtain the number of containers and container numbers contained in various types of nodes in MySQL.
[0059] Step S503: Based on the node information, select the first batch of containers to be upgraded from various types of nodes and upgrade them.
[0060] For example, if an ElasticSearch cluster is an application to be upgraded, with 4 data nodes, 2 client nodes, and 3 master nodes, and the upgrade order is data nodes > client nodes > master nodes, with upgrade ratios of data nodes (25%), client nodes (50%), and master nodes (33%), then the first batch of upgrades would be the containers in 1 data node, the containers in 1 client node, and the containers in 1 master node.
[0061] Step S504: Determine whether all containers to be upgraded in the first batch have been successfully upgraded.
[0062] Specifically, the upgrade process is used to determine whether all containers to be upgraded have been successfully upgraded by accessing each node. If each node is functioning normally, the upgrade is successful. For example, if a test log is stored in the data node of ElasticSearch and then retrieved through the client node, the node upgrade is successful if the retrieval is successful, otherwise the upgrade has failed.
[0063] Step S505: If all containers to be upgraded in the first batch fail to upgrade, then perform a rollback operation.
[0064] Specifically, if a container upgrade fails, all containers in the first batch of upgrades will be rolled back to the previous version and can be used again in the next upgrade.
[0065] Step S506: If all containers to be upgraded in the first batch are successfully upgraded, then continue with the upgrade operation for the next batch.
[0066] Specifically, if all containers to be upgraded in the first batch are successfully upgraded, the next batch of containers to be upgraded will continue to be upgraded.
[0067] Step S507: Determine whether the current batch is the last batch of stateful applications to be upgraded. If the current batch is the last batch, proceed with the upgrade operation for the next stateful application. If the current batch is not the last batch, continue with the upgrade operation for the next batch of the current stateful applications.
[0068] Specifically, after each batch of containers to be upgraded for the current stateful application is successfully upgraded, it is determined whether the current batch is the last batch of the stateful application to be upgraded. If it is the last batch, the upgrade operation for the next stateful application is performed. If the current batch is not the last batch, the upgrade operation for the next batch of the current stateful application continues.
[0069] The optional application upgrade method provided in this application embodiment offers a fast and convenient method for concurrent application upgrades, reducing upgrade pressure and improving upgrade efficiency. It automatically specifies the upgrade order, upgrade ratio, and maximum number of unavailable applications for different types, reducing errors caused by manual specification and fully ensuring the high availability of stateful applications.
[0070] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0071] This application also provides an application upgrade apparatus. It should be noted that the application upgrade apparatus of this application can be used to execute the application upgrade method provided in this application. The application upgrade apparatus provided in this application is described below.
[0072] Figure 6 This is a schematic diagram of an application upgrade device provided according to an embodiment of this application. For example... Figure 6 As shown, the device includes:
[0073] The first determining unit 10 is used to determine the application to be upgraded, wherein the application to be upgraded contains multiple nodes, and each node contains multiple containers;
[0074] The acquisition unit 20 is used to acquire the application type of the application to be upgraded and determine the node information of the application to be upgraded based on the application type.
[0075] The second determining unit 30 is used to determine the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade of the application.
[0076] Setting unit 40 is used to set the target number of containers to be upgraded in each batch in a node based on the minimum number of containers in the node for each type of node.
[0077] The third determining unit 50 is used to determine the upgrade batch of all containers based on the target number of containers to be upgraded in each batch of all nodes, and to perform upgrade processing on the application to be upgraded according to the upgrade batch.
[0078] The application upgrade device provided in this application embodiment determines the application to be upgraded by a first determining unit 10, wherein the application to be upgraded includes multiple nodes, and each node includes multiple containers; an obtaining unit 20 obtains the application type of the application to be upgraded and determines the node information of the application to be upgraded based on the application type; a second determining unit 30 determines the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the node to maintain operation during the upgrade of the application; a setting unit 40 sets the target number of containers to be upgraded in each batch in each node based on the minimum number of containers in the node; and a third determining unit 50 determines the upgrade batch of all containers based on the target number of containers to be upgraded in each batch of all nodes, and performs upgrade processing on the application to be upgraded according to the upgrade batch. This solves the problem in related technologies where application upgrades affect the efficiency of business processing when processing business. By upgrading the containers deployed on each node in the application according to the upgrade batch, the minimum number of containers required to maintain the operation of each node is guaranteed to run normally during the upgrade, thereby achieving the effect of still being able to process business during application upgrade and improving the efficiency of application business processing.
[0079] Optionally, in the application upgrade device provided in this application embodiment, the second determining unit 30 includes: an extraction module, used to extract from node information the multiple nodes included in the application to be upgraded and the number of containers deployed on each node; an acquisition module, used to acquire the historical container failure ratio of each node and calculate the product of the number of containers deployed and the historical container failure ratio; and a calculation module, used to calculate the difference between the number of containers deployed and the product, and set a minimum number of containers based on the difference, wherein the difference is greater than or equal to the minimum number of containers, and the minimum number of containers is greater than or equal to one.
[0080] Optionally, in the application upgrade device provided in the embodiments of this application, the setting unit 40 includes: a setting module, used to set the target number of containers to be upgraded in each batch in each type of node, wherein the difference between the number of containers deployed and the target number is greater than or equal to the minimum number of containers.
[0081] Optionally, in the application upgrade device provided in the embodiments of this application, the third determining unit 50 includes: a first determining module, used to determine the number of each container deployed in the node for each node, and determine the target number of containers deployed in the node as the first upgrade batch in ascending order of the numbers; a second determining module, used to determine a preset number of other containers as the Nth upgrade batch in ascending order of the numbers, where N is an integer, N is greater than or equal to one, the preset number is less than or equal to the target number, and the other containers are containers deployed in the node other than the first upgrade batch.
[0082] Optionally, in the application upgrade device provided in the embodiments of this application, the third determining unit 50 includes: a third determining module, used to determine the container to be upgraded for each type of node in the same upgrade batch, to obtain the container to be upgraded for each upgrade batch; and a processing module, used to perform upgrade processing on the containers to be upgraded batch by batch in ascending order of upgrade batches.
[0083] Optionally, in the application upgrade device provided in this application embodiment, the processing module includes: a judgment submodule, used to determine whether all containers in each upgrade batch have been successfully upgraded; a processing submodule, used to execute the upgrade processing of the next upgrade batch if all containers in the current upgrade batch have been successfully upgraded; and a rollback module, used to roll back all containers in the current upgrade batch to the historical version before the upgrade processing if not all containers in the current upgrade batch have been successfully upgraded.
[0084] Optionally, in the application upgrade apparatus provided in this application embodiment, the determination submodule includes: a data writing module, used to write test data to each type of node after the containers in the target upgrade batch have undergone upgrade processing, and to determine whether the client node of the application to be upgraded has obtained the test data; a first container upgrade determination module, used to determine that all containers in the target upgrade batch have been successfully upgraded if the client node has obtained the test data; and a second container upgrade determination module, used to determine that not all containers in the target upgrade batch have been successfully upgraded if the client node has not obtained the test data.
[0085] The application upgrade device includes a processor and a memory. The first determining unit 10, the acquiring unit 20, the second determining unit 30, the setting unit 40, and the third determining unit 50 are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.
[0086] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured; by adjusting kernel parameters, the processor can continue to handle business operations during application upgrades, thereby improving application processing efficiency.
[0087] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0088] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements an application upgrade method.
[0089] This invention provides a processor for running a program, wherein the program executes an application upgrade method during runtime.
[0090] Figure 7 This is a schematic diagram of an electronic device provided according to an embodiment of this application. For example... Figure 7 As shown, electronic device 701 includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: an application upgrade method. The device in this document can be a server, PC, PAD, mobile phone, etc.
[0091] This application also provides a computer program product that, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: an application upgrade method.
[0092] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0094] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0095] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0096] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0097] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0098] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0099] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0100] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0101] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for upgrading an application, characterized in that, include: The application to be upgraded is identified, wherein the application to be upgraded contains multiple nodes, and each node contains multiple containers; Obtain the application type of the application to be upgraded, and determine the node information of the application to be upgraded based on the application type; Based on the node information, determine the minimum number of containers for each type of node in the application to be upgraded, wherein the minimum number of containers is the number of containers required for the nodes of the application to be upgraded to maintain operation during the upgrade. The determination of the minimum number of containers for each type of node in the application to be upgraded based on the node information includes: extracting the various types of nodes included in the application to be upgraded and the number of containers deployed on each type of node from the node information; obtaining the historical container failure ratio for each type of node, and calculating the product of the number of containers deployed and the historical container failure ratio; calculating the difference between the number of containers deployed and the product, and setting the minimum number of containers based on the difference, wherein the difference is greater than or equal to the minimum number of containers, and the minimum number of containers is greater than or equal to one; the historical container failure ratio is the proportion of the number of failed containers that failed at the same time in the historical working records of each node to the number of containers deployed on that node; For each type of node, set the target number of containers to be upgraded in each batch within the node based on the minimum number of containers in the node; Specifically, setting the target number of containers to be upgraded in each batch in a node based on the minimum number of containers in the node includes: setting the target number of containers to be upgraded in each batch in each node, wherein the difference between the number of containers deployed and the target number is greater than or equal to the minimum number of containers; The upgrade batches of all containers are determined based on the target number of containers to be upgraded in each batch of all nodes, and the application to be upgraded is upgraded according to the upgrade batches.
2. The method according to claim 1, characterized in that, The upgrade batches for all containers are determined based on the target number of containers to be upgraded in each batch across all nodes, including: For each node, determine the number of each container deployed in the node, and determine the target number of containers deployed in the node as the first upgrade batch in ascending order of the numbers; The preset number of other containers are determined as the Nth upgrade batch in ascending order of their numbers, where N is an integer and is greater than or equal to one. The preset number is less than or equal to the target number, and the other containers are containers deployed in the node other than the first upgrade batch.
3. The method according to claim 1, characterized in that, Upgrading the application to be upgraded according to the aforementioned upgrade batch includes: Determine the upgrade container for each node in the same upgrade batch to obtain the upgrade container for each upgrade batch; The containers to be upgraded are upgraded in batches, from smallest to largest.
4. The method according to claim 3, characterized in that, Upgrading the containers to be upgraded in batches, from smallest to largest, includes: Determine whether all containers in each upgrade batch have been successfully upgraded; If all containers in the current upgrade batch are successfully upgraded, proceed with the upgrade process for the next upgrade batch. If not all containers in the current upgrade batch are successfully upgraded, all containers in the current upgrade batch will be rolled back to the previous version before the upgrade process.
5. The method according to claim 4, characterized in that, Determining whether all containers in each upgrade batch have been successfully upgraded includes: After the containers in the target upgrade batch are upgraded, test data is written to each type of node, and it is determined whether the client node of the application to be upgraded has obtained the test data. If the client node obtains the test data, it is determined that all containers in the target upgrade batch have been successfully upgraded; If the client node fails to acquire the test data, it is determined that not all containers in the target upgrade batch have been successfully upgraded.
6. An application upgrade device, characterized in that, include: The first determining unit is used to determine the application to be upgraded, wherein the application to be upgraded includes multiple nodes, and each node includes multiple containers; The acquisition unit is used to acquire the application type of the application to be upgraded and determine the node information of the application to be upgraded based on the application type. The second determining unit is used to determine the minimum number of containers for each type of node in the application to be upgraded based on the node information, wherein the minimum number of containers is the number of containers required for the nodes of the application to be upgraded to maintain operation during the upgrade. The second determining unit includes: an extraction module, used to extract from the node information the various nodes included in the application to be upgraded and the number of containers deployed on each node; an acquisition module, used to acquire the historical container failure ratio of each node and calculate the product of the number of containers deployed and the historical container failure ratio; and a calculation module, used to calculate the difference between the number of containers deployed and the product, and set the minimum number of containers based on the difference, wherein the difference is greater than or equal to the minimum number of containers, and the minimum number of containers is greater than or equal to one; the historical container failure ratio is the proportion of the number of faulty containers that failed at the same time in the historical working records of each node to the number of containers deployed on that node. The setting unit is used to set the target number of containers to be upgraded in each batch in a node based on the minimum number of containers in the node. The setting unit includes: a setting module, used to set the target number of containers to be upgraded in each batch in each type of node, wherein the difference between the number of containers deployed and the target number is greater than or equal to the minimum number of containers; The third determining unit is used to determine the upgrade batch of all containers based on the target number of containers to be upgraded in each batch of all nodes, and to perform upgrade processing on the application to be upgraded according to the upgrade batch.
7. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, wherein the program, when running, controls the device where the non-volatile storage medium resides to execute the application upgrade method according to any one of claims 1 to 5.
8. An electronic device, characterized in that, It includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the application upgrade method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Rolling upgrading method, device and equipment of application example and storage medium
CN112306525A