Micro-service version management and control method and device
Through the communication between the microservice and the configuration center and the use of the configuration identification set, the problem of configuration information modification errors in the microservice version changes is solved, and the accurate configuration information acquisition and successful change of the microservice during the version changes is achieved.
Patent Information
- Application Number
- CN202510137498.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-06-17
AI Technical Summary
During the microservice version change process, the process of manually modifying the configuration table is cumbersome and error-prone, making it difficult for microservices to accurately obtain configuration information adapted to the version to be changed, resulting in the failure of version change.
Through the communication connection between the microservice and the configuration center, each version of the microservice has a corresponding configuration identity set, and the corresponding configuration information is referenced from the configuration center based on the configuration identity. In response to the target microservice to be changed, determine the corresponding configuration identification set of its current version and the target version, calculate the configuration information difference, and change the configuration information stored in the configuration center to make it store configuration information that is adapted to the target version.
It realizes that microservices accurately obtain configuration information adapted to the target version when version changes, avoids the cumbersome and errors of manually modifying the configuration table, and ensures the success of the microservice version change.
Smart Images

Figure CN120162075A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of microservice version control, and particularly to a microservice version control method and device. Background Art
[0002] An application based on a microservice architecture consists of numerous microservices, and corresponding services are realized through the coordination and cooperation among the microservices. During the development or release stage of the application, version change operations such as version upgrade of the microservices are often required to enable the microservices to better support the service implementation of the application based on the changed version.
[0003] Each version of the microservice requires a set of configuration information that supports the normal operation of the microservice in the corresponding version. The configuration information required by the microservice is usually read from a configuration table dedicated to recording configuration information. Based on this, before each version change of the microservice, it is necessary to first modify the configuration information of the microservice in the configuration table to be adapted to the version to which the change is to be made, and then the version change of the microservice can be performed based on the modified configuration information. However, the modification of the configuration table depends on developers to complete manually, and the manual modification process is cumbersome and error-prone. Problems such as incorrect modification and omission of configuration information often occur, resulting in the microservice being difficult to accurately obtain the configuration information adapted to the version to which the change is to be made, and further causing the failure of the microservice version change.
[0004] Therefore, how to accurately obtain the configuration information adapted to the version to which the microservice is to be changed for version change of the microservice has become an urgent problem to be solved currently. Summary of the Invention
[0005] This application proposes a microservice version control method and device, and the main purpose is to accurately obtain the configuration information adapted to the version to which the microservice is to be changed for version change of the microservice.
[0006] To achieve the above purpose, this application mainly provides the following technical solutions:
[0007] In a first aspect, the present application provides a microservice version control method. The microservice is communicatively connected to a configuration center, and the configuration center is used to store the configuration information of the microservice. Each version of the microservice has a corresponding set of configuration identifiers, and each configuration identifier in the set of configuration identifiers corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identifier. The microservice version control method provided in this embodiment may include: in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program, determining a first set of configuration identifiers corresponding to the current version of the target microservice and a second set of configuration identifiers corresponding to the target version to which it is to be changed; based on the first set of configuration identifiers and the second set of configuration identifiers, determining the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version; based on the configuration information difference, changing the configuration information stored in the configuration center so that the changed configuration center stores the configuration information corresponding to the second set of configuration identifiers; and by the target microservice referencing the configuration information corresponding to the second set of configuration identifiers, changing the target microservice from the current version to the target version.
[0008] In a second aspect, the present application provides a microservice version control device. The microservice is communicatively connected to a configuration center, and the configuration center is used to store the configuration information of the microservice. Each version of the microservice has a corresponding set of configuration identifiers, and each configuration identifier in the set of configuration identifiers corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identifier. The microservice version control device provided in this embodiment includes:
[0009] A first determination module, configured to, in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program, determine a first set of configuration identifiers corresponding to the current version of the target microservice and a second set of configuration identifiers corresponding to the target version to which it is to be changed;
[0010] A second determination module, configured to determine the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version based on the first set of configuration identifiers and the second set of configuration identifiers;
[0011] A first change module, configured to change the configuration information stored in the configuration center based on the configuration information difference so that the changed configuration center stores the configuration information corresponding to the second set of configuration identifiers;
[0012] A second change module, configured to change the target microservice from the current version to the target version by the target microservice referencing the configuration information corresponding to the second set of configuration identifiers.
[0013] In a third aspect, the present application provides a computer-readable storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the microservice version management method described in the first aspect.
[0014] In a fourth aspect, the present application provides an electronic device, which includes: a memory for storing a program; a processor coupled to the memory for running the program to execute the microservice version management method described in the first aspect.
[0015] For the microservice version management method and device provided by the present application, in response to the existence of a target microservice with a version to be changed in the microservice cluster of an application program, the first configuration identification set corresponding to the current version of the target microservice and the second configuration identification set corresponding to the target version to be changed are determined, and based on the first configuration identification set and the second configuration identification set, the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version is determined. Then, based on the configuration information difference, the configuration information stored in the configuration center is changed so that the configuration information stored in the changed configuration center is the configuration information corresponding to the second configuration identification set. Finally, by the target microservice referring to the configuration information corresponding to the second configuration identification set, the target microservice is changed from the current version to the target version. It can be seen that in the solution provided by the embodiments of the present application, when a microservice in an application program is to be changed to a certain target version, as long as the configuration information difference between the current version and the target version is determined based on the configuration identification set of the current version and the configuration identification set of the target version of the microservice, the configuration information stored in the configuration center can be changed based on the configuration information difference, so that the changed configuration center stores all the configuration information corresponding to the configuration identification set of the target version. In this way, the microservice can accurately obtain the configuration information adapted to the target version of the microservice from the changed configuration center through the configuration identification set corresponding to the target version, thereby successfully completing the version change of the microservice.
[0016] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the specific embodiments of the present application are specifically listed below. Description of the Drawings
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0018] Figure 1 The flowchart of a microservice version control method provided by an embodiment of the present application is shown;
[0019] Figure 2 The schematic diagram of the configuration information difference between the configuration information corresponding to a target version and the configuration information corresponding to the current version provided by an embodiment of the present application is shown;
[0020] Figure 3 The structural schematic diagram of a microservice version control device provided by an embodiment of the present application is shown;
[0021] Figure 4 The structural schematic diagram of a microservice version control device provided by another embodiment of the present application is shown. Detailed implementation manners
[0022] Hereinafter, the exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be completely conveyed to those skilled in the art.
[0023] Currently, before changing the version of the microservices included in the application, it is necessary to modify the configuration information in the configuration table dedicated to recording the configuration information to be adapted to the version to which it is to be changed for use in changing the microservice version. However, the modification of the configuration table depends on developers to complete manually, and the manual modification process is cumbersome and error-prone. Problems such as incorrect modification and omission of configuration information often occur, resulting in the microservice being difficult to accurately obtain the configuration information adapted to the version to which it is to be changed, thus causing the failure of the microservice version change.
[0024] After research, it is found that if each version of the microservice has a corresponding set of configuration identifiers, and the microservice can reference the corresponding configuration information from the configuration center for storing the configuration information of the microservice based on the configuration identifiers included in the set of configuration identifiers, then when the microservice is to be changed to a certain target version, as long as the configuration information difference between the current version and the target version is determined based on the set of configuration identifiers of the current version and the set of configuration identifiers of the target version of the microservice, and the configuration information stored in the configuration center is changed based on the configuration information difference, so that the configuration center stores the configuration information corresponding to the set of configuration identifiers of the target version, then the microservice can reference the configuration information required by the target version from the changed configuration center, and thus the target microservice can be changed from the current version to the target version based on the referenced configuration information required by the target version. Based on this, in order to accurately obtain the configuration information adapted to the version to which the microservice is to be changed and perform version change on the microservice, the following two key technologies can be used: One is that the microservice is communicatively connected to the configuration center for storing the configuration information of the microservice. The other is that each version of the microservice has a corresponding set of configuration identifiers, and can reference the corresponding configuration information from the configuration center based on the configuration identifiers included in the set of configuration identifiers. Through the combination of these two technical implementations, when there is a target microservice with a version to be changed in the microservice cluster of the application program, only the configuration information stored in the configuration center needs to be changed so that the changed configuration center stores the configuration information corresponding to the set of configuration identifiers of the version to be changed, and then the configuration information corresponding to the set of configuration identifiers of the version to be changed can be referenced through the target microservice, and thus the configuration information adapted to the version to which the microservice is to be changed can be accurately obtained to perform version change on the microservice.
[0025] Based on the above findings, this embodiment specifically provides a technical solution for microservice version control, specifically: The microservice is communicatively connected to the configuration center, and the configuration center is used to store the configuration information of the microservice. Each version of the microservice has a corresponding set of configuration identifiers, and each configuration identifier in the set of configuration identifiers corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identifier. In response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program, determine the first set of configuration identifiers corresponding to the current version of the target microservice and the second set of configuration identifiers corresponding to the target version to be changed. Based on the first set of configuration identifiers and the second set of configuration identifiers, determine the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version. Based on the configuration information difference, change the configuration information stored in the configuration center so that the changed configuration center stores the configuration information corresponding to the second set of configuration identifiers. Through the target microservice referencing the configuration information corresponding to the second set of configuration identifiers, change the target microservice from the current version to the target version.
[0026] The technical solution for microservice version control provided in this embodiment can be applied to any microservice in any microservice cluster of an application based on the microservice architecture. This embodiment does not limit the types of the application and the microservice, and both can be flexibly selected according to business requirements.
[0027] Based on the above technical solution for microservice version control, this embodiment specifically provides a microservice version control method and apparatus. The following specifically describes the microservice version control method and apparatus provided in this embodiment.
[0028] The embodiment of the present application provides a microservice version control method. The microservice version control provided in this embodiment is used to accurately obtain the configuration information adapted to the version to which the microservice is to be changed and perform version change on the microservice. In order to accurately obtain the configuration information adapted to the version to which the microservice is to be changed and perform version change on the microservice, the following two processes are performed in this embodiment: First, the microservice is communicatively connected to the configuration center, and the configuration center is used to store the configuration information of the microservice. Second, each version of the microservice has a corresponding configuration identifier set, and each configuration identifier in the configuration identifier set corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identifier. Based on the above two processes, when there is a target microservice with a version to be changed in the microservice cluster of the application, only the configuration information stored in the configuration center needs to be changed so that the changed configuration center stores the configuration information corresponding to the configuration identifier set of the version to which it is to be changed, and then the configuration information corresponding to the configuration identifier set of the version to which it is to be changed can be referenced by the target microservice, so that the configuration information adapted to the version to which the microservice is to be changed can be accurately obtained to perform version change on the microservice.
[0029] Based on this, as Figure 1 shown, the microservice version control method provided in this embodiment can at least include the following steps 101 to 104:
[0030] 101. In response to the existence of a target microservice with a version to be changed in the microservice cluster of the application, determine a first configuration identifier set corresponding to the current version of the target microservice and a second configuration identifier set corresponding to the target version to which it is to be changed.
[0031] The microservice version control method provided in this embodiment is executed in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application. Therefore, the microservice version control method provided in this embodiment can also include the following monitoring steps: Monitor whether there is a target microservice with a version to be changed in the microservice cluster of the application. The implementation methods of this monitoring step can at least include the following Method 1 to Method 3:
[0032] Method 1: Monitor whether a version change instruction is received. If received, determine the microservice specified in the version change instruction as the target microservice to be changed in version, and determine the version specified in the version change instruction as the target version to which the target microservice is to be changed. It should be noted that the version specified in the version change instruction can include any of the following: First, the version specified in the version change instruction is lower than the current version of the target microservice, so as to change the target microservice to a lower version; Second, the version specified in the version change instruction is higher than the current version of the target microservice, so as to change the target microservice to a higher version.
[0033] Method 2: For each microservice in the microservice cluster of the application, execute respectively: Monitor whether the version publisher corresponding to the current microservice publishes a new version for the current microservice. If published, determine the current microservice as the target microservice to be changed in version, and determine the new version published for the current microservice as the target version to which the target microservice is to be changed.
[0034] Method 3: Monitor whether new microservices need to be added to the microservice cluster of the application. If new microservices need to be added, determine the new microservices to be added as the target microservices to be changed in version, and determine the selected version of the new microservices as the target version to which the target microservices are to be changed.
[0035] At least one of the above three methods for monitoring whether there are target microservices to be changed in version in the microservice cluster of the application can be selected based on business needs. When two or three methods are selected, the selected methods can be used simultaneously to more comprehensively and timely monitor whether there are target microservices to be changed in version in the microservice cluster of the application.
[0036] After determining the target microservices to be changed in version in the microservice cluster of the application, in response to the existence of target microservices to be changed in version in the microservice cluster of the application, determine the first configuration identification set corresponding to the current version of the target microservice and the second configuration identification set corresponding to the target version to which it is to be changed. The methods for determining the first configuration identification set corresponding to the current version of the target microservice and the second configuration identification set corresponding to the target version to which it is to be changed can at least include the following two:
[0037] One way is that the configuration identifiers corresponding to the configuration information required by each version of the microservice are built into the version code of the microservice of the corresponding version. Based on this, the first configuration identifier set is obtained by extracting the configuration identifiers corresponding to the current version from the version code of the current version of the target microservice, and the second configuration identifier set is obtained by extracting the configuration identifiers corresponding to the target version from the version code of the target version of the target microservice. Although the acquisition of the first configuration identifier set and the second configuration identifier set in this method intrudes on the corresponding version code, since it is extracted from the version code, the accuracy of the extracted first configuration identifier set and second identifier set is relatively high.
[0038] Another way is to store the configuration identifier sets corresponding to each version of each microservice in the microservice cluster at a specified storage location. Based on this, the first configuration identifier set corresponding to the current version of the target microservice and the second configuration identifier set corresponding to the target version to be changed are found at the specified storage location. In this method, the determination of the first configuration identifier set and the second configuration identifier set does not intrude on the corresponding version code, and since the first configuration identifier set and the second configuration identifier set are determined by looking up at the specified storage location, the determination efficiency of the first configuration identifier set and the second configuration identifier set can be improved.
[0039] At least one of the above two methods for determining the first configuration identifier set corresponding to the current version of the target microservice and the second configuration identifier set corresponding to the target version to be changed can be flexibly selected based on business needs. It should be noted that when two methods are selected, the first configuration identifier set and the second configuration identifier set determined by the two methods are mutually verified to improve the accuracy of the first configuration identifier set and the second configuration identifier set.
[0040] 102. Based on the first configuration identifier set and the second configuration identifier set, determine the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version.
[0041] The first configuration identifier set includes the configuration identifiers corresponding to the configuration information required by the current version of the target microservice, and the second configuration identifier set includes the configuration identifiers corresponding to the configuration information required by the target version of the target microservice. Based on this, based on the first configuration identifier set and the second configuration identifier set, the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version can be determined.
[0042] Based on the first set of configuration identifiers and the second set of configuration identifiers, the specific process of determining the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version may include the following steps: Compare the configuration identifiers included in the first set of configuration identifiers with the configuration identifiers included in the second set of configuration identifiers; If a first configuration identifier that exists in the first set of configuration identifiers but does not exist in the second set of configuration identifiers is found through the comparison, then determine the configuration information corresponding to the first configuration identifier as the configuration information with a difference between the current version and the target version, and indicate through the configuration information difference the configuration information corresponding to the first configuration identifier that does not exist in the first set of configuration identifiers but exists in the second set of configuration identifiers; If a second configuration identifier that does not exist in the first set of configuration identifiers but exists in the second set of configuration identifiers is found through the comparison, then determine the configuration information corresponding to the second configuration identifier as the configuration information with a difference between the current version and the target version, and indicate through the configuration information difference the configuration information corresponding to the second configuration identifier that exists in the first set of configuration identifiers but does not exist in the second set of configuration identifiers.
[0043] 103. Based on the configuration information difference, change the configuration information stored in the configuration center so that the changed configuration center stores the configuration information corresponding to the second set of configuration identifiers.
[0044] When a microservice runs in a certain version, the configuration information corresponding to that version must be stored in the configuration center to support the microservice running in that version through these configuration information. Based on this, the configuration information of the current version of the target microservice is stored in the configuration center to support the target microservice running in the current version through these configuration information.
[0045] Based on the configuration information difference, changing the configuration information stored in the configuration center is usually based on the configuration information of the current version stored in the configuration center, and the specific process of changing the configuration information stored in the configuration center based on the configuration information difference is related to the specific configuration information indicated by the configuration information difference. Based on this, the specific process of changing the configuration information stored in the configuration center based on the configuration information difference may include the following two types:
[0046] First, the specific process of changing the configuration information stored in the configuration center based on the configuration information difference may include the following steps: If the configuration information difference indicates the configuration information corresponding to the first configuration identifier that does not exist in the first set of configuration identifiers but exists in the second set of configuration identifiers, then incrementally store the configuration information corresponding to the first configuration identifier in the configuration center.
[0047] As Figure 2 shown, Figure 2 shows a schematic diagram of the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version. Figure 2The circle 1 in it is used to represent the configuration information corresponding to the first set of configuration identifiers of the current version, and the circle 2 is used to represent the configuration information corresponding to the second set of configuration identifiers of the target version. Figure 2 The white area "area A" inside the circle 2 in it is used to represent the configuration information corresponding to the first configuration identifier that does not exist in the first set of configuration identifiers indicated by the configuration information difference and exists in the second set of configuration identifiers.
[0048] The configuration information corresponding to the first configuration identifier that does not exist in the first set of configuration identifiers indicated by the configuration information difference and exists in the second set of configuration identifiers is the configuration information newly added by the target version relative to the current version. These configuration information are not currently stored in the configuration center, and the target microservice cannot reference these configuration information from the configuration center through the first configuration identifier. Based on this, the configuration information corresponding to the first configuration identifier is incrementally stored in the configuration center to enable the target microservice to reference these configuration information from the configuration center based on the first configuration identifier.
[0049] In some embodiments, the version of the microservice will be changed during both the development stage and the release stage of the application. Some configuration information in the development stage is only for debugging use and does not need to be released together with the application. Based on this, before the above-mentioned step of incrementally storing the configuration information corresponding to the first configuration identifier in the configuration center, the microservice version control method provided in this embodiment may further include the following steps: detecting whether there is configuration information with a first configuration annotation in the configuration information corresponding to the first configuration identifier, and the first configuration annotation is used to indicate that the configuration information is for microservice debugging use.
[0050] If it is detected that there is no configuration information with a first configuration annotation in the configuration information corresponding to the first configuration identifier, it means that the configuration information corresponding to the first configuration identifier is not the configuration information for microservice debugging use, but the configuration information for the release stage of the application. Therefore, the above step of "incrementally storing the configuration information corresponding to the first configuration identifier in the configuration center" is executed.
[0051] If it is detected that there is configuration information with a first configuration annotation in the configuration information corresponding to the first configuration identifier, then any one of the following operations A and B is performed on the configuration information with the first configuration annotation:
[0052] Operation A: Incrementally store the configuration information with the first configuration annotation in the debug configuration center. The debug configuration center is communicatively connected to the microservice during the application debugging stage and disconnects from the microservice when the application enters the release stage.
[0053] To prevent the configuration information used in the application debugging phase from interfering with the configuration information used in the application release phase, the configuration information with the first configuration annotation is incrementally stored in the debug configuration center. In this way, not only can the configuration information for the debugging phase be separated from the configuration information for the release phase, but also the microservice can reference the corresponding configuration information of the target version from the debug configuration center, without affecting the accurate acquisition of the configuration information adapted to the version to which the microservice is to be changed in the debugging phase for version change of the microservice.
[0054] Operation B: After incrementally storing the configuration information with the first configuration annotation in the configuration center in the above step, add a second configuration annotation to the configuration information with the first configuration annotation. The second configuration annotation is used to indicate that the configuration information is to be deleted from the configuration center when the application enters the release phase.
[0055] To prevent the configuration information used in the invocation phase from being released, after incrementally storing the configuration information with the first configuration annotation in the configuration center in the above step, add a second configuration annotation to the configuration information with the first configuration annotation, so that when the application enters the release phase, the configuration information only for the debugging phase is deleted from the configuration center based on the second configuration annotation, so that when entering the release phase, the configuration information stored in the configuration center is all for the release phase. The second configuration annotation can be determined based on business needs and is not limited in this embodiment. For example, the configuration information is marked with a field "present", and its meaning is used to indicate whether the configuration information is deleted in the release phase. If it needs to be deleted, assign "yes" to "present", and the form after assignment is "present: \"yes\"".
[0056] Second, the specific process of changing the configuration information stored in the configuration center based on the configuration information difference may include the following steps: If the configuration information difference indicates that there is configuration information corresponding to a second configuration identifier that exists in the first configuration identifier set and does not exist in the second configuration identifier set, then delete the configuration information corresponding to the second configuration identifier from the configuration center.
[0057] As Figure 2 shown, Figure 2 the black area "Area B" within the middle circle 1 is used to represent the configuration information corresponding to the second configuration identifier that exists in the first configuration identifier set and does not exist in the second configuration identifier set indicated by the configuration information difference.
[0058] The configuration information corresponding to the second configuration identifiers that exist in the first set of configuration identifiers indicated by the configuration information differences and do not exist in the second set of configuration identifiers is the configuration information for which the target version is different from the current version. These configuration information are the configuration information that the target version does not need, and these configuration information are currently stored in the configuration center. Based on this, in order to release the storage space of the configuration center and avoid confusion in the reference of configuration information caused by the existence of the configuration information corresponding to the second configuration identifiers, the configuration information corresponding to the second configuration identifiers is deleted from the configuration center.
[0059] In some embodiments, different microservices may use the same configuration information. In order to reduce the investment in the storage cost of the configuration center, these configuration information usually have the same configuration identifier. Based on this, before deleting the configuration information corresponding to the second configuration identifiers from the configuration center in the above steps, the microservice version control method provided in this embodiment may further include the following steps: searching for each second configuration identifier in the set of configuration identifiers of the current version of each microservice other than the target microservice in the microservice cluster; if a found second configuration identifier exists, configure that the configuration information corresponding to the found second configuration identifier cannot be deleted from the configuration center.
[0060] The configuration information corresponding to the second configuration identifiers may be used by microservices other than the target microservice in the microservice cluster. If the configuration information corresponding to the second configuration identifiers is deleted from the configuration information, it will affect the normal operation of these microservices. Based on this, it is necessary to search for each second configuration identifier in the set of configuration identifiers of the current version of each microservice other than the target microservice in the microservice cluster to clarify whether the configuration information corresponding to the second configuration identifiers is used by other microservices.
[0061] If no second configuration identifier is found in the set of configuration identifiers of the current version of each microservice other than the target microservice in the microservice cluster, it means that the configuration information corresponding to all second configuration identifiers is not used by other microservices in the microservice cluster. Therefore, in order to release the storage space of the configuration center and avoid confusion in the reference of configuration information caused by the existence of the configuration information corresponding to the second configuration identifiers, the step of deleting the configuration information corresponding to the second configuration identifiers from the configuration center is executed.
[0062] If a corresponding second configuration identifier is found in the set of configuration identifiers of the current version of each microservice other than the target microservice in the microservice cluster, it means that the configuration information corresponding to the found second configuration identifier is used by other microservices in the microservice cluster. Therefore, configure that the configuration information corresponding to the found second configuration identifier cannot be deleted from the configuration center to avoid the deletion of these configuration information from the configuration center.
[0063] For the above two specific processes of changing the configuration information stored in the configuration center based on the configuration information differences, they can be used according to the specific configuration information indicated by the configuration information differences, and this embodiment does not make any limitations in this regard. After changing the configuration information stored in the configuration center based on the configuration information differences, the changed configuration center stores the configuration information corresponding to the second configuration identifier set. In this way, the target microservice can accurately reference from the changed configuration center the configuration information adapted to the version to which the microservice is to be changed, so as to implement the version change of the target microservice.
[0064] 104. The target microservice references the configuration information corresponding to the second configuration identifier set, and changes the target microservice from the current version to the target version.
[0065] After changing the configuration information stored in the configuration center based on the configuration information differences, the changed configuration center stores the configuration information corresponding to the second configuration identifier set. In this way, the configuration center stores all the configuration information that supports the target microservice to be changed to the target version.
[0066] Based on this, in order to implement the change of the target microservice to the target version, the specific process of the target microservice referencing the configuration information corresponding to the second configuration identifier set may include the following steps: adjusting the target microservice to reference the configuration information corresponding to each configuration identifier in the second configuration identifier set from referencing the configuration information corresponding to each configuration identifier in the first configuration identifier set from the configuration center.
[0067] The method of adjusting the target microservice to reference the configuration information corresponding to each configuration identifier in the second configuration identifier set from referencing the configuration information corresponding to each configuration identifier in the first configuration identifier set from the configuration center may include the following two types:
[0068] One is to release the target microservice from referencing the configuration information corresponding to each configuration identifier in the first configuration identifier set from the configuration center, and control the target microservice to reference the configuration information corresponding to each configuration identifier in the second configuration identifier set from the configuration center. In this way, before the target microservice references the configuration information corresponding to each configuration identifier in the second configuration identifier set from the configuration center, the target microservice does not reference the configuration information from the configuration center, so the possibility of confusion and errors in the configuration information reference can be reduced.
[0069] Second, if the configuration information difference indicates that the configuration information corresponding to the first configuration identifier that does not exist in the first configuration identifier set but exists in the second configuration identifier set, then the target microservice is released from referring to the configuration information corresponding to each first configuration identifier in the first configuration identifier set in the configuration center. If the configuration information difference indicates that the configuration information corresponding to the second configuration identifier that exists in the first configuration identifier set but does not exist in the second configuration identifier set, then the target microservice is controlled to refer to the configuration information corresponding to each second configuration identifier in the second configuration identifier set in the configuration center. In this way, by fine-tuning the configuration information referred to by the target microservice from the configuration center, it is possible to quickly implement the target microservice referring to the configuration information corresponding to each configuration identifier in the second configuration identifier set in the configuration center.
[0070] The above two methods of adjusting the target microservice from referring to the configuration information corresponding to each configuration identifier in the first configuration identifier set in the configuration center to referring to the configuration information corresponding to each configuration identifier in the second configuration identifier set can be flexibly selected based on business needs, and this embodiment does not make any limitations in this regard.
[0071] After adjusting the target microservice from referring to the configuration information corresponding to each configuration identifier in the first configuration identifier set in the configuration center to referring to the configuration information corresponding to each configuration identifier in the second configuration identifier set, all the configuration information for supporting the target microservice to change from the current version to the target version is obtained. Therefore, the target microservice can be changed from the current version to the target version based on the configuration information corresponding to the second configuration identifier set that is referred to.
[0072] The specific process of changing the target microservice from the current version to the target version based on the configuration information corresponding to the second configuration identifier set that is referred to may include: determining the version change tool corresponding to the target microservice; calling the version change tool, and changing the target microservice from the current version to the target version through the configuration information corresponding to the second configuration identifier set referred to by the target microservice.
[0073] The microservice version control method provided by the embodiments of the present application, in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program, determines a first configuration identifier set corresponding to the current version of the target microservice and a second configuration identifier set corresponding to the target version to be changed, and based on the first configuration identifier set and the second configuration identifier set, determines the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version. Then, based on the configuration information difference, the configuration information stored in the configuration center is changed so that the changed configuration center stores the configuration information corresponding to the second configuration identifier set. Finally, the target microservice references the configuration information corresponding to the second configuration identifier set to change the target microservice from the current version to the target version. It can be seen that in the solution provided by the embodiments of the present application, when a microservice in an application program is to be changed to a certain target version, as long as the configuration information difference between the current version and the target version is determined based on the configuration identifier set of the current version and the configuration identifier set of the target version of the microservice, the configuration information stored in the configuration center can be changed based on the configuration information difference, so that the changed configuration center stores all the configuration information corresponding to the configuration identifier set of the target version. In this way, the microservice can accurately reference the configuration information adapted to the target version of the microservice from the changed configuration center through the configuration identifier set corresponding to the target version, thus successfully completing the version change of the microservice.
[0074] In some embodiments of the present application, the configuration center is used to store the configuration information of the microservice, and the microservice references the corresponding configuration information from the configuration center based on the configuration identifier corresponding to the configuration information. Based on this, the configuration center can store the configuration information of the microservice in a coded manner, so that the microservice can reference the corresponding configuration information from the configuration center based on the configuration identifier.
[0075] In some embodiments, the configuration center stores the configuration information corresponding to the configuration identifier in a preset structure to code the configuration information corresponding to the configuration identifier based on the preset structure. Specifically, the configuration identifier and the configuration information exist in the preset structure as key-value pairs. It should be noted that if there are corresponding configuration comments for the configuration information, there may also be corresponding configuration comments in the preset structure.
[0076] The preset structure can be selected based on business requirements, and this embodiment does not limit this. For example, the preset structure may include, but is not limited to, a structure defined in the golang language. There may be tags shown in Table-1 in the preset structure.
[0077] Table-1
[0078]
[0079] Exemplarily, based on the example in Table-1, the configuration center stores the following configuration information 1:
[0080] Configuration Information 1: QueueSize Item `key: "qlog.queue.size", value: "2048000", comment: "Queue size"`.
[0081] In the comment of the QueueSize field of Configuration Information 1, three types of tags are defined: "key", "value", and "comment". Among them, key is used to identify the configuration identifier, value is used to identify the configuration data, and comment is used to identify the configuration comment. The corresponding meaning of this Configuration Information 1 is: The configuration information 1 corresponding to the configuration label "qlog.queue.size" includes the configuration data "2048000" and the configuration comment "Queue size".
[0082] Exemplarily, the configuration center also stores the following Configuration Information 2:
[0083] Configuration Information 2: Level Item `key: value: "{{if.qlog_level}}{{.qlog_level}}{{else}}ALL{{end}}", comment: "Default log level"`.
[0084] In the comment of the Level field of Configuration Information 2, three types of tags are defined: "key", "value", and "comment". Among them, key is used to identify the configuration identifier, value is used to identify the configuration data, and comment is used to identify the configuration comment. The corresponding meaning of this Configuration Information 2 is: The configuration information 2 corresponding to the configuration label "qlog.log.level" includes the configuration data "{{if.qlog_level}}{{.qlog_level}}{{else}}ALL{{end}}" and the comment data "Default log level". {{if.qlog_level}}{{.qlog_level}}{{else}}ALL{{end}} is a template syntax expression based on the golang text / template library, and its meaning is: If the variable qlog_level appears when calculating the template, use the content of this variable as the log level; if it does not appear, use the value "ALL".
[0085] In some embodiments of the present application, after determining in step 101 above that there is a target microservice with a version to be changed in the microservice cluster of the application, the microservice version control method provided in this embodiment may further include the following steps: If it is determined that the target microservice is a microservice newly added to the microservice cluster, determine the first added version of the target microservice, and add all the configuration information corresponding to each configuration identifier included in the configuration identifier set corresponding to the first added version to the configuration center.
[0086] If it is determined that the target microservice is a microservice newly added to the microservice cluster, it is very likely that the configuration center does not store the configuration information of the target microservice. Therefore, determine the first added version of the target microservice, and add all the configuration information corresponding to each configuration identifier included in the configuration identifier set corresponding to the first added version to the configuration center, so that the target microservice can reference the configuration information corresponding to each configuration identifier included in the configuration identifier set corresponding to the first added version, and add the target microservice to the microservice cluster of the application based on the referenced configuration information, realizing the expansion of the microservice of the application.
[0087] In some embodiments of the present application, there may be the same third configuration identifier in the first configuration identifier set and the second configuration identifier set, that is, the third configuration identifier that exists in both the first configuration identifier set and the second configuration identifier set. Considering that the configuration information corresponding to the configuration identifier may change with the change of business requirements, based on this, the microservice version control method provided in this embodiment may further include the process: If after step 101 above, it is determined that there is a third configuration identifier that exists in both the first configuration identifier set and the second configuration identifier set, then for each third configuration identifier, perform the following steps respectively: Compare the configuration information of the current third configuration identifier in the current version and the target version. If it is compared that the two are the same, then maintain the storage of the configuration information of the current third configuration identifier in the current version in the configuration center. If it is compared that the two are different, then replace the configuration information of the current third configuration identifier in the current version stored in the configuration center with the configuration information of the current third configuration identifier in the target version.
[0088] As Figure 2 shown, Figure 2 the shaded area "Area C" in
[0089] is used to represent the configuration information corresponding to the third configuration identifier that exists in both the first configuration identifier set and the second configuration identifier set.
[0090] If it is found that the configuration information corresponding to the current third configuration identifier in the current version and the target version is different, it indicates that the configuration information corresponding to the current third configuration identifier has changed. Therefore, to ensure that the target microservice can reference the configuration information supporting the target version, the configuration information corresponding to the current third configuration identifier in the current version stored in the configuration center is replaced with the configuration information corresponding to the current third configuration identifier in the target version.
[0091] In some embodiments, considering that the configuration information corresponding to the current third configuration identifier is not only used by the target microservice, but may also be used by other microservices in the microservice cluster except the target microservice. If the configuration information corresponding to the current third configuration identifier is changed, it will affect the use of other microservices. Based on this, before replacing the configuration information corresponding to the current third configuration identifier in the current version stored in the configuration center with the configuration information corresponding to the current third configuration identifier in the target version, the microservice version control method provided in this embodiment may further include the following steps: If it is found that the configuration information corresponding to the current third configuration identifier in the current version and the target version is different, a replacement query is issued for the third configuration identifier, so that developers can determine whether to replace the configuration information corresponding to the current third configuration identifier in the current version stored in the configuration center with the configuration information corresponding to the current third configuration identifier in the target version based on the replacement query. For example, if it is determined that the configuration information corresponding to the current third configuration identifier still needs to be referenced by other microservices in the application program, and the configuration information corresponding to the current third configuration identifier in the target version is not applicable to other microservices, it is determined that the configuration information corresponding to the current third configuration identifier cannot be changed, and a rejection instruction for the replacement query is fed back. For example, if it is determined that the configuration information corresponding to the current third configuration identifier does not need to be referenced by other microservices in the application program, or it is determined that the configuration information corresponding to the current third configuration identifier in the target version is applicable to other microservices, it is determined that the configuration information corresponding to the current third configuration identifier can be changed, and an approval instruction for the replacement query is fed back to replace the configuration information corresponding to the current third configuration identifier in the current version stored in the configuration center with the configuration information corresponding to the current third configuration identifier in the target version.
[0092] If an approval instruction for the replacement query is received, the step of replacing the configuration information corresponding to the current third configuration identifier in the current version stored in the configuration center with the configuration information corresponding to the current third configuration identifier in the target version is executed. Thus, not only can the target microservice reference the configuration information adapted to the target version through the current third configuration identifier, but also other microservices can reference the replaced configuration information through the current third configuration identifier for the normal operation of other microservices.
[0093] If a rejection instruction for the replacement query is received, or if a confirmation instruction is not received within the target duration, the configuration information corresponding to the current third configuration identifier in the current version is maintained and stored in the configuration center, so that other microservices can continue to reference the configuration information corresponding to the current third configuration identifier for normal operation.
[0094] Furthermore, considering that the configuration information corresponding to the current third configuration identifier of the target version is applicable to the target version of the target microservice, if it is not added to the configuration center, it may cause the target microservice to not be able to change to the target version. Based on this, when a rejection instruction is received or a confirmation instruction is not received within the target duration, any of the following disposal operations can also be performed:
[0095] Operation 1: Incrementally store the configuration information corresponding to the current third configuration identifier in the target version in the configuration center, and set the configuration information corresponding to the current third configuration identifier in the target version to be of the private type for the target microservice, and set the reference priority of the configuration information of the private type for the target microservice to be higher than the configuration information corresponding to other third configuration identifiers stored in the configuration center. In this way, not only can it be ensured that other microservices can reference the adapted configuration information based on the third configuration identifier, but also it can be ensured that the target microservice can reference the configuration information adapted to the target version based on the third configuration information. It should be noted that after the target microservice references the configuration information with a high reference priority based on the third configuration identifier, it no longer references the other configuration information corresponding to the third configuration identifier from the configuration center.
[0096] Operation 2: Modify the current third configuration identifier of the target version to a configuration identifier that is different from the current third configuration identifier and has uniqueness, and incrementally add the configuration information corresponding to the modified configuration identifier to the configuration center for the target microservice to reference the corresponding configuration information based on the modified configuration identifier.
[0097] The above two disposal operations can be flexibly selected based on business needs, and this embodiment does not make any limitations in this regard.
[0098] In some embodiments of the present application, considering that the logs printed by microservices based on configuration information may lead to the leakage of sensitive data. Based on this, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center through the above step 103, the microservice version control method provided in this embodiment may further include the following steps: If it is determined that there is configuration information including target configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, a corresponding third configuration annotation is added to the configuration information including the target configuration data in the configuration center. The target configuration data is used to indicate that there is sensitive data in the logs printed based on the configuration information, and the third configuration annotation is used to indicate the desensitization rules for the microservice to process sensitive data, so as to desensitize the sensitive data based on the desensitization rules when the microservice references the configuration information to print logs.
[0099] If it is determined that there is configuration information including target configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, it indicates that printing logs by the microservice based on the configuration information including the target configuration data will cause the leakage of sensitive data. Based on this, a corresponding third configuration annotation is added to the configuration information including the target configuration data in the configuration center, so that when the microservice references the configuration information including the target configuration data to print logs, it can desensitize the sensitive data based on the desensitization rules indicated by the third configuration annotation, so as to prevent the sensitive data from leaking through the logs.
[0100] The desensitization rules for sensitive data can be flexibly selected according to business needs, and it can include but is not limited to at least one of the following: performing MD5 operation on sensitive data, replacing the characters at specified positions in sensitive data with preset symbols. The third configuration annotation can be flexibly set according to business needs, and this embodiment does not make any limitations in this regard. Exemplarily, for the field "desensitive" corresponding to the third configuration annotation, its field meaning indicates the desensitization rules for the microservice to process sensitive data, and the desensitization rule is the assignment of desensitive. For example, when the desensitization rule is md5, the third configuration annotation is "desensitive: \"md5\"".
[0101] In some embodiments of the present application, considering that the configuration data in some configuration information of microservices is data that needs to be kept confidential and cannot be leaked, and this configuration data usually exists in ciphertext form. In order to enable microservices to use this ciphertext configuration data, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center through the above step 103, the microservice version control method provided in this embodiment may further include the following steps: If it is determined that there is configuration information including ciphertext configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, then add a corresponding fourth configuration annotation in the configuration center for the configuration information including ciphertext configuration data. The fourth configuration annotation is used to indicate the decryption algorithm for the microservice to decrypt the ciphertext configuration data, so as to obtain the configuration data in plaintext form based on the decryption algorithm when the microservice references the configuration information.
[0102] If it is determined that there is configuration information including ciphertext configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, then in order to enable the microservice to normally use the ciphertext configuration data, add a corresponding fourth configuration annotation in the configuration center for the configuration information including ciphertext configuration data, so that when the microservice references the configuration information including ciphertext configuration data, it can decrypt the ciphertext configuration data based on the decryption algorithm indicated by the fourth configuration annotation to obtain the configuration data in plaintext form for use. In practical applications, the decryption algorithm corresponds to the encryption algorithm used when forming the ciphertext with the ciphertext configuration data to ensure that the microservice can successfully decrypt the ciphertext configuration data to obtain the plaintext configuration data.
[0103] In some embodiments of the present application, a microservice usually includes multiple functional modules. Based on this, the configuration information stored in the configuration center at least includes a common type, and the configuration information of the common type is the configuration information that multiple functional modules in the same microservice depend on.
[0104] Based on this, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center through the above step 103, the microservice version control method provided in this embodiment may further include the following steps: If it is determined that there is configuration information that is dependent on by multiple functional modules in the target microservice among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, then set the corresponding configuration information as the common type for multiple functional modules included in the microservice to reference. This can at least achieve the following effect: The configuration information that is dependent on by multiple functional modules in the target microservice is set as the common type. In this way, the target microservice can simultaneously reference the corresponding configuration information for multiple functional modules based on the configuration identifier, that is, the target microservice can reference it once based on the configuration identifier and enable multiple functional modules to reference the corresponding configuration information, thereby improving the efficiency of the microservice in referencing configuration information.
[0105] The configuration information relied on by multiple functional modules in the target microservice can be set based on business requirements, and this embodiment does not limit this. Exemplarily, the configuration information relied on by multiple functional modules in the target microservice may include, but is not limited to, account password configuration information.
[0106] In some embodiments of the present application, the configuration information stored in the configuration center at least includes a global type and a private type. The configuration information of the global type is the configuration information relied on by all microservices in the microservice cluster, and the configuration information of the private type is the configuration information relied on by specified types of microservices in the microservice cluster. It should be noted that the specified types can be at least one, and each specified type has a corresponding private type.
[0107] Based on this, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center through the above step 103, the microservice version control method provided in this embodiment may further include the following steps: If it is determined that there is configuration information that belongs to both the global type and the private type among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, then set the reference priority of the corresponding configuration information in the private type to be higher than that in the global type.
[0108] If there is configuration information that belongs to both the global type and the private type among the configuration information corresponding to the configuration identifier, then the configuration information belonging to the global type and the configuration information belonging to the private type may have completely different configuration information, or they include at least some identical configuration items, and the configuration data of at least some of these identical configuration items are different. For the configuration identifier whose corresponding configuration information has configuration information that belongs to both the global type and the private type, when the microservice references the corresponding configuration information based on this configuration identifier, it is very likely to reference the configuration information belonging to both the global type and the private type at the same time, which may lead to reference confusion. Therefore, for the configuration information corresponding to this configuration identifier, it is necessary to set the reference priority of the corresponding configuration information in the private type to be higher than that in the global type, so that the microservice can preferentially reference the configuration information of the private type for use. Exemplarily, there is configuration information belonging to the global type and configuration information belonging to the private type in the configuration information corresponding to configuration identifier 1, and except for the configuration data of the configuration item "log level" being different in the two configuration items, the configuration data of other configuration items are the same. The configuration data of the "log level" of the configuration information belonging to the global type is "WARN", and the configuration data of the "log level" of the configuration information belonging to the private type is "DEBUG". When the microservice references, it preferentially references the configuration information with the configuration data of the "log level" being "DEBUG" based on the reference priority, so that the log level generated by the microservice is "DEBUG".
[0109] In some embodiments, the specific process of a target microservice referring to the configuration information corresponding to the second set of configuration identifiers may be as follows: For each configuration identifier included in the second set of configuration identifiers, the following steps are respectively executed: Refer to the configuration information with a higher reference priority from the configuration information corresponding to the current configuration identifier stored in the configuration center.
[0110] In some embodiments, further, before referring to the configuration information with a higher reference priority from the configuration information corresponding to the current configuration identifier stored in the configuration center, the microservice version control method provided in this embodiment may further include the following steps: Detect whether the functional module of the microservice referring to the configuration information based on the current configuration identifier is a functional module for determining a specified type of microservice; if so, execute the step of referring to the configuration information with a higher reference priority from the configuration information corresponding to the current configuration identifier stored in the configuration center; if not, refer to the global type of configuration information from the configuration information corresponding to the current configuration identifier stored in the configuration center.
[0111] In some embodiments, the configuration center manages the global type and private type of configuration information through namespaces. Exemplarily, the global type of configuration information is named "global.go", and the private type of configuration information is named "*.go", where "*.go" is used to indicate the naming rule of the private type of configuration information, and the symbol "*" can be replaced with any string that meets the business needs based on the business needs.
[0112] In some embodiments of the present application, in order to enable a microservice to refer to the corresponding configuration information from the configuration center based on a configuration identifier, each microservice in the microservice cluster of the application program has a target interface respectively. The target interface is used to enable the microservice to refer to the corresponding configuration information from the configuration center based on the configuration identifier through the target reference method, and when there is a configuration identifier for which the configuration information has not been successfully referred to, use the second default configuration information as the configuration information referred to by the corresponding configuration identifier.
[0113] Both the type of the target interface and the target reference method are related to the storage form of the configuration information in the configuration center. Exemplarily, if the configuration center stores the configuration information corresponding to the configuration identifier in the form of a structure defined in the golang language, the target interface is the Confer interface, and the target reference method is the String() method. Exemplarily, the Confer interface can be defined as follows: type Confer interface{String(key string)string}.
[0114] In practical applications, when a microservice references configuration information from a configuration center based on a configuration identifier, it may happen that the configuration information cannot be referenced due to some exceptions. In order to still be able to implement the microservice to change to the version to be changed in such a situation, the target interface also needs to have the function of using the second default configuration information as the configuration information referenced by the corresponding configuration identifier when there is a configuration identifier for which the configuration information has not been successfully referenced, so that the microservice can be supported to successfully change to the version to be changed based on the second default configuration information and other successfully referenced configuration information. The second default configuration data is data that can implement the version change of the microservice, and its specific data can be flexibly selected based on business needs.
[0115] Further, an embodiment of the present application also provides a microservice version control device. The microservice is communicatively connected to a configuration center, and the configuration center is used to store the configuration information of the microservice. Each version of the microservice has a corresponding set of configuration identifiers, and each configuration identifier in the set of configuration identifiers corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identifier, as Figure 3 shown, the microservice version control device provided in this embodiment may at least include:
[0116] A first determination module 21, configured to determine a first set of configuration identifiers corresponding to the current version of the target microservice and a second set of configuration identifiers corresponding to the target version to be changed in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program;
[0117] A second determination module 22, configured to determine the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version based on the first set of configuration identifiers and the second set of configuration identifiers;
[0118] A first change module 23, configured to change the configuration information stored in the configuration center based on the configuration information difference, so that the configuration information corresponding to the second set of configuration identifiers is stored in the changed configuration center;
[0119] A second change module 24, configured to change the target microservice from the current version to the target version by the target microservice referencing the configuration information corresponding to the second set of configuration identifiers.
[0120] The microservice version control device provided by the embodiment of the present application, in response to the existence of a target microservice with a version to be changed in the microservice cluster of the application program, determines a first configuration identifier set corresponding to the current version of the target microservice and a second configuration identifier set corresponding to the target version to which it is to be changed, and based on the first configuration identifier set and the second configuration identifier set, determines the configuration information difference between the configuration information corresponding to the target version and the configuration information corresponding to the current version. Then, based on the configuration information difference, the configuration information stored in the configuration center is changed so that the configuration center after the change stores the configuration information corresponding to the second configuration identifier set. Finally, the target microservice references the configuration information corresponding to the second configuration identifier set, and changes the target microservice from the current version to the target version. It can be seen that in the solution provided by the embodiment of the present application, when a microservice in an application program is to be changed to a certain target version, as long as the configuration information difference between the current version and the target version is determined based on the configuration identifier set of the current version and the configuration identifier set of the target version of the microservice, the configuration information stored in the configuration center can be changed based on the configuration information difference, so that the configuration center after the change stores all the configuration information corresponding to the configuration identifier set of the target version. In this way, the microservice can accurately reference the configuration information adapted to the target version of the microservice from the configuration center after the change through the configuration identifier set corresponding to the target version, thus successfully completing the version change of the microservice.
[0121] In some embodiments of the present application, as Figure 4 shown, the configuration information of the current version of the target microservice is stored in the configuration center. The second change module 24 is specifically configured to change the configuration information corresponding to each configuration identifier in the first configuration identifier set referenced by the target microservice from the configuration center to the configuration information corresponding to each configuration identifier in the second configuration identifier set.
[0122] In some embodiments of the present application, as Figure 4 shown, the first change module 23 includes:
[0123] The first change unit 231 is configured to, if the configuration information difference indicates that the configuration information corresponding to the first configuration identifier that does not exist in the first configuration identifier set and exists in the second configuration identifier set, incrementally store the configuration information corresponding to the first configuration identifier in the configuration center;
[0124] The second change unit 232 is configured to, if the configuration information difference indicates that the configuration information corresponding to the second configuration identifier that exists in the first configuration identifier set and does not exist in the second configuration identifier set, delete the configuration information corresponding to the second configuration identifier from the configuration center.
[0125] In some embodiments of the present application, as Figure 4As shown, the first change module 23 may further include:
[0126] A first detection unit 233, configured to detect whether there is configuration information with a first configuration annotation in the configuration information corresponding to the first configuration identifier before the first change unit 231 incrementally stores the configuration information corresponding to the first configuration identifier into the configuration center, where the first configuration annotation is used to indicate that the configuration information is for microservice debugging; if so, perform any of the following operations on the configuration information with the first configuration annotation: trigger the third change unit 234 to incrementally store the configuration information with the first configuration annotation into the debugging configuration center, where the debugging configuration center is communicatively connected to the microservice during the application debugging phase and disconnects from the microservice when the application enters the release phase; or, trigger the adding unit 235 to add a second configuration annotation to the configuration information with the first configuration annotation after the first change unit 231 incrementally stores the configuration information with the first configuration annotation into the configuration center, where the second configuration annotation is used to indicate that the configuration information is to be deleted from the configuration center when the application enters the release phase.
[0127] In some embodiments of the present application, as Figure 4 shown, the first change module 23 may further include:
[0128] A second detection unit 236, configured to look up each of the second configuration identifiers in the current version configuration identifier sets of each microservice other than the target microservice in the microservice cluster before the second change unit 232 deletes the configuration information corresponding to the second configuration identifier from the configuration center; if a found second configuration identifier exists, trigger the configuration unit 237 to configure the configuration information corresponding to the found second configuration identifier not to be deletable from the configuration center.
[0129] In some embodiments of the present application, as Figure 4 shown, the microservice version control device provided in this embodiment may further include:
[0130] A third change module 25, configured to, if it is determined that there are third configuration identifiers that exist in both the first configuration identifier set and the second configuration identifier set, perform the following for each of the third configuration identifiers: compare the configuration information corresponding to the third configuration identifier in the current version and the target version, if it is compared that the two are the same, then maintain the storage of the configuration information corresponding to the third configuration identifier in the current version in the configuration center, if it is compared that the two are different, then replace the configuration information corresponding to the third configuration identifier in the current version that has been stored in the configuration center with the configuration information corresponding to the third configuration identifier in the target version.
[0131] In some embodiments of the present application, as Figure 4As shown, the third change module 25 can also be used to issue a replacement query for the third configuration identifier if it is compared that the two are different; if a confirmation instruction for the replacement query is received, execute the step of replacing the configuration information corresponding to the third configuration identifier stored in the configuration center in the corresponding configuration information of the current version with the configuration information corresponding to the third configuration identifier in the target version; if a rejection instruction for the replacement query is received, or the confirmation instruction is not received within the target duration, maintain the storage of the configuration information corresponding to the third configuration identifier in the current version in the configuration center.
[0132] In some embodiments of the present application, as Figure 4 shown, the configuration information stored in the configuration center at least includes a global type and a private type. The configuration information of the global type is the configuration information relied on by all microservices in the microservice cluster, and the configuration information of the private type is the configuration information relied on by the specified type of microservices in the microservice cluster.
[0133] Then, the microservice version control device provided in this embodiment may further include: a first configuration module 26, configured to, after the first change module 23 changes the configuration information corresponding to each configuration identifier included in the second configuration identifier set stored in the configuration center, if it is determined that there is configuration information that belongs to both the global type and the private type among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, set the reference priority of the corresponding configuration information in the private type to be higher than that in the global type.
[0134] In some embodiments of the present application, as Figure 4 shown, the microservice includes multiple functional modules, and the configuration information stored in the configuration center at least includes a public type. The configuration information of the public type is the configuration information relied on by multiple functional modules in the same microservice.
[0135] Then, the microservice version control device provided in this embodiment may further include: a second configuration module 27, after the first change module 23 changes the configuration information corresponding to each configuration identifier included in the second configuration identifier set stored in the configuration center, if it is determined that there is configuration information relied on by multiple functional modules in the target microservice among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, set the corresponding configuration information to the public type for multiple functional modules included in the microservice to reference.
[0136] In some embodiments of the present application, as Figure 4As shown in the figure, the microservice version control device provided in this embodiment may further include: a third configuration module 28, configured to, after the first change module 23 changes the configuration information corresponding to each configuration identifier included in the second configuration identifier set stored in the configuration center, if it is determined that there is configuration information including target configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, add a corresponding third configuration annotation to the configuration information including the target configuration data in the configuration center, where the target configuration data is used to indicate that sensitive data exists in the log printed based on the configuration information, and the third configuration annotation is used to indicate the desensitization rule for the microservice to process sensitive data, so as to desensitize the sensitive data based on the desensitization rule when the microservice references the configuration information to print the log.
[0137] In some embodiments of the present application, as Figure 4 As shown in the figure, the microservice version control device provided in this embodiment may further include: a fourth configuration module 29, configured to, after the first change module 23 changes the configuration information corresponding to each configuration identifier included in the second configuration identifier set stored in the configuration center, if it is determined that there is configuration information including ciphertext configuration data among the configuration information corresponding to the configuration identifiers included in the second configuration identifier set, add a corresponding fourth configuration annotation to the configuration information including the ciphertext configuration data in the configuration center, where the fourth configuration annotation is used to indicate the decryption algorithm for the microservice to decrypt the ciphertext configuration data, so as to decrypt the ciphertext configuration data based on the decryption algorithm to obtain the configuration data in plaintext form when the microservice references the configuration information.
[0138] In some embodiments of the present application, the configuration center in this embodiment stores the configuration information corresponding to the configuration identifier in a preset structure, and the configuration identifier and the configuration information exist in the preset structure in a key-value pair; wherein, the preset structure includes a structure defined in the golang language.
[0139] In some embodiments of the present application, each microservice in the application in this embodiment respectively has a target interface, where the target interface is used to implement that the microservice references the corresponding configuration information from the configuration center based on the configuration identifier through the target reference method, and when there is a configuration identifier for which the configuration information cannot be successfully referenced, the second default configuration information is used as the configuration information referenced by the corresponding configuration identifier.
[0140] In some embodiments of the present application, the microservice version control device provided in this embodiment may further include:
[0141] An adding module 30 is used to, after a first determination module 21 determines that there is a target microservice with a version to be changed in a microservice cluster of an application, if it is determined that the target microservice is a microservice newly added to the microservice cluster, determine the first added version of the target microservice, and add all the configuration information corresponding to each configuration identifier included in the configuration identifier set corresponding to the first added version to the configuration center.
[0142] In the microservice version control device provided by the embodiments of the present application, the detailed explanations adopted during the operation of each functional module can refer to the corresponding explanations in the embodiments of the microservice version control method above, and will not be elaborated here.
[0143] Furthermore, an embodiment of the present application further provides a computer-readable storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the above microservice version control method.
[0144] Furthermore, an embodiment of the present application further provides an electronic device, where the electronic device includes: a memory for storing a program; a processor coupled to the memory for running the program to execute the above microservice version control method.
[0145] In the above embodiments, the descriptions of each embodiment have their own focuses. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0146] It can be understood that the relevant features in the above methods and devices can be referred to each other. In addition, the "first", "second", etc. in the above embodiments are used to distinguish each embodiment, and do not represent the advantages and disadvantages of each embodiment.
[0147] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated here.
[0148] The algorithms and displays provided herein are not inherently related to any specific computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The structure required to construct such a system is obvious from the above description. In addition, the present application is not directed to any specific programming language. It should be understood that the content of the present application described herein can be implemented using various programming languages, and the description of a specific language above is to disclose the preferred embodiments of the present application.
[0149] In addition, the memory may include non-permanent memory in the form of 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.
[0150] Those skilled in the art will appreciate that the embodiments of the present application may be provided as a method, system, or computer program product. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented 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.
[0151] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce means for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.
[0152] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.
[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are performed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.
[0154] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0155] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0156] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0157] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0158] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0159] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A microservice version control method, characterized in that: The microservice is in communication connection with a configuration center, the configuration center is used to store configuration information of the microservice, each version of the microservice has a corresponding configuration identification set, each configuration identification in the configuration identification set corresponds to corresponding configuration information, the microservice references the corresponding configuration information from the configuration center based on the configuration identification, and the method includes: In response to the existence of a target microservice of a to-be-changed version in the microservice cluster of the application, determining a first configuration identifier set corresponding to a current version of the target microservice and a second configuration identifier set corresponding to a target version to be changed; Determine, based on the first configuration identifier set and the second configuration identifier set, configuration information differences between the configuration information corresponding to the target version and the configuration information corresponding to the current version; Based on the configuration information difference, the configuration information stored in the configuration center is changed so that the changed configuration center stores the configuration information corresponding to the second configuration identifier set; The target microservice is changed from the current version to the target version by referencing the configuration information corresponding to the second configuration identifier set by the target microservice.
2. The method according to claim 1, characterized in that The configuration center stores the configuration information of the current version of the target microservice, and the configuration information corresponding to the second configuration identifier set is referenced by the target microservice, including: The target microservice references configuration information corresponding to each configuration identifier in the first configuration identifier set from the configuration center, and adjusts the reference to configuration information corresponding to each configuration identifier in the second configuration identifier set.
3. The method according to claim 2, characterized in that Based on the configuration information difference, the configuration information stored in the configuration center is changed, including: If the configuration information difference indicates that the configuration information corresponding to the first configuration identifier does not exist in the first configuration identifier set and exists in the second configuration identifier set, then incrementally storing the configuration information corresponding to the first configuration identifier in the configuration center; If the configuration information difference indicates configuration information corresponding to the second configuration identifier that exists in the first configuration identifier set but does not exist in the second configuration identifier set, the configuration information corresponding to the second configuration identifier is deleted from the configuration center.
4. The method according to claim 3, characterized in that Before storing the configuration information corresponding to the first configuration identifier incrementally to the configuration center, the method further includes: detecting whether there is configuration information with a first configuration annotation in the configuration information corresponding to the first configuration identifier, the first configuration annotation being used to indicate that the configuration information is for microservice debugging; if so, performing any of the following operations on the configuration information with the first configuration annotation: storing the configuration information with the first configuration annotation incrementally to a debugging configuration center, the debugging configuration center being connected to the microservice in communication during the application debugging phase, and disconnecting the communication connection with the microservice when the application enters the release phase; or, after storing the configuration information with the first configuration annotation incrementally to the configuration center, adding a second configuration annotation to the configuration information with the first configuration annotation, the second configuration annotation being used to indicate that the configuration information is deleted from the configuration center when the application enters the release phase; and / or, Before deleting the configuration information corresponding to the second configuration identifier from the configuration center, the method further includes: searching for each second configuration identifier in the configuration identifier set of the current version of each microservice other than the target microservice in the microservice cluster; if the found second configuration identifier exists, the configuration information corresponding to the found second configuration identifier cannot be deleted from the configuration center.
5. The method according to claim 2, characterized in that: The method further comprises: If a third configuration identifier is determined to exist in both the first configuration identifier set and the second configuration identifier set, the following is performed for each third configuration identifier: the configuration information corresponding to the third configuration identifier in the current version and the target version is compared; if the comparison shows that the two are the same, the configuration information corresponding to the third configuration identifier in the current version is maintained and stored in the configuration center; if the comparison shows that the two are different, the configuration information corresponding to the third configuration identifier in the current version stored in the configuration center is replaced with the configuration information corresponding to the third configuration identifier in the target version.
6. The method according to claim 5, characterized in that The method further comprises: If the comparison shows that the two are different, a replacement query is issued for the third configuration identifier; If a confirmation instruction for the replacement query is received, a step of replacing the configuration information corresponding to the third configuration identifier in the current version stored in the configuration center with the configuration information corresponding to the third configuration identifier in the target version is executed; If a rejection instruction for the replacement inquiry is received, or the confirmation instruction is not received within the target time period, the configuration information corresponding to the third configuration identifier in the current version is maintained and stored in the configuration center.
7. The method according to any one of claims 2 to 6, characterized in that: The configuration information stored in the configuration center includes at least global type and private type. The global type of configuration information is the configuration information that all microservices in the microservice cluster depend on, and the private type of configuration information is the configuration information that microservices of a specified type in the microservice cluster depend on; Then, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center, the method further includes: if it is determined that there is configuration information of a global type and a private type in the configuration information corresponding to the configuration identifier included in the second configuration identifier set, setting the reference priority of the corresponding configuration information in the private type to be higher than that of the global type; and / or, The microservice includes multiple functional modules, and the configuration information stored in the configuration center includes at least a common type, and the common type of configuration information is configuration information that multiple functional modules in the same microservice rely on; Then, after storing the configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center, the method further includes: if it is determined that the configuration information corresponding to the configuration identifier included in the second configuration identifier set includes configuration information relied on by multiple functional modules in the target microservice, setting the corresponding configuration information as a public type for reference by the multiple functional modules included in the microservice; and / or, After storing configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center, the method further includes: if it is determined that configuration information corresponding to the configuration identifiers included in the second configuration identifier set includes configuration information including target configuration data, adding a corresponding third configuration annotation to the configuration information including the target configuration data in the configuration center, wherein the target configuration data is used to indicate that sensitive data exists in the log printed based on the configuration information, and the third configuration annotation is used to indicate a desensitization rule for microservices to process sensitive data, so that the sensitive data is desensitized based on the desensitization rule when the microservice references the configuration information to print the log; and / or, After storing configuration information corresponding to each configuration identifier included in the second configuration identifier set in the configuration center, the method further includes: if it is determined that configuration information corresponding to the configuration identifier included in the second configuration identifier set includes configuration information including ciphertext configuration data, adding a corresponding fourth configuration annotation to the configuration information including the ciphertext configuration data in the configuration center, wherein the fourth configuration annotation is used to indicate a decryption algorithm for decrypting the ciphertext configuration data by the microservice, so that when the microservice references the configuration information, the ciphertext configuration data is decrypted based on the decryption algorithm to obtain the configuration data in plain text; and / or, The configuration center stores configuration information corresponding to the configuration identifier in a preset structure, and the configuration identifier and the configuration information exist in the preset structure as a key-value pair; wherein the preset structure includes a structure defined in the golang language; and / or, Each microservice in the application has a target interface, and the target interface is used to enable the microservice to reference corresponding configuration information from the configuration center based on the configuration identifier through a target reference method, and when there is a configuration identifier that fails to successfully reference the configuration information, the second default configuration information is used as the configuration information referenced by the corresponding configuration identifier.
8. The method according to any one of claims 1 to 6, characterized in that After determining that there is a target microservice whose version is to be changed in the microservice cluster of the application, the method further includes: If it is determined that the target microservice is a microservice that is added to the microservice cluster for the first time, the first added version of the target microservice is determined, and all configuration information corresponding to each configuration identifier included in the configuration identifier set corresponding to the first added version is added to the configuration center.
9. A microservice version control device, characterized in that: The microservice is connected to the configuration center for communication. The configuration center is used to store the configuration information of the microservice. Each version of the microservice has a corresponding configuration identification set. Each configuration identification in the configuration identification set corresponds to the corresponding configuration information. The microservice references the corresponding configuration information from the configuration center based on the configuration identification. The device includes: A first determination module is used to determine, in response to the existence of a target microservice of a to-be-changed version in the microservice cluster of the application, a first configuration identification set corresponding to a current version of the target microservice and a second configuration identification set corresponding to a target version to be changed; A second determining module, configured to determine, based on the first configuration identification set and the second configuration identification set, configuration information differences between the configuration information corresponding to the target version and the configuration information corresponding to the current version; A first changing module, configured to change the configuration information stored in the configuration center based on the configuration information difference, so that the changed configuration center stores the configuration information corresponding to the second configuration identifier set; The second changing module is used to change the target microservice from the current version to the target version by referring to the configuration information corresponding to the second configuration identifier set by the target microservice.
10. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the microservice version control method described in any one of claims 1 to 8.
11. An electronic device, characterized in that: The electronic device comprises: Memory, used to store programs; A processor, coupled to the memory, is used to run the program to execute the microservice version control method described in any one of claims 1 to 8.