A method and apparatus for restarting a cloud service

By detecting the consistency of the version identification of the configuration information in the container management system, and automatically restarting the cloud service, the problem of low efficiency of configuration information update is solved, automatic update is realized, and operation and maintenance costs are reduced.

CN113010266BActive Publication Date: 2025-07-25BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110287738.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-17
Publication Date
2025-07-25
Estimated Expiration
2041-03-17

AI Technical Summary

Technical Problem

In the container management system, the update efficiency of configuration information is low, which can easily lead to untimely or incorrect updates, and does not conform to the devops concept, requiring higher operation and maintenance costs.

Method used

By obtaining the first version identification of the configuration information stored in the database and the second version identification of the configuration information of the cloud service running in the container management system, check whether the two are consistent, and automatically restart the cloud service when inconsistent, to achieve automatic update of the configuration information.

Benefits of technology

It improves the efficiency of update of configuration information in the container management system, reduces manual intervention, conforms to the devops concept, and reduces operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113010266B_ABST
    Figure CN113010266B_ABST
Patent Text Reader

Abstract

The present application relates to a method and apparatus for restarting a cloud service. The method includes: obtaining a first version identifier of configuration information stored in a database and a second version identifier of configuration information used on a cloud service running in a container management system; detecting whether the first version identifier is consistent with the second version identifier; and restarting the cloud service running in the container management system when it is detected that the second version identifier is inconsistent with the first version identifier. The present application solves the technical problem of low update efficiency of configuration information running in the container management system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular, to a method and device for restarting cloud services. Background Art

[0002] In a container management system (kubernetes), a configuration dictionary (configmap) is often used to store configuration files of a program, such as the port of a service and the service address, etc. The configuration in the configmap can be used as an environment variable for easy modification. After modification, restarting the service can complete the update without modifying the code of the service program. Currently, microservices are used to develop services, which will result in many services in a system. Placing all configurations in a single file is also convenient for management. However, this approach will bring a problem, that is, after updating the configuration file, it is often forgotten to update, or because there are too many services involved, it is not known which services need to be updated, or only some of the services are updated when updating the services.

[0003] Currently in kubernetes technology, restarting the service after configuration update by manually updating the service is still not very secure and has the following drawbacks: First, the service update is not timely, and it is impossible to ensure that all services are completely updated, and there may be misoperations. It requires higher operation and maintenance costs and the operation of operation and maintenance personnel. In addition, it does not conform to the devops concept. Services should be deployed and updated as automated as possible, and the part of manual intervention should be minimized as much as possible, so that the program can automatically update the corresponding service after detecting changes.

[0004] In response to the above problems, no effective solution has been proposed yet. Summary of the Invention

[0005] The present application provides a method and device for restarting cloud services to at least solve the technical problem of low update efficiency of configuration information running in a container management system in related technologies.

[0006] According to one aspect of the embodiments of the present application, a method for restarting a cloud service is provided, including:

[0007] Obtaining a first version identifier of configuration information stored in a database and a second version identifier of configuration information used on a cloud service running in a container management system;

[0008] Detecting whether the first version identifier is consistent with the second version identifier;

[0009] When it is detected that the second version identifier is inconsistent with the first version identifier, restarting the cloud service running in the container management system.

[0010] Optionally, obtaining the first version identifier of the configuration information stored in the database and the second version identifier of the configuration information used on the cloud service running in the container management system includes:

[0011] Reading the first version identifier of the configuration information from the database every target time;

[0012] Reading the second version identifier of the configuration information from the container management system.

[0013] Optionally, in the case where it is detected that the second version identifier is inconsistent with the first version identifier, restarting the cloud service running in the container management system includes:

[0014] In the case where it is detected that the second version identifier is inconsistent with the first version identifier, determining a first cloud service to be updated among the cloud services running in the container management system;

[0015] Restarting the first cloud service.

[0016] Optionally, obtaining the first cloud service to be updated from the cloud services running in the container management system includes:

[0017] Determining target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system;

[0018] Obtaining a second cloud service that uses the target configuration information from the cloud services running in the container management system;

