Microservice Upgrade Method and Device
By using the target microservice upgrade container during the microservice upgrade process, first performing the environment configuration subcontainer and then the application subcontainer, the cumbersome problems caused by the update of environmental resource configuration between versions during the microservice upgrade process are solved, and a rapid and simplified cross-version microservice upgrade is achieved.
Patent Information
- Application Number
- CN202210166973.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2042-02-23
AI Technical Summary
During the microservice upgrade process, if there are other versions between the current version and the target version, these versions need to be upgraded in turn, resulting in a cumbersome and long-term upgrade process, affecting the user experience.
Upgrade the container by obtaining the target microservices' target microservices, which contains the environment configuration subcontainer and application subcontainer. First execute the environment configuration subcontainer to initialize the environment resource configuration of the target microservice, and then after the environment configuration subcontainer is executed, execute the application subcontainer to upgrade the microservice to the target version.
Cross-version microservice upgrades have been realized, and directly upgraded from the current version to the target version at one time, simplifying the upgrade process, shortening the upgrade time, and improving the user experience.
Smart Images

Figure CN114510253B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a microservice upgrade method and apparatus. Background Art
[0002] A microservice architecture is an architectural style that can split a complex application into numerous microservice components that can be independently deployed and run. In related technologies, when upgrading a microservice, if there are other versions that have updated the environmental resource configuration of the microservice between the current version and the target version to be upgraded, it is necessary to first upgrade the microservice from the current version to that other version, and it is impossible to directly upgrade from the current version to the target version. The upgrade process is relatively cumbersome and the upgrade time is relatively long, seriously affecting the user experience. Summary of the Invention
[0003] In view of this, this application provides a microservice upgrade method and apparatus to achieve cross-version microservice upgrade, enabling the microservice to be directly upgraded from the current version to the target version to be upgraded in one go.
[0004] Specifically, this application is implemented through the following technical solutions:
[0005] According to a first aspect of this application, a microservice upgrade method is proposed, including:
[0006] Obtain a target microservice upgrade container corresponding to the target microservice, where the target microservice upgrade container is used to upgrade the target microservice to the target version, the target microservice upgrade container includes an environment configuration sub-container and an application program sub-container, the environment configuration sub-container is used to update the environmental resource configuration corresponding to the target microservice, and the application program sub-container is used to update the service content provided by the target microservice;
[0007] Execute the environment configuration sub-container to initialize the environmental resource configuration of the target microservice under the target version;
[0008] When the execution of the environment configuration sub-container is completed, execute the application program sub-container to upgrade the target microservice to the target version.
[0009] According to a second aspect of this application, a microservice upgrade apparatus is proposed, including:
[0010] An acquisition unit, configured to acquire a target microservice upgrade container corresponding to a target microservice, where the target microservice upgrade container is used to upgrade the target microservice to a target version, and the target microservice upgrade container includes an environment configuration sub-container and an application sub-container. The environment configuration sub-container is used to update the environment resource configuration corresponding to the target microservice, and the application sub-container is used to update the service content provided by the target microservice;
[0011] A first execution unit, configured to execute the environment configuration sub-container to implement initialization of the environment resource configuration of the target microservice under the target version;
[0012] A second execution unit, configured to execute the application sub-container to upgrade the target microservice to the target version when the execution of the environment configuration sub-container is completed.
[0013] According to a third aspect of the present application, there is provided an electronic device, including:
[0014] A processor;
[0015] A memory for storing executable instructions of the processor;
[0016] Wherein, the processor runs the executable instructions to implement the method described in the embodiment of the first aspect above.
[0017] According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the embodiment of the first aspect above are implemented.
[0018] As can be seen from the technical solutions provided by the present application above, the present application stores the update operation for the environment resource configuration in the form of an independent environment configuration sub-container, and differentiates it from the application sub-container corresponding to the update of the service content of the microservice. When upgrading the microservice, the environment configuration sub-container is executed first, and then the application sub-container is executed after the execution of the environment configuration sub-container is completed, so that the microservice does not need to pay attention to other versions between the current version and the target version to be upgraded when upgrading, but can achieve cross-version microservice upgrade and directly upgrade from the current version to the target version at one time. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0020] Figure 1 is a schematic diagram of a microservice upgrade version shown in the related art;
[0021] Figure 2 is a flowchart of a microservice upgrade method shown according to an exemplary embodiment of the present application;
[0022] Figure 3 is a detailed flowchart of a microservice upgrade method shown according to an exemplary embodiment of the present application;
[0023] Figure 4 is a schematic diagram of a microservice upgrade version shown according to an exemplary embodiment of the present application;
[0024] Figure 5 is a schematic diagram of an electronic device for microservice upgrade shown according to an exemplary embodiment of the present application;
[0025] Figure 6 is a block diagram of a microservice upgrade device shown according to an exemplary embodiment of the present application. Detailed implementation manners
[0026] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0027] The terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms "a", "the", and "said" used in the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0028] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".
[0029] Next, the embodiments of the present application will be described in detail.
[0030] The upgrade process of microservices generally requires the operation and maintenance personnel to conduct an environment assessment of the microservices first, in order to inspect and troubleshoot the running status of the current software product. If problems or potential hazards are found during the troubleshooting process, rectification and repair are required to ensure the normal running status of the microservice software before the upgrade implementation. Then, by replacing the container, the container of the new upgraded version is used to replace the existing container to achieve the upgrade of the microservice application, and functional testing is performed on the microservice application after the upgrade implementation to sign and accept based on the functional test results.
[0031] Generally speaking, microservice applications are upgraded as the version iterates according to the software versions provided by developers. However, in some cases where users do not upgrade the microservices in a timely manner or other situations, the following scenarios may occur: the current version of the microservice is Vm, and the target version to be upgraded is Vn, where both m and n are positive integers and n - m ≥ 2, that is, there are other un-upgraded versions between the current version and the target version to be upgraded of the microservice. In this case, if any of the un-upgraded versions between the current version Vm and the target version Vn updates the environmental resource configuration corresponding to the microservice, then during the process of updating the microservice from the current version to the target version, the versions that update the environmental resource configuration need to be upgraded in sequence. Among them, the environmental resource configuration mainly includes peripheral resources such as database table structures, database data, Redis cache data, DNS domain name addresses, etc., which are not the microservice software itself. Figure 1 It is a schematic diagram of the upgraded version of microservices in related technologies, as Figure 1 shown, the microservice to be upgraded corresponds to multiple versions such as V1, V2... V7 that are iterated in sequence, where V1 is the initial version of the service, V3 is the current version of the microservice, and V7 is the target version to be upgraded of the microservice; if there are changes to the database table in the update operation corresponding to version V2, modifications to the Redis cache data in the update operation corresponding to version V4, and replacement of the DNS domain name address in the update operation corresponding to version V6. Then there are multiple other versions between the current version V3 and the target version V7 that update the environmental resource configuration of the microservice. If you want to upgrade the microservice from the current version V3 to the target version V7, you need to upgrade it from the current version V3 to version V4, then from version V4 to version V6, and finally from version V6 to the target version V7, that is, three upgrades are required. And in each upgrade, the entire upgrade process of "environment assessment - problem repair - upgrade implementation - functional testing - signature acceptance" as described above needs to be carried out. The upgrade takes a long time and is relatively cumbersome to implement, and has high requirements for the operation of the operation and maintenance personnel.
[0032] To solve the above problems, Figure 2 It is a flowchart of a microservice upgrade method shown according to an exemplary embodiment of the present application. AsFigure 2 As shown in the figure, the method may include the following steps:
[0033] Step 202: Obtain a target microservice upgrade container corresponding to the target microservice. The target microservice upgrade container is used to upgrade the target microservice to a target version. The target microservice upgrade container includes an environment configuration sub-container and an application sub-container. The environment configuration sub-container is used to update the environment resource configuration corresponding to the target microservice, and the application sub-container is used to update the service content provided by the target microservice.
[0034] It should be noted that the execution subject of the microservice upgrade method provided in this application may specifically be an upgrade device of a microservice architecture, such as a container management controller, etc. This upgrade device can be implemented in a hardware and / or software manner. Generally, it can be integrated into the server on which the microservice architecture platform is based, and can cooperate with the data server storing various databases on which the microservice architecture platform is based. In addition, the server on which the update device is based and the data server can be the same server, or different servers belonging to the same server cluster. This application does not limit this.
[0035] Compared with directly encapsulating the environment resource configuration operation and the service content provided by the microservice itself in the same container in the related art, in this application, the operations related to the environment resource configuration of the microservice are extracted from the application code and encapsulated separately into an environment configuration sub-container, and the remaining content of the application code for the service provided by the microservice is encapsulated into an application sub-container. That is, the application sub-container in this application is used to provide services externally, and stores the exchange process and service content related to this microservice; while the environment configuration sub-container is used to add, delete, modify the database of the non-microservice software itself or modify the database table structure. Among them, the environment resource configuration can be used to provide authentication query data, etc. for the microservice. Therefore, the environment resource configuration in this application can include at least one of the following: database table structure, database data, Redis cache data, DNS domain name address. For any version of the microservice, there is a microservice upgrade container that includes a unique environment configuration sub-container and a unique application sub-container corresponding to this version, that is, the environment configuration sub-container, the application sub-container, the microservice upgrade container, and the version correspond one by one. Therefore, for the target version to which the target microservice is to be upgraded, there is also a target microservice upgrade container for upgrading the target microservice to the target version. This target microservice upgrade container includes an environment configuration sub-container for upgrading the environment resource configuration of the target microservice to the target version, and an application sub-container for upgrading the service content provided by the target microservice to the target version.
[0036] Step 104: Execute the environment configuration sub-container to initialize the environment resource configuration of the target microservice under the target version.
[0037] In one embodiment, the environment configuration sub-container may include at least one environment configuration tool to be upgraded, and the environment configuration tool to be upgraded corresponds to the environment configuration version to be upgraded of the target microservice. The environment configuration version to be upgraded is the version between the current version and the target version of the target microservice that includes environment resource configuration update operations. That is, the environment configuration tool to be upgraded is the environment configuration tool corresponding to the version that requires environment resource configuration during the upgrade process of the target microservice from the current version to the target version. Among them, any environment configuration tool to be upgraded is used to update the environment resource configuration from the previous version of the target environment configuration version corresponding to the any environment configuration tool to the target environment configuration version. Therefore, by sequentially executing each environment configuration tool to be upgraded, the environment resource configuration corresponding to the target microservice can be upgraded sequentially and finally upgraded to the environment resource configuration corresponding to the target version.
[0038] Any Figure 1 Taking the microservice upgrade version shown as an example, during the process of upgrading from the current version V3 to the target version V7, there are versions V4 and V6 that have updated the environment resource configuration. That is, the environment configuration versions to be upgraded are versions V4 and V6, and the environment configuration sub-container corresponding to the target version V7 contains the environment configuration tools to be upgraded corresponding to versions V4 and V6 respectively. Among them, the environment configuration tool to be upgraded corresponding to version V4 is used to update the environment resource configuration corresponding to the microservice from version V3 to version V4; the environment configuration tool to be upgraded corresponding to version V6 is used to update the environment resource configuration corresponding to the microservice from version V4 to version V6. By executing the environment configuration sub-container corresponding to version V7 to sequentially execute the environment configuration tool to be upgraded corresponding to version V4 and the environment configuration tool to be upgraded corresponding to version V6, the initialization of the environment resource configuration corresponding to the target version V7 of this microservice can be achieved.
[0039] However, during the actual application process, the environment configuration sub-container may not necessarily be able to know the current version of the target microservice to be upgraded when it is created. Therefore, in addition to the environment configuration tool to be upgraded, the environment configuration tools included in the environment configuration sub-container may also include historical environment configuration tools. The historical environment configuration tools correspond to the respective historical environment configuration versions of the target microservice, and the historical environment configuration versions are the versions that contain environment resource configuration update operations in the historical versions corresponding to the current version. That is, when the current version of the microservice is not the initial version, if there is also a version in the historical version corresponding to this current version that updated the environment resource configuration corresponding to the microservice, then the environment configuration tool corresponding to that version can also be included in the environment configuration sub-container corresponding to the target version to be upgraded. That is to say, the environment configuration sub-container corresponding to the target version to be upgraded may include the environment configuration tools corresponding to all the versions that updated the environment resource configuration from the initial version to the target version of the target microservice.
[0040] Thus, when upgrading a microservice, it is necessary to first determine the current version of the target microservice to be upgraded, so as to screen the environment configuration tools included in the environment configuration sub-container according to this current version, and determine the environment configuration tools to be upgraded whose corresponding versions are between the current version and the target version. For example, Figure 1 taking the microservice upgrade version shown as an example, if there are also versions V1 and V2 before the current version V3, and version V2 updated on the basis of the microservice environment resource configuration corresponding to version V1, and as mentioned above, there are also versions V4 and V6 that updated the environment resource configuration during the process of upgrading from the current version V3 to the target version V7. Then, in the environment configuration sub-container corresponding to the target version V7, in addition to the environment configuration tools corresponding to the above versions V4 and V6 respectively, it also includes the environment configuration tool corresponding to version V3, which is used to update the environment resource configuration corresponding to the microservice from version V1 to version V3. When executing the environment configuration sub-container corresponding to version V7, it is also necessary to determine that the current version of this microservice is version V3, and based on this, determine that the environment configuration tool corresponding to version V2 is a historical environment configuration tool, and the environment configuration tools corresponding to versions V4 and V6 respectively are the environment configuration tools to be upgraded. After that, execute the environment configuration tools to be upgraded corresponding to version V4 and version V6 in sequence to complete the initialization of the environment resource configuration corresponding to the target version V7 of this microservice.
[0041] In one embodiment, the environment configuration tool may exist in the form of a script and be stored in a corresponding script directory, which may correspond to the version number of the corresponding version of the stored environment configuration tool. For example, it may be named after the version number of the corresponding environment configuration script it stores. That is, in the environment configuration sub-container corresponding to the target version of the target microservice, there are script directories corresponding to all versions that have updated the environment resource configuration from the initial version to the target version of the target microservice. Each script directory stores an environment configuration script solidified from the environment resource configuration operations of its corresponding version, which is used to implement the function of updating the environment resource configuration of the target service from the previous version corresponding to its version to its corresponding version. In addition to the environment configuration scripts contained in each script directory, the environment configuration sub-container may also contain a scheduling script for scheduling the script directories and executing the environment configuration scripts therein.
[0042] Specifically, when executing the environment configuration sub-container corresponding to the target version, the current version number of the target version can be obtained first, and the version range to be upgraded can be determined according to the version number of the target version to be upgraded. And sort the script directories based on the version numbers corresponding to each script directory in the environment configuration sub-container (for example, the script directories can be arranged in ascending order according to the iteration order of the versions). Execute the scheduling script to sequentially obtain the script directories according to the sorting result, compare the version number corresponding to the obtained script directory with the version range to be upgraded. If the version number corresponding to the obtained script directory is not within the version range to be upgraded, obtain the next script directory according to the sorting result; if the version number corresponding to the obtained script directory is within the version range to be upgraded, execute the environment configuration script stored in the script directory. Among them, sorting the script directories based on the version numbers corresponding to each script directory in the environment configuration container can be performed at any stage before executing the scheduling script, and can also be pre-configured during the configuration process of the environment configuration sub-container. This application does not limit this. Taking Figure 1 the microservice upgrade version shown as an example, if it is determined that the current version number of the target microservice to be upgraded is V3 and the target version number is V7, then the version range to be upgraded can be determined as (V3, V7]. Execute the scheduling script to sequentially obtain the script directories according to the version numbers corresponding to each script directory in the environment configuration sub-container corresponding to the target version V7, and compare whether it is within the version range to be upgraded. If it is within the range, execute the environment configuration script contained in the script directory, so that the environment resource configuration corresponding to the target microservice can be updated from the current version to the target version in sequence according to the iteration order of the versions.
[0043] In one embodiment, the environment configuration sub-container further includes a backup tool, which can also exist in the form of a script. Before updating the environment resources configuration of the microservice, the backup tool can be executed to back up the current version data of the target microservice, so as to avoid the failure of microservice upgrade and the inability to restore to its current version.
[0044] Step 106: When the execution of the environment configuration sub-container is completed, execute the application sub-container to upgrade the target microservice to the target version.
[0045] In one embodiment, when the execution of the environment configuration sub-container is completed, that is, after each environment configuration tool to be upgraded included in the environment configuration sub-container is executed in sequence, the application sub-container can be automatically started, ensuring that before the application sub-container starts, the surrounding environment supporting resources or data of the microservice already meet the microservice requirements, so that the application sub-container can directly update the service content provided by the microservice to the target version. Although for the environment configuration sub-container, multiple upgrades still need to be performed based on the iteration order of other versions that have updated the environment resource configuration between the current version and the target version, this process is automatically scheduled and completed by directly executing the environment configuration sub-container, and for the application sub-container, only one upgrade is required to directly upgrade from the current version to the target version. That is to say, for the overall target microservice upgrade container, the target microservice can be directly upgraded from the current version to the target version corresponding to the target microservice upgrade container through only one upgrade. The multiple automatic upgrades performed by the environment configuration sub-container are imperceptible to the operation and maintenance personnel, solving the problem that an upgrade requirement of the operation and maintenance personnel must be achieved through multiple upgrade operations, shortening the upgrade process and improving the operation and maintenance efficiency.
[0046] In one embodiment, to avoid the abnormal operation of the upgraded microservice, after the execution of the application sub-container is completed, the upgraded target microservice needs to be functionally checked to determine whether the status of the microservice is normal, and at the same time verify all the functions of the service instance to ensure that the upgrade result meets the expectations. If the upgraded target microservice passes the function verification, it is determined that the upgrade of the target microservice is successful. If the upgraded target microservice fails the function verification, the upgraded target microservice needs to be restored to the current version before the upgrade according to the backed-up current version data before the upgrade, and it is determined that the upgrade of the service instance fails. At the same time, the inspection data corresponding to the instance with inspection failure can also be collected and recorded. The inspection data includes business logic information, error message, etc. By outputting the inspection data to the tester, it is convenient for the tester to find the reason for the failure of the service instance upgrade.
[0047] As can be seen from the technical solutions provided by the present application above, the present application stores the update operations for environmental resource configuration in the form of an independent environmental configuration sub-container, and differentiates it from the application program sub-container corresponding to the update of the service content of the microservice. When upgrading the microservice, first execute the environmental configuration sub-container, and then execute the application program sub-container after the execution of the environmental configuration sub-container is completed, so that the microservice does not need to pay attention to other versions between the current version and the target version to be upgraded during the upgrade, but can achieve cross-version microservice upgrade and directly upgrade from the current version to the target version at one time. The following will be combined with Figure 3 for detailed description. Among them, Figure 3 The detailed flowchart of a microservice upgrade method shown according to an exemplary embodiment of the present application. As Figure 3 shown, the microservice upgrade process includes the following steps:
[0048] Step 301, obtain the environmental configuration sub-container and the application program sub-container.
[0049] When the software product of the microservice architecture needs to be upgraded, first, a target microservice upgrade container corresponding to the target version to be upgraded will be received, where the target microservice upgrade container includes an environmental configuration sub-container and an application program sub-container.
[0050] Taking Figure 4 the microservice upgrade version shown as an example, the target microservice is successively upgraded and iterated with versions V2, V3... V7 on the basis of the initial version V1, and the environmental resource configuration corresponding to the microservice is updated in versions V2, V4, and V6, where version V7 is the target version to be upgraded to. The target microservice upgrade container corresponding to version V7 contains an environmental configuration sub-container and an application service sub-container. The environmental sub-container contains the script directories corresponding to versions V2, V4, and V6, and each script directory contains the environmental configuration scripts solidified from the environmental resource configuration update operations corresponding to their respective versions.
[0051] Step 302: Execute the environmental configuration sub-container.
[0052] Step 303: Execute the backup script.
[0053] After receiving the target microservice upgrade container, first execute the environmental configuration sub-container therein.
[0054] If the environmental configuration sub-container contains a backup script, first execute the backup script to back up the current version data of the target microservice.
[0055] Step 304: Obtain the current version number of the target microservice and the target version number to be upgraded.
[0056] Step 305: Determine the version range to be upgraded.
[0057] For example, if the current version number of the target version is V3 and the target version number is V7, the version range to be upgraded for the target version can be determined as (V3, V7].
[0058] Step 306: Sort each script directory included in the environment configuration sub-container.
[0059] If each script directory in the environment configuration sub-container is named by its corresponding version number, the version iteration order of the target microservice can be determined based on the order of the version numbers, and the script directories are sorted accordingly. Therefore, the script directories in the environment configuration sub-container corresponding to the target version V7 can be arranged in the order of V2 - V4 - V6.
[0060] Step 307: Obtain the script directories in sequence according to the beat requirement result.
[0061] Step 308: Determine whether the corresponding version number of the obtained script directory is within the version range to be upgraded.
[0062] If the corresponding version number of the obtained script directory is within the version range to be upgraded, go to Step 309; if the corresponding version number of the obtained script directory is not within the version range to be upgraded, go back to Step 307.
[0063] Step 309: Execute the script directory.
[0064] Step 310: Determine whether the script directories in the environment configuration sub-container have been obtained in sequence.
[0065] If the script directories in the environment configuration sub-container have not been obtained in sequence, go back to Step 307; if the script directories in the environment configuration sub-container have been obtained in sequence, go to Step 311.
[0066] As Figure 4As shown by the dashed arrow, it is the upgrade process of the environmental resource configuration corresponding to the target microservice Su in this embodiment. Based on the arrangement order described above, the scheduling script in the environmental configuration sub-container can first obtain the script directory corresponding to version V2, and determine that V2 is not within the version range to be upgraded (V3, V7]; then obtain the script directory corresponding to version V4, and determine that V4 is within the version range to be upgraded (V3, V7], and execute the environmental configuration tool in the script directory corresponding to V4. At this time, the script directories in the environmental configuration sub-container have not been obtained one by one; then it is necessary to obtain the script directory corresponding to version V6, determine that V6 is within the version range to be upgraded (V3, V7], execute the environmental configuration tool in the script directory corresponding to V6, and determine that all the script directories in the environmental configuration sub-container have been obtained one by one.
[0067] Step 311: Execute the application program sub-container
[0068] After determining that all the script directories in the environmental configuration sub-container have been obtained one by one, that is, determining that the environmental configuration sub-container has been executed, the application program sub-container is automatically executed, as Figure 4 shown by the solid arrow in, and directly upgrade the service content provided by the target microservice from the current version V3 to the target version V7.
[0069] Corresponding to the above method embodiment, this specification also provides an embodiment of a device.
[0070] Figure 5 It is a schematic structural diagram of a microservice upgrade electronic device shown according to an exemplary embodiment of the present application. Referring to Figure 5 , at the hardware level, this electronic device includes a processor 502, an internal bus 504, a network interface 506, a memory 508, and a non-volatile memory 510. Of course, there may also be other hardware required for other services. The processor 502 reads the corresponding computer program from the non-volatile memory 510 into the memory 508 and then runs. Of course, in addition to the software implementation method, the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, and can also be hardware or a logic device.
[0071] Figure 6 It is a block diagram of a microservice upgrade device shown according to an exemplary embodiment of the present application. Referring to Figure 6 , this device includes an acquisition unit 602, a first execution unit 604, and a second execution unit 606, where:
[0072] The acquisition unit 602 is configured to acquire a target microservice upgrade container corresponding to a target microservice, where the target microservice upgrade container is used to upgrade the target microservice to a target version. The target microservice upgrade container includes an environment configuration sub-container and an application sub-container. The environment configuration sub-container is used to update the environment resource configuration corresponding to the target microservice, and the application sub-container is used to update the service content provided by the target microservice.
[0073] Optionally, the environment resource configuration includes at least one of the following: database table structure, database data, Redis cache data, DNS domain name address.
[0074] The first execution unit 604 is configured to execute the environment configuration sub-container to implement the initialization of the environment resource configuration of the target microservice in the target version.
[0075] Optionally, the environment configuration sub-container includes at least one environment configuration tool to be upgraded. The environment configuration tool to be upgraded corresponds to the environment configuration version to be upgraded of the target microservice. The environment configuration version to be upgraded is a version between the current version and the target version of the target microservice that includes an environment resource configuration update operation. Executing the environment configuration sub-container includes: sequentially executing each environment configuration tool to be upgraded; where any environment configuration tool to be upgraded is used to update the environment resource configuration from the previous version of the target environment configuration version corresponding to the any environment configuration tool to the target environment configuration version to be upgraded.
[0076] Optionally, the environment configuration sub-container includes at least one environment configuration tool. The at least one environment configuration tool includes a historical environment configuration tool and an environment configuration tool to be upgraded. The historical environment configuration tool corresponds to each historical environment configuration version of the target microservice. The historical environment configuration version is a historical version corresponding to the current version that includes an environment resource configuration update operation. The first execution unit 604 further includes:
[0077] A determination subunit is configured to determine the current version of the target microservice.
[0078] An acquisition subunit is configured to acquire the environment configuration tool to be upgraded in the environment configuration sub-container according to the current version.
[0079] Optionally, the environment configuration tool is an environment configuration script, and the environment configuration scripts are respectively stored in a script directory, and the script directory corresponds to the version number of the corresponding version of the stored environment configuration script; obtaining the environment configuration tool to be upgraded in the environment configuration sub-container according to the current version, and sequentially executing each environment configuration tool to be upgraded, including: obtaining the current version number corresponding to the current version and the target version number corresponding to the target version; determining the version range to be upgraded according to the current version number and the target version number; sorting the script directories according to the version numbers corresponding to the respective script directories, and sequentially obtaining the script directories according to the sorting result; if the version number corresponding to the obtained script directory is within the version range, execute the environment configuration script stored in the script directory.
[0080] Optionally, the script directory is named after the version number of the corresponding version of the stored environment configuration script.
[0081] Optionally, the environment configuration sub-container includes a backup tool, and executing the environment configuration sub-container includes: executing the backup tool to back up the current version data of the target microservice; and updating the environment resource configuration according to the environment configuration sub-container when the backup is completed.
[0082] The second execution unit 606 is configured to execute the application sub-container to upgrade the target microservice to the target version when the execution of the environment configuration sub-container is completed.
[0083] Optionally, the above device further includes:
[0084] The verification unit 608 is configured to perform functional verification on the upgraded target microservice.
[0085] The recovery unit 610 is configured to, if the verification fails, restore the upgraded target microservice to the version before the upgrade according to the current version data obtained by the backup.
[0086] The implementation processes of the functions and roles of the various units in the above device are specifically detailed in the implementation processes of the corresponding steps in the above method, and will not be elaborated here.
[0087] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions of the method embodiments. The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this application. A person of ordinary skill in the art can understand and implement it without creative work.
[0088] In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium including instructions, such as a memory including instructions. The above instructions can be executed by a processor of the microservice upgrade device to implement the method described in any one of the above embodiments. For example, the method may include:
[0089] Obtain a target microservice upgrade container corresponding to the target microservice. The target microservice upgrade container is used to upgrade the target microservice to a target version. The target microservice upgrade container includes an environment configuration sub-container and an application program sub-container. The environment configuration sub-container is used to update the environment resource configuration corresponding to the target microservice, and the application program sub-container is used to update the service content provided by the target microservice; execute the environment configuration sub-container to initialize the environment resource configuration of the target microservice under the target version; when the execution of the environment configuration sub-container is completed, execute the application program sub-container to upgrade the target microservice to the target version.
[0090] Among them, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc., and this application does not limit this.
[0091] The above are only the preferred embodiments of this application and are not used to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application shall be included within the scope of protection of this application.
Claims
1. A microservice upgrade method, characterized in that, the method includes: Obtain a target microservice upgrade container corresponding to the target microservice. The target microservice upgrade container is used to upgrade the target microservice to a target version. The target microservice upgrade container includes an environment configuration sub-container and an application sub-container. The environment configuration sub-container is used to update the environment resource configuration corresponding to the target microservice, and the application sub-container is used to update the service content provided by the target microservice; Execute the environment configuration sub-container to sequentially execute the environment resource configuration update operations included between the current version and the target version of the target microservice; When the execution of the environment configuration sub-container is completed, execute the application sub-container to upgrade the target microservice to the target version.
2. The method according to claim 1, characterized in that, The environment configuration sub-container includes at least one environment configuration tool to be upgraded. The environment configuration tool to be upgraded corresponds to the environment configuration version to be upgraded of the target microservice. The environment configuration version to be upgraded is the version between the current version and the target version of the target microservice that includes environment resource configuration update operations; The execution of the environment configuration sub-container includes: Sequentially execute each environment configuration tool to be upgraded; wherein, any environment configuration tool to be upgraded is used to update the environment resource configuration from the previous version of the target environment configuration version to be upgraded corresponding to the any environment configuration tool to be upgraded to the target environment configuration version to be upgraded.
3. The method according to claim 2, characterized in that, The environment configuration sub-container includes at least one environment configuration tool. The at least one environment configuration tool includes a historical environment configuration tool and an environment configuration tool to be upgraded. The historical environment configuration tool corresponds to each historical environment configuration version of the target microservice. The historical environment configuration version is the historical version corresponding to the current version that includes environment resource configuration update operations. The method further includes: Determine the current version of the target microservice; Obtain the environment configuration tool to be upgraded in the environment configuration sub-container according to the current version.
4. The method according to claim 3, characterized in that, The environment configuration tool is an environment configuration script, and the environment configuration scripts are respectively stored in a script directory. The script directory corresponds to the version number of the corresponding version of the stored environment configuration script; The obtaining the environment configuration tool to be upgraded in the environment configuration sub-container according to the current version and sequentially executing each environment configuration tool to be upgraded includes: Obtain the current version number corresponding to the current version and the target version number corresponding to the target version; Determine the version range to be upgraded according to the current version number and the target version number; Determine the sorting result of the script directories according to the version numbers corresponding to the respective script directories in the environment configuration sub-container, and sequentially obtain the script directories according to the sorting result; If the version number corresponding to the obtained script directory is within the version range, execute the environment configuration script stored in the script directory.
5. The method according to claim 4, wherein, the script directory is named with the version number corresponding to the version of the stored environment configuration script.
6. The method according to claim 1, wherein, the environment resource configuration includes at least one of the following: database table structure, database data, Redis cache data, DNS domain name address.
7. The method according to claim 1, wherein, the environment configuration sub-container contains a backup tool, and the execution of the environment configuration sub-container includes: executing the backup tool to back up the current version data of the target microservice; in the case where the backup is completed, updating the environment resource configuration according to the environment configuration sub-container.
8. The method according to claim 7, wherein, the method further includes: performing a function verification on the upgraded target microservice; if the verification fails, restoring the upgraded target microservice to the version before the upgrade according to the obtained current version data by backup.
9. A microservice upgrade device, wherein, the device includes: an acquisition unit, configured to acquire a target microservice upgrade container corresponding to a target microservice, the target microservice upgrade container being used to upgrade the target microservice to a target version, the target microservice upgrade container including an environment configuration sub-container and an application program sub-container, the environment configuration sub-container being used to update the environment resource configuration corresponding to the target microservice, and the application program sub-container being used to update the service content provided by the target microservice; a first execution unit, configured to execute the environment configuration sub-container to sequentially execute the environment resource configuration update operations included between the current version and the target version of the target microservice; a second execution unit, configured to execute the application program sub-container to upgrade the target microservice to the target version in the case where the execution of the environment configuration sub-container is completed.
10. An electronic device, wherein, it includes: a processor; a memory for storing processor-executable instructions; wherein, the processor realizes the method according to any one of claims 1-8 by running the executable instructions.
11. A computer-readable storage medium, on which computer instructions are stored, wherein, when the instructions are executed by a processor, the steps of the method according to any one of claims 1-8 are realized.
Citation Information
Patent Citations
Cloud platform upgrading method and device, terminal and storage medium
CN110286930A
Software upgrading method and device, electronic equipment and readable storage medium
CN113741931A