[0019] Obtaining the cloud service corresponding to the target service identifier from the second cloud service as the first cloud service, where the target service identifier is used to indicate the cloud service allowed to be updated.

[0020] Optionally, before obtaining the first version identifier of the configuration information stored in the database, the method further includes:

[0021] In the case where it is determined that the first configuration information stored in the database is updated to the second configuration information, assigning a version identifier to the second configuration information;

[0022] In the case where it is determined that the third configuration information is added to the database, assigning a version identifier to the third configuration information.

[0023] Optionally, before assigning a version identifier to the second configuration information or assigning a version identifier to the third configuration information, the method further includes:

[0024] Receive the notification information sent by the code repository, where the notification information is used to indicate that the first configuration information is updated to the second configuration information, or the third configuration information is added to the code repository, and the database includes the code repository.

[0025] Optionally, allocating a version identifier for the second configuration information, or allocating a version identifier for the third configuration information includes:

[0026] The controller responds to the notification information to generate a version identifier for the second configuration information, or generate a version identifier for the third configuration information, where the code repository is used to receive the second configuration information or the third configuration information submitted by the user account and send the notification information to the controller;

[0027] The controller sends the version identifier generated for the second configuration information, or the version identifier generated for the third configuration information to the code repository.

[0028] Optionally, after restarting the cloud service running in the container management system, the method further includes:

[0029] In the case where the restart of the cloud service running in the container management system fails, restart the cloud service running in the container management system regularly;

[0030] In the case where the process of restarting again reaches the target state, stop restarting the cloud service running in the container management system.

[0031] Optionally, in the case where the process of restarting again reaches the target state, stopping the restart of the cloud service running in the container management system includes:

[0032] In the case where the restart is successful, stop restarting the cloud service running in the container management system and send a first prompt message, where the first prompt message is used to prompt that the restart of the cloud service running in the container management system is successful;

[0033] In the case where the process of restarting again reaches the preset condition, but the cloud service running in the container management system still fails to restart successfully, stop restarting the cloud service running in the container management system and send a second prompt message, where the second prompt message is used to prompt that the restart of the cloud service running in the container management system fails.

[0034] According to another aspect of the embodiments of the present application, there is also provided a restart device for a cloud service, including:

[0035] An acquisition module, configured to acquire a first version identifier of configuration information stored in a database, and a second version identifier of configuration information used on a cloud service running in a container management system;

[0036] A detection module, configured to detect whether the first version identifier is consistent with the second version identifier;

[0037] A restart module, configured to restart the cloud service running in the container management system when it is detected that the second version identifier is inconsistent with the first version identifier.

[0038] According to another aspect of the embodiments of the present application, there is also provided a storage medium, which includes a stored program that executes the above method when the program runs.

[0039] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the above method through the computer program.

[0040] In the embodiments of the present application, a first version identifier of configuration information stored in a database and a second version identifier of configuration information used on a cloud service running in a container management system are acquired; it is detected whether the first version identifier is consistent with the second version identifier; when it is detected that the second version identifier is inconsistent with the first version identifier, the cloud service running in the container management system is restarted. In this way, it is detected whether the first version identifier of the configuration information in the database is consistent with the second version identifier of the configuration information used on the container management system, so as to automatically restart the cloud service in the case of inconsistent version identifiers, automatically detect the cloud services that need to be updated according to the different version identifiers of the new version configuration information and the old version configuration information, and automatically restart and update the cloud services, thereby achieving the technical effect of improving the update efficiency of the configuration information running in the container management system, and further solving the technical problem of the low update efficiency of the configuration information running in the container management system. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0042] 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 accompanying drawings required for describing the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0043] Figure 1Schematic diagram of the hardware environment of the cloud service restart method according to an embodiment of the present application;

[0044] Figure 2 Flowchart of an alternative cloud service restart method according to an embodiment of the present application;

[0045] Figure 3 Schematic diagram of a cloud service restart process according to an alternative embodiment of the present application;

[0046] Figure 4 Schematic diagram of an alternative cloud service restart device according to an embodiment of the present application;

[0047] Figure 5 Block diagram of the structure of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0048] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0049] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0050] According to one aspect of the embodiments of the present application, an embodiment of a method for restarting a cloud service is provided.

[0051] Optionally, in this embodiment, the above-mentioned cloud service restart method can be applied to a hardware environment composed of a database 101 and a container management system 103 as shown in Figure 1 As shown in Figure 1As shown in the figure, the container management system 103 is connected to the database 101 through a network, and the above network includes but is not limited to: wide area network, metropolitan area network or local area network. The database 101 is used to store the configuration information used by the cloud services running in the container management system 103. The restart method of the cloud service in the embodiment of the present application can be executed by the container management system 103.

[0052] Figure 2 is a flowchart of an optional method for restarting a cloud service according to an embodiment of the present application. As Figure 2 shown, the method may include the following steps:

[0053] Step S202, obtain the first version identifier of the configuration information stored in the database, and the second version identifier of the configuration information used on the cloud service running in the container management system;

[0054] Step S204, detect whether the first version identifier is consistent with the second version identifier;

[0055] Step S206, in the case where it is detected that the second version identifier is inconsistent with the first version identifier, restart the cloud service running in the container management system.

[0056] Through the above steps S202 to S206, it is detected whether the first version identifier of the configuration information in the database is consistent with the second version identifier of the configuration information used on the container management system, so as to automatically restart the cloud service for the case where the version identifiers are inconsistent, and automatically detect the cloud service that needs to be updated according to the different version identifiers of the new version configuration information and the old version configuration information, and automatically restart and update the cloud service, thereby achieving the technical effect of improving the update efficiency of the configuration information running in the container management system, and further solving the technical problem of the low update efficiency of the configuration information running in the container management system.

[0057] In the technical solution provided in step S202, the configuration information stored in the database may be, but is not limited to, the configuration information in the form of a configmap configuration file.

[0058] Optionally, in this embodiment, the user may, but is not limited to, submit configuration information to the database through document tools such as gitlab, or perform operations such as modifying, deleting, and querying the configuration information in the database.

[0059] Optionally, in this embodiment, the above database may include, but is not limited to, various services with code storage functions, such as: code repository, cloud server, distributed storage system, etc.

[0060] As an alternative embodiment, obtaining the first version identifier of the configuration information stored in the database and the second version identifier of the configuration information used on the cloud service running in the container management system includes:

[0061] S11, reading the first version identifier of the configuration information from the database every target time;

[0062] S12, reading the second version identifier of the configuration information from the container management system.

[0063] Optionally, in this embodiment, it is possible but not limited to periodically detect whether the running version of the configuration information is the latest version through a customizer configured in the container management system.

[0064] Optionally, in this embodiment, the target time can be but is not limited to any preset time interval, such as: 1 second, 2 seconds, 5 seconds, etc.

[0065] As an alternative embodiment, before obtaining the first version identifier of the configuration information stored in the database, it further includes:

[0066] S21, when determining that the first configuration information stored in the database is updated to the second configuration information, assigning a version identifier to the second configuration information;

[0067] S22, when determining that the third configuration information is added to the database, assigning a version identifier to the third configuration information.

[0068] Optionally, in this embodiment, when the configuration information in the database is updated, or when new configuration information is added to the database, the latest version identifier can be assigned to the latest configuration information. Thus, it reflects the need for the cloud service to be synchronously updated when the configuration information is updated.

[0069] Optionally, in this embodiment, the method of assigning a version identifier to the new configuration information can be but is not limited to generating an md5 value for each configuration file (configmap), and the md5 will change as long as it is updated or modified, etc.

[0070] As an alternative embodiment, before assigning a version identifier to the second configuration information or assigning a version identifier to the third configuration information, it further includes:

[0071] S31, receiving a notification message sent by the code repository, where the notification message is used to indicate that the first configuration information is updated to the second configuration information, or the third configuration information is added to the code repository, and the database includes the code repository.

[0072] Optionally, in this embodiment, the update or modification of the configuration information may, but is not limited to, be actively notified to the container management system by the code repository by sending notification information.

[0073] Optionally, in this embodiment, the form of the notification information may, but is not limited to, include sending a notification to the container management system through an informer.

[0074] As an alternative embodiment, assigning a version identifier to the second configuration information, or assigning a version identifier to the third configuration information includes:

[0075] S41, in response to the notification information, the controller generates a version identifier for the second configuration information, or generates a version identifier for the third configuration information, where the code repository is used to receive the second configuration information or the third configuration information submitted by the user account and send the notification information to the controller;

[0076] S42, the controller sends the version identifier generated for the second configuration information, or the version identifier generated for the third configuration information, to the code repository.

[0077] Optionally, in this embodiment, a version identifier for the configuration information may be generated, but is not limited to, by a controller in the container management system. Then, the controller sends the generated version identifier to the code repository for recording.

[0078] In the technical solution provided in step S204, it may, but is not limited to, be detected by the controller whether the first version identifier is the same as the second version identifier.

[0079] Optionally, in this embodiment, the method for detecting whether the first version identifier is the same as the second version identifier may, but is not limited to, include a string matching method and the like.

[0080] In the technical solution provided in step S206, if it is detected that the second version identifier is not the same as the first version identifier, the cloud services running in the container management system are automatically restarted to achieve automatic update of the cloud services when the configuration information is updated.

[0081] Optionally, in this embodiment, the restarted cloud services may, but are not limited to, be all the cloud services running in the container management system, or may also be all the cloud services running in the container management system that use the configuration information with inconsistent version identifiers, or may further be some of the cloud services running in the container management system that use the configuration information with inconsistent version identifiers.

[0082] As an alternative embodiment, when it is detected that the second version identifier is inconsistent with the first version identifier, restarting the cloud services running in the container management system includes:

[0083] S51, when it is detected that the second version identifier is inconsistent with the first version identifier, determine a first cloud service to be updated among the cloud services running in the container management system;

[0084] S52, restart the first cloud service.

[0085] Optionally, in this embodiment, if it is detected that the second version identifier is inconsistent with the first version identifier, the first cloud service to be updated among the cloud services running in the container management system can be first determined, and the first cloud service can be restarted.

[0086] Optionally, in this embodiment, the first cloud service can be, but is not limited to, all or part of the cloud services that use configuration information with inconsistent service identifiers among the cloud services running in the container management system.

[0087] As an alternative embodiment, obtaining the first cloud service to be updated from the cloud services running in the container management system includes:

[0088] S61, determine target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system;

[0089] S62, obtain a second cloud service that uses the target configuration information from the cloud services running in the container management system;

[0090] S63, obtain the cloud service corresponding to the target service identifier from the second cloud service as the first cloud service, where the target service identifier is used to indicate the cloud service allowed to be updated.

[0091] Optionally, in this embodiment, first find the target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system, then find the second cloud service that uses the target configuration information from the cloud services running in the container management system, and then find the part that overlaps with the cloud service allowed to be updated from the second cloud service as the first cloud service.

[0092] Optionally, in this embodiment, the target service identifier is used to indicate the cloud service allowed to be updated. That is to say, when restarting the cloud services, not all the running cloud services are restarted, nor are all the cloud services that use configuration information with inconsistent version identifiers restarted. The impact of the restart operation can be preset within a certain range.

[0093] Optionally, in this embodiment, if it is detected that the configmap identifiers of all services are inconsistent and modifications are made, since the configmap adopts a centralized management method, it may cause a large-scale service restart, affecting the service quality. The scope affected by modifying the configuration file can be added (that is, setting which services need to be updated), and then when the controller checks for updates, only the services that meet both the scope of action and the configmap identifier are restarted and updated, and other services are not processed. In this way, the services that need to be updated can be updated more targeted, preventing the situation where all services are updated because only the configuration of one service is modified.

[0094] Optionally, in this embodiment, if each service is to be updated separately, its own version information can be set for each service. This version information can be a pre-agreed version, such as v1.1, or it can be a random code automatically generated each time the code is built. For example, a random code is automatically generated each time code is submitted to GitLab. The pre-agreed version number of each service can be given in the configuration file, or alternatively, the random code generated by the code submission of GitLab can be used as the service identifier.

[0095] As an alternative embodiment, after restarting the cloud service running in the container management system, it further includes:

[0096] S71, when the restart of the cloud service running in the container management system fails, restart the cloud service running in the container management system at regular intervals;

[0097] S72, when the process of restarting again reaches the target state, stop restarting the cloud service running in the container management system.

[0098] Optionally, in this embodiment, if the restart fails, it can be retried at regular intervals, and when a certain target state is reached during the retry process, the restart is stopped.

[0099] Optionally, in this embodiment, the time interval for retrying can be determined by an algorithm, and the calculated time interval can gradually become longer.

[0100] Optionally, in this embodiment, when the process of restarting again reaches the target state, the restart of the cloud service running in the container management system can be stopped. The result of the retry can be that the service is updated to conform to the latest configuration and the update is successful. It can also be that even if the update fails to succeed, the update operation can be exited. For example: it can be restarted continuously until the restart is successful before stopping, or certain requirements such as a certain restart time and the number of restarts can also be set. When the set requirements are reached but the restart still fails to succeed, the restart operation will also be stopped.

[0101] As an alternative embodiment, when the restart process reaches the target state, stopping the restart of the cloud services running in the container management system includes:

[0102] S81, when the restart is successful, stopping the restart of the cloud services running in the container management system and sending a first prompt message, where the first prompt message is used to prompt that the restart of the cloud services running in the container management system is successful;

[0103] S82, when the restart process reaches a preset condition but the cloud services running in the container management system have not been restarted successfully yet, stopping the restart of the cloud services running in the container management system and sending a second prompt message, where the second prompt message is used to prompt that the restart of the cloud services running in the container management system fails.

[0104] Optionally, in this embodiment, if the restart is successful, a message indicating successful restart can also be prompted by sending a first prompt message.

[0105] Optionally, in this embodiment, the restart process reaching a preset condition may include, but is not limited to, the number of restarts exceeding a preset number, or the restart process timing out, etc.

[0106] Optionally, in this embodiment, if the restart process reaches a preset condition but the cloud services running in the container management system still cannot be restarted successfully, when stopping the restart, an alarm for the restart failure can also be sent by sending a second prompt message, and the second prompt message can also carry information such as the reason for the restart failure and the reason for exiting the restart process.

[0107] This application also provides an alternative embodiment, which provides a process of monitoring the configmap update in a controller manner to complete the automatic restart and upgrade of cloud services. Figure 3 It is a schematic diagram of the restart process of a cloud service according to an alternative embodiment of this application, as Figure 3As shown in the figure, first, the user updates the configmap configuration file. When the service needs to add or modify the configuration, the user can modify the configmap on tools such as GitLab, and then submit the modified configmap file to the code repository. After submitting to the code repository, a custom controller will be triggered by sending a notification through the informer. Next, the controller will receive the service update message, generate a version identification information corresponding to the configmap and assign it to the updated configmap in the code repository. This version identification information is recorded in the code repository as the expected configmap version status. There is a customizer inside the controller that checks the actual configmap version status (i.e., the version identification of the configmap actually running in the system) and the expected configmap version status (i.e., the currently expected configmap version identification, for example, if the user updates the configmap, it is the updated version identification) every few seconds. If it is found that the configmap of the currently running cloud service is inconsistent with the expected configmap version identification, indicating that the configmap has changed, the controller will find the corresponding service and restart it.

[0108] In the above process, the update of the configmap is monitored through the controller method to complete the automatic restart and upgrade of the cloud service. Without too much manual intervention, the entire update is completely automated. The controller will continuously adjust (Reconcile) the configmap from the actual version status to the expected version status, and the controller will ensure that the update is successful. If it is not successful, the controller will keep retrying until it succeeds. This processing method is more in line with the concept of cloud native, completely solving the problems of incorrect service updates or missed service updates caused by manual operations, and being able to reduce the cost of service operation and maintenance. If the scale of the service cluster is large, manual operation for updates requires the participation of many operation and maintenance related personnel.

[0109] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be in other sequences or carried out simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential for this application.

[0110] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing an electronic device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0111] According to another aspect of the embodiments of the present application, there is also provided a cloud service restart device for implementing the above-mentioned cloud service restart method. Figure 4 is a schematic diagram of an optional cloud service restart device according to an embodiment of the present application, as Figure 4 shown. The device may include:

[0112] An obtaining module 42, configured to obtain a first version identifier of configuration information stored in a database, and a second version identifier of configuration information used on a cloud service running in a container management system;

[0113] A detecting module 44, configured to detect whether the first version identifier is consistent with the second version identifier;

[0114] A restart module 46, configured to restart the cloud service running in the container management system when it is detected that the second version identifier is inconsistent with the first version identifier.

[0115] It should be noted that the obtaining module 42 in this embodiment can be used to execute step S202 in the embodiments of the present application, the detecting module 44 in this embodiment can be used to execute step S204 in the embodiments of the present application, and the restart module 46 in this embodiment can be used to execute step S206 in the embodiments of the present application.

[0116] Here, it should be noted that the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in a hardware environment as Figure 1 shown, and can be implemented by software or by hardware.

[0117] Through the above module, it is detected whether the first version identifier of the configuration information in the database is consistent with the second version identifier of the configuration information used on the container management system, so as to automatically restart the cloud service in the case of inconsistent version identifiers, automatically detect the cloud services that need to be updated according to the different version identifiers of the new version configuration information and the old version configuration information, and automatically restart and update the cloud services, thus achieving the technical effect of improving the update efficiency of the configuration information running in the container management system, and further solving the technical problem of the low update efficiency of the configuration information running in the container management system.

[0118] As an optional embodiment, the obtaining module includes:

[0119] A first reading unit, configured to read the first version identifier of the configuration information from the database every target time;

[0120] A second reading unit, configured to read the second version identifier of the configuration information from the container management system.

[0121] As an optional embodiment, the restart module includes:

[0122] An obtaining unit, configured to determine a first cloud service to be updated in the cloud services running in the container management system when it is detected that the second version identifier is inconsistent with the first version identifier;

[0123] A restart unit, configured to restart the first cloud service.

[0124] As an optional embodiment, the obtaining unit is configured to:

[0125] Determine target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system;

[0126] Obtain a second cloud service that uses the target configuration information from the cloud services running in the container management system;

[0127] Obtain the cloud service corresponding to the target service identifier from the second cloud service as the first cloud service, where the target service identifier is used to indicate the cloud service allowed to be updated.

[0128] As an optional embodiment, the device further includes:

[0129] A first allocation module, configured to allocate a version identifier to the second configuration information in the case of determining that the first configuration information stored in the database is updated to the second configuration information before obtaining the first version identifier of the configuration information stored in the database;

[0130] A second allocation module, configured to allocate a version identifier to the third configuration information when it is determined that the third configuration information has been added to the database.

[0131] As an optional embodiment, the apparatus further includes:

[0132] A receiving module, configured to receive notification information sent by a code repository before allocating a version identifier to the second configuration information or allocating a version identifier to the third configuration information, where the notification information is used to indicate that the first configuration information is updated to the second configuration information, or the third configuration information is added to the code repository, and the database includes the code repository.

[0133] As an optional embodiment, the first allocation module, or the second allocation module includes:

[0134] A generating unit, configured to generate a version identifier for the second configuration information or generate a version identifier for the third configuration information by a controller in response to the notification information, where the code repository is configured to receive the second configuration information or the third configuration information submitted by a user account and send the notification information to the controller;

[0135] A sending unit, configured to send, by the controller, the version identifier generated for the second configuration information or the version identifier generated for the third configuration information to the code repository.

[0136] As an optional embodiment, the apparatus further includes:

[0137] A retry module, configured to, after restarting a cloud service running in the container management system, if the restart of the cloud service running in the container management system fails, periodically restart the cloud service running in the container management system again;

[0138] A stopping module, configured to stop restarting the cloud service running in the container management system when the process of restarting again reaches a target state.

[0139] As an optional embodiment, the stopping module includes:

[0140] A first processing unit, configured to, when the restart is successful again, stop restarting the cloud service running in the container management system and send a first prompt message, where the first prompt message is used to prompt that the restart of the cloud service running in the container management system is successful;

[0141] A second processing unit, configured to stop restarting the cloud service running in the container management system and send a second prompt message when the restart process reaches a preset condition but the cloud service running in the container management system has not been successfully restarted, where the second prompt message is used to prompt that the restart of the cloud service running in the container management system fails.

[0142] It should be noted here that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in the hardware environment as shown in Figure 1 shown, and can be implemented by software or by hardware, where the hardware environment includes a network environment.

[0143] According to another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above-mentioned method for restarting a cloud service.

[0144] Figure 5 is a structural block diagram of an electronic device according to an embodiment of the present application. As shown in Figure 5 shown, the electronic device may include: one or more (only one is shown in the figure) processors 501, a memory 503, and a transmission device 505. As shown in Figure 5 shown, the electronic device may further include an input / output device 507.

[0145] Among them, the memory 503 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for restarting a cloud service in the embodiments of the present application. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 503, that is, implements the above-mentioned method for restarting a cloud service. The memory 503 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, a flash memory, or other non-volatile solid-state memories. In some instances, the memory 503 may further include a memory remotely disposed relative to the processor 501, and these remote memories may be connected to the electronic device through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0146] The above-mentioned transmission device 505 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network can include a wired network and a wireless network. In one example, the transmission device 505 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers through a network cable, so as to communicate with the Internet or a local area network. In one example, the transmission device 505 is a Radio Frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0147] Specifically, the memory 503 is used to store application programs.

[0148] The processor 501 can call the application program stored in the memory 503 through the transmission device 505 to execute the following steps:

[0149] Obtain the first version identifier of the configuration information stored in the database and the second version identifier of the configuration information used on the cloud service running in the container management system;

[0150] Detect whether the first version identifier is consistent with the second version identifier;

[0151] In the case where it is detected that the second version identifier is inconsistent with the first version identifier, restart the cloud service running in the container management system.

[0152] By adopting the embodiment of the present application, a solution for restarting a cloud service is provided. Detect whether the first version identifier of the configuration information in the database is consistent with the second version identifier of the configuration information used on the container management system, so as to automatically restart the cloud service in the case of inconsistent version identifiers, automatically detect the cloud services that need to be updated according to the different version identifiers of the new version configuration information and the old version configuration information, and automatically restart and update the cloud service, thereby achieving the technical effect of improving the update efficiency of the configuration information running in the container management system, and further solving the technical problem of the low update efficiency of the configuration information running in the container management system.

[0153] Optionally, the specific examples in this embodiment can refer to the examples described in the above embodiments, and this embodiment will not be elaborated here.

[0154] Those of ordinary skill in the art can understand that Figure 5 The structure shown is only schematic, and the electronic device can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a Mobile Internet Devices (MID), a PAD and other electronic devices. Figure 5It does not limit the structure of the above-mentioned electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, a display device, etc.) than those shown in Figure 5 , or have a different configuration from that shown in Figure 5 .

[0155] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware of the electronic device through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.

[0156] An embodiment of the present application also provides a storage medium. Optionally, in this embodiment, the above storage medium may be used to execute the program code of the cloud service restart method.

[0157] Optionally, in this embodiment, the above storage medium may be located on at least one of the multiple network devices in the network shown in the above embodiment.

[0158] Optionally, in this embodiment, the storage medium is set to store program code for performing the following steps:

[0159] Obtain the first version identifier of the configuration information stored in the database and the second version identifier of the configuration information used on the cloud service running in the container management system;

[0160] Detect whether the first version identifier is consistent with the second version identifier;

[0161] In the case where it is detected that the second version identifier is inconsistent with the first version identifier, restart the cloud service running in the container management system.

[0162] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments, and details are not repeated here.

[0163] Optionally, in this embodiment, the above storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc, etc., which are various media that can store program code.

[0164] The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments.

[0165] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage media. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0166] In the above embodiments of this application, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0167] In the several embodiments provided by this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in electrical or other forms.

[0168] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0169] In addition, the functional units in the various embodiments of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0170] The above are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of this application.

Claims

1. A method for restarting a cloud service, characterized in that, Including: Obtaining a first version identifier of configuration information stored in a database and a second version identifier of configuration information used on a cloud service running in a container management system; Detecting whether the first version identifier is consistent with the second version identifier; In the case where it is detected that the second version identifier is inconsistent with the first version identifier, restarting the cloud service running in the container management system, including: in the case where it is detected that the second version identifier is inconsistent with the first version identifier, determining a first cloud service to be updated among the cloud services running in the container management system; restarting the first cloud service; Obtaining the first cloud service to be updated from the cloud services running in the container management system includes: determining target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system; obtaining a second cloud service using the target configuration information from the cloud services running in the container management system; obtaining, as the first cloud service, the cloud service corresponding to a target service identifier from the second cloud service, where the target service identifier is used to indicate a cloud service allowed to be updated.

2. The method according to claim 1, wherein Obtaining the first version identifier of the configuration information stored in the database and the second version identifier of the configuration information used on the cloud services running in the container management system includes: Reading the first version identifier of the configuration information from the database every target time; Reading the second version identifier of the configuration information from the container management system.

3. The method according to claim 1, wherein Before obtaining the first version identifier of the configuration information stored in the database, the method further includes: In the case where it is determined that the first configuration information stored in the database is updated to second configuration information, assigning a version identifier to the second configuration information; In the case where it is determined that third configuration information is added to the database, assigning a version identifier to the third configuration information.

4. The method according to claim 3, wherein Before assigning a version identifier to the second configuration information or to the third configuration information, the method further includes: Receiving notification information sent by a code repository, where the notification information is used to indicate that the first configuration information is updated to the second configuration information, or that the third configuration information is added to the code repository, and the database includes the code repository.

5. The method according to claim 4, wherein Assigning a version identifier to the second configuration information or to the third configuration information includes: Generating, by a controller in response to the notification information, a version identifier for the second configuration information or a version identifier for the third configuration information, where the code repository is used to receive the second configuration information or the third configuration information submitted by a user account and send the notification information to the controller; Sending, by the controller, the version identifier generated for the second configuration information or the version identifier generated for the third configuration information to the code repository.

6. The method according to claim 1, characterized in that, After restarting the cloud service running in the container management system, the method further includes: In the case where the restart of the cloud service running in the container management system fails, restart the cloud service running in the container management system at regular intervals; In the case where the restart process reaches the target state, stop restarting the cloud service running in the container management system.

7. The method according to claim 6, wherein In the case where the restart process reaches the target state, stopping the restart of the cloud service running in the container management system includes: In the case where the restart is successful, stop restarting the cloud service running in the container management system and send a first prompt message, where the first prompt message is used to prompt that the restart of the cloud service running in the container management system is successful; In the case where the restart process reaches a preset condition, but the cloud service running in the container management system has not been restarted successfully, stop restarting the cloud service running in the container management system and send a second prompt message, where the second prompt message is used to prompt that the restart of the cloud service running in the container management system fails.

8. A restart device for cloud services, characterized in that, including: An acquisition module, configured to acquire a first version identifier of the configuration information stored in the database, and a second version identifier of the configuration information used on the cloud service running in the container management system; A detection module, configured to detect whether the first version identifier is consistent with the second version identifier; A restart module, configured to restart the cloud service running in the container management system in the case where it is detected that the second version identifier is inconsistent with the first version identifier, including: in the case where it is detected that the second version identifier is inconsistent with the first version identifier, determining a first cloud service to be updated among the cloud services running in the container management system; restarting the first cloud service; obtaining the first cloud service to be updated from the cloud services running in the container management system includes: determining target configuration information with inconsistent version identifiers from the configuration information used on the cloud services running in the container management system; obtaining a second cloud service using the target configuration information from the cloud services running in the container management system; obtaining the cloud service corresponding to the target service identifier from the second cloud service as the first cloud service, where the target service identifier is used to indicate the cloud service allowed to be updated.

9. A storage medium, characterized in that, The storage medium includes a stored program, where the program, when running, executes the method described in any one of claims 1 to 7 above.

10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the method described in any one of claims 1 to 7 above through the computer program.

Citation Information

Patent Citations

  • Micro-service state detection method and device, electronic equipment and storage medium

    CN112486629A