Updating configuration file method, configuration server, version control server and system
By configuring the server to automatically detect and update configuration file modification events in the version control server, the problem of inconsistent configuration file updates in the microservice architecture is solved, and automatic update and efficient management of configuration files are realized.
Patent Information
- Application Number
- CN201910472915.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-31
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2039-05-31
AI Technical Summary
In microservice architecture, configuration file updates usually require manual management by developers, resulting in inconsistent applications and configuration files, and manual management brings higher risks.
By configuring the server to detect the modification events of the configuration file in the version control server, automatically obtain and update the configuration files of the container to ensure automatic update and consistency of the configuration files.
Automatic update of configuration files is realized, avoiding the risk of inconsistency between applications and configuration files caused by manual management, and improving the management efficiency and consistency of configuration files.
Smart Images

Figure CN112099836B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software technology, and more specifically, to a method for updating a configuration file, a configuration server, a version control server and a system. Background Art
[0002] In computer applications, configuration files determine the behavior of applications in specific environments, specific times, and specific clusters. A flexible and scalable application often has many configuration items, such as information about application listening ports, available memory, data and log storage addresses, and the IP addresses and ports of other applications it depends on. During the development and production process, these configurations often change due to changes in the environment or customer needs, and even need to be restored after just a change. Obtaining the latest configuration files for applications has become a daunting challenge for developers.
[0003] In the era of microservice architecture, each microservice is usually deployed in the form of a container. In the most commonly used distributed cluster management systems (such as Kubernetes clusters), the main way for applications to obtain configuration files is to mount the configuration files in the host machine to the container running the application. In the container cluster management system, configuration servers and hosts can be included, and each host machine is a node. Each host machine can include one or more containers, and each container runs an application.
[0004] The configuration file can be saved in the host machine of the container. When the container is started, the configuration file stored in the host machine is mounted into the container.
[0005] When updating the configuration file, the configuration file can be modified on the configuration server, and the developer needs to manually control the configuration server to distribute the modified configuration file to the corresponding host in the distributed cluster. However, manually controlling the configuration file update by the developer may cause inconsistency between the application and the configuration file. Summary of the invention
[0006] An object of the present invention is to provide a new technical solution for a method of updating a configuration file.
[0007] According to a first aspect of the present invention, a method for updating a configuration file is provided, the method being implemented by a configuration server, the method comprising:
[0008] Detecting an event that a configuration file pre-stored in a version control server is modified;
[0009] Determining, according to a detection result of the event, a storage address of the modified configuration file in the version control server;
[0010] According to the storage address, obtaining the modified configuration file from the version control server;
[0011] The modified configuration file is sent to the manager of the container corresponding to the storage address to mount and update the configuration file of the container.
[0012] Optionally, the event includes any one or more of the following:
[0013] Receiving a notification from the version control server that the configuration file has been modified;
[0014] The result obtained by comparing the configuration file at the current moment with the configuration file at the previous moment is that there is a difference;
[0015] The last modification time of the configuration file has changed.
[0016] Optionally, the event includes: receiving a notification sent by the version control server that the configuration file has been modified; and the step of determining a storage address of the modified configuration file in the version control server includes:
[0017] A storage address associated with a webhook that receives the notification is determined.
[0018] Optionally, the method further comprises:
[0019] Generate and send an update instruction to the manager, so that the manager can mount and update the configuration file of the container according to the update instruction.
[0020] Optionally, the method further comprises:
[0021] Detecting whether the container corresponding to the storage address is pre-configured with an automatic update function;
[0022] In the case where the container is pre-configured with an automatic update function, the step of sending the modified configuration file to the administrator of the container is performed.
[0023] Optionally, the method further comprises:
[0024] In response to the release of the resource object, recording the corresponding relationship between itself contained in the resource object and the storage address;
[0025] receiving a correspondence between the container and the resource object sent by the manager; wherein the correspondence between the container and the resource object is sent by the manager when publishing an application running in the container;
[0026] According to the corresponding relationship between the storage address and the resource object, and the corresponding relationship between the container and the resource object, a container corresponding to the storage address is determined.
[0027] Optionally, the method further comprises:
[0028] In response to a rollback operation on the configuration file, obtaining a rollback version number of the configuration file;
[0029] According to the rollback version number and the storage address, obtaining a configuration file corresponding to the rollback version number from the version control server;
[0030] The configuration file corresponding to the rollback version number is sent to the administrator to perform the mount rollback of the configuration file of the container.
[0031] Optionally, the method further comprises:
[0032] The modified configuration file is stored in a local cache, so that when a request for obtaining the modified configuration file is received, the modified configuration file in the local cache is sent to the manager of the container that sends the request for mounting.
[0033] Optionally, the method further comprises:
[0034] Receiving a feature value sent by the version control server, the feature value being obtained by the version control server performing feature calculation processing on the modified configuration file according to a preset information-digest algorithm;
[0035] The characteristic value is sent to the administrator to verify the integrity of the received configuration file.
[0036] According to a second aspect of the present invention, a method for updating a configuration file is provided, the method being implemented by a version control server, the method comprising:
[0037] In response to a modification operation on a pre-stored configuration file, a notification that the configuration file has been modified is sent to a configuration server so that the configuration server can detect whether the configuration file has been modified.
[0038] Optionally, the step of sending a notification includes:
[0039] Determining a network hook associated with a storage address of the configuration file;
[0040] A notification of modification of the configuration file is sent to the configuration server through the network hook.
[0041] Optionally, the method further comprises:
[0042] Performing feature calculation processing on the modified configuration file according to a preset information-digest algorithm to obtain a feature value;
[0043] The characteristic value is sent to a configuration server.
[0044] According to a third aspect of the present invention, a configuration server is provided, comprising a first processor and a first memory, wherein the first memory is used to store a first instruction, and the first instruction is used to control the first processor to execute the method according to the first aspect of the present invention.
[0045] According to a fourth aspect of the present invention, a version control server is provided, comprising a second processor and a second memory, wherein the second memory is used to store second instructions, and the second instructions are used to control the second processor to execute the method according to the second aspect of the present invention.
[0046] According to a fifth aspect of the present invention, a system for updating a configuration file is provided, comprising the configuration server according to the third aspect of the present invention, the version control server according to the fourth aspect of the present invention, and a manager, wherein the manager is configured to receive a modified configuration file sent by the version control server to mount and update the configuration file of the corresponding container.
[0047] In an embodiment of the present invention, a configuration server detects the result of a modification event of a configuration file stored in a version control server, obtains the modified configuration file from the version control server, and sends the modified configuration file to the manager of the corresponding container to mount and update the configuration file of the container. In this way, automatic updating of the configuration file can be achieved. In addition, the risk of inconsistency between the application running in the container and the mounted configuration file caused by manual management of the configuration file can be avoided.
[0048] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0050] Figure 1 is a block diagram showing an example of a hardware configuration of a system that can be used to implement a configuration file update according to an embodiment of the present invention.
[0051] Figure 2 A flow chart showing a method for updating a configuration file according to a first embodiment of the present invention is shown.
[0052] Figure 3A flow chart showing a method for updating a configuration file according to a first embodiment of the present invention is shown.
[0053] Figure 4 A flow chart showing a method for updating a configuration file according to a first embodiment of the present invention is shown.
[0054] Figure 5 A flow chart showing a method for updating a configuration file according to a first embodiment of the present invention is shown.
[0055] Figure 6 A block diagram of a configuration server according to a first embodiment of the present invention is shown.
[0056] Figure 7 A flow chart showing a method for updating a configuration file according to a second embodiment of the present invention is shown.
[0057] Figure 8 A block diagram of a version control server according to a second embodiment of the present invention is shown.
[0058] Fig. 9 A block diagram of a system for updating a configuration file according to a third embodiment of the present invention is shown. DETAILED DESCRIPTION
[0059] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0060] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0061] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0062] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0063] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0064] <Hardware Configuration>
[0065] like Figure 1As shown, the system 1000 for updating configuration files includes a configuration server 1100 , a version control server 1200 , a host machine 1300 , and a network 1400 .
[0066] In a distributed cluster such as a Kubenetes cluster, the configuration server 1100 may be responsible for the control and management of the entire cluster. The host machine 1300, as a node of the cluster, may run one or more containers, and an application may run in each container. The host machine 1300 includes a manager for processing the tasks sent to the node by the configuration server 1100 and managing the containers therein. In addition, the manager may also report to the configuration server 1100 the configuration file corresponding to each container, whether the automatic update function is pre-configured, and the configuration file corresponding to each container is mounted to a local location, etc.
[0067] Configuration server 1100 may be, for example, a blade server, etc. In one example, configuration server 1100 may be one or more computers. In another example, configuration server 1100 may be, for example, a server. Figure 1 As shown, the server includes a processor 1110, a memory 1120, an interface device 1130, a communication device 1140, a display device 1150, and an input device 1160. Although the server may also include a speaker, a microphone, etc., these components are irrelevant to the present invention and are omitted here. Among them, the processor 1110 may be, for example, a central processing unit CPU, a microprocessor MCU, etc. The memory 1120 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1130 may include, for example, a USB interface, a serial interface, etc. The communication device 1140 may be capable of wired or wireless communication, for example. The display device 1150 may be, for example, a liquid crystal display. The input device 1160 may include, for example, a touch screen, a keyboard, etc.
[0068] The version control server 1200 may also be one or more computers. Figure 1As shown, the version control server 1200 may include a processor 1210, a memory 1220, an interface device 1230, a communication device 1240, a display device 1250, an input device 1260, a speaker 1270, a microphone 1280, and the like. The processor 1210 may be a central processing unit CPU, a microprocessor MCU, and the like. The memory 1220 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, and the like. The interface device 1230 may include, for example, a USB interface, a headphone interface, and the like. The communication device 1240 may, for example, be capable of wired or wireless communication. The display device 1250 may be, for example, a liquid crystal display screen, a touch display screen, and the like. The input device 1260 may include, for example, a touch screen, a keyboard, and the like. The user may input / output voice information through the speaker 1270 and the microphone 1280.
[0069] The host machine 1300 may also be one or more computers. Figure 1 As shown, the host machine 1300 may include a processor 1310, a memory 1320, an interface device 1330, a communication device 1340, a display device 1350, an input device 1360, a speaker 1370, a microphone 1380, and the like. Among them, the processor 1310 may be a central processing unit CPU, a microprocessor MCU, and the like. The memory 1320 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, and the like. The interface device 1330 may include, for example, a USB interface, a headphone interface, and the like. The communication device 1340 may, for example, be capable of wired or wireless communication. The display device 1350 may be, for example, a liquid crystal display screen, a touch display screen, and the like. The input device 1360 may include, for example, a touch screen, a keyboard, and the like. The user may input / output voice information through the speaker 1370 and the microphone 1380.
[0070] The communication network 1400 may be a wireless network or a network, and may be a local area network or a wide area network. Figure 1 In the configuration environment 1000 shown, the version control server 1200 and the configuration server 1100 , as well as the configuration server 1100 and the host machines 1300 - 1 , 1300 - 2 , and 1300 - 3 may communicate via a communication network 1400 .
[0071] Figure 1 The depicted configuration environment 1000 is merely illustrative and is in no way intended to limit the invention, its application, or uses.
[0072] In the embodiment of the present invention, the memory 1120 of the configuration server 1100 is used to store instructions, and the instructions are used to control the processor 1110 to operate to execute any one of the methods for updating the configuration file provided in the first embodiment of the present invention.
[0073] The memory 1220 of the version control server 1200 is used to store instructions, and the instructions are used to control the processor 1210 to operate to execute any one of the methods for updating a configuration file provided in the second embodiment of the present invention.
[0074] The memory 1320 of the host machine 1300 is used to store instructions, and the instructions are used to control the processor 1310 to operate so as to execute the method for updating the configuration file implemented by the administrator provided in the third embodiment of the present invention.
[0075] It should be understood by those skilled in the art that although Figure 1 In the figure, multiple devices are shown for the configuration server 1100, the version control server 1200, and the host machine 1300, but the present invention may only involve some of the devices, for example, the configuration server 1100 only involves the processor 1110 and the memory 1120, or the version control server 1200 only involves the processor 1210 and the memory 1220, or the host machine 1300 only involves the processor 1310 and the memory 1320, etc. The technicians can design instructions according to the scheme disclosed by the present invention. How the instructions control the processor to operate is well known in the art, so it will not be described in detail here.
[0076] The overall concept of an embodiment of the present invention is to provide a technical solution for updating a configuration file, in which a target configuration file is pre-stored on a version control server. When the configuration server receives a request from a host machine for the current application to read the target configuration file, the configuration server obtains the target configuration file pre-stored on the version control server and sends it to the host machine that issued the request, so that the host machine mounts the received target configuration file to the container corresponding to the current application. In this way, the decoupling between the configuration file and the container can be achieved, so that different applications can read the same configuration file. Moreover, the configuration server will uniformly distribute the configuration files of the specified version to multiple applications, which can ensure the consistency of the configuration files read by the same application. In addition, various risks brought by manual management of configuration files can also be avoided.
[0077] <Method>
[0078] In this embodiment, a method for updating a configuration file is provided, and the method is implemented by a configuration server.
[0079] The configuration server can be any electronic device with a processor and a memory, for example, a desktop computer, a blade server, a cloud server, etc. In one example, the configuration server can be Figure 1 Configuration server 1100 is shown.
[0080] The method to update the configuration file, such as Figure 2 As shown, it includes: steps S2100-S2400.
[0081] Step 2100: Detect an event that a configuration file pre-stored in a version control server is modified.
[0082] Specifically, the configuration file may be stored on a version control server. If the target configuration file needs to be modified, the modification may be performed on the version control server.
[0083] The version control server may be a server that can provide a storage configuration file. The version control server may be, for example but not limited to, a git server.
[0084] In an example, the event may include any one or more of the following:
[0085] Receive notification from the version control server that the configuration file has been modified;
[0086] The result obtained by comparing the configuration file at the current moment with the configuration file at the previous moment is that there is a difference;
[0087] The last modification time of the configuration file has changed.
[0088] In the embodiment where the event includes receiving a notification of modification of a configuration file sent by a version control server, the version control server may send a notification of modification of the configuration file to the configuration server when the stored configuration file is modified. Specifically, the notification of modification of the configuration file sent by the version control server may be detected in real time, or the notification of modification of the configuration file sent by the version control server may be detected according to a preset detection frequency.
[0089] In the embodiment where the event includes the result of comparing the configuration file at the current moment with the configuration file at the previous moment and finding that there is a difference, for example, the configuration server may compare the configuration file at the current moment with the configuration file at the previous moment in the version control server according to a preset frequency. If the content of the configuration file at the current moment is not completely the same as the content of the configuration file at the previous moment, that is, the result of comparing the configuration file at the current moment with the configuration file at the previous moment is that there is a difference, then it can be considered that the event of modification of the configuration file pre-stored in the version control server occurs.
[0090] In the embodiment where the event includes a change in the latest modification time of the configuration file, the latest modification time of the configuration file may be stored in the version control server. The configuration server may monitor the latest modification time in real time, and when the latest modification time of the configuration file changes, it may be considered that an event that the configuration file pre-stored in the version control server has been modified has occurred. The configuration server may also detect the latest modification time of the configuration file at a preset frequency, and when the latest modification time detected at the current moment is different from the latest modification time detected at the previous moment, it may be considered that an event that the configuration file pre-stored in the version control server has been modified has occurred.
[0091] Step S2200: Determine the storage address of the modified configuration file in the version control server according to the detection result of the event.
[0092] Specifically, when it is detected that a configuration file pre-stored in the version control server is modified, the storage address of the modified configuration file in the version control server is determined.
[0093] In an embodiment where the event that a configuration file pre-stored in the version control server is modified includes receiving a notification that the configuration file is modified sent by the version control server, the step of determining the storage address of the modified configuration file in the version control server may include:
[0094] Determine the storage address associated with the web hook that receives the notification.
[0095] Specifically, when a configuration file is modified, the version control server may determine the network hook associated with the storage address of the configuration file, and send a notification of the configuration file modification to the configuration server through the network hook. In this way, the configuration server can obtain the storage address of the configuration file in the version control server through the storage address associated with the network hook that receives the notification of the configuration file modification.
[0096] In the embodiment where the event that the configuration file pre-stored in the version control server is modified includes the result of comparing the configuration file at the current moment with the configuration file at the previous moment showing a difference, or in the embodiment where the event that the configuration file pre-stored in the version control server is modified includes the change in the latest modification time of the configuration file, the configuration server may also pre-store a correspondence between the configuration file and its storage address in the version control server. Then, when the configuration server detects that the configuration file is modified, it can determine the storage address of the configuration file in the version control server based on the correspondence.
[0097] Step S2300: Obtain the modified configuration file from the version control server according to the storage address.
[0098] Specifically, according to the storage address of the modified configuration file in the version control server, the modified configuration file can be obtained from the version control server.
[0099] Step S2400: Send the modified configuration file to the administrator of the container corresponding to the storage address to mount and update the configuration file of the container.
[0100] Specifically, the configuration server may pre-store a correspondence between the storage address of the configuration file and the container. Based on the correspondence, the container corresponding to the storage address may be determined. If the configuration file is modified, the storage address of the configuration file in the version control server may also be modified accordingly, or may not be modified.
[0101] Furthermore, the method may also include: Figure 3 Steps S3100-S3300 are shown.
[0102] Step S3100, in response to the release of the resource object, record the corresponding relationship between the resource object itself and the storage address.
[0103] The resource object may include a correspondence between the resource object itself and the storage address.
[0104] The resource object may be, for example, a ConfigMap in a Kubernetes cluster. The ConfigMap may be published through kubectl, an interactive tool of the Kubernetes cluster.
[0105] Step S3200: receiving the correspondence between the container and the resource object sent by the administrator.
[0106] The correspondence between the container and the resource object is sent by the administrator when publishing an application running in the container.
[0107] Step S3300: Determine the container corresponding to the storage address according to the correspondence between the storage address and the resource object, and the correspondence between the container and the resource object.
[0108] Specifically, the resource object corresponding to the storage address can be determined based on the correspondence between the storage address and the resource object, and the container corresponding to the resource object can be determined based on the correspondence between the container and the resource object, that is, the container corresponding to the storage address.
[0109] Since the container communicates data with the configuration server through the corresponding manager, the configuration server may send the modified configuration file to the manager of the container corresponding to the storage address to mount and update the configuration file of the container.
[0110] Before the administrator updates the configuration file of the container, the configuration file is mounted in the container. The configuration file of the container is updated by the administrator replacing the configuration file mounted in the container with the modified configuration file.
[0111] By mounting the configuration file and the modified configuration file into the container, the container will not be aware of the existence of the configuration server, and the application running in the container can read the configuration file mounted into the corresponding container in the existing way, without having to adapt the configuration server according to the application. In this way, the scope of application of the method for updating the configuration file in this embodiment can be improved.
[0112] In one example, the administrator may detect whether a modified configuration file is stored in the local cache according to a preset frequency, and mount and update the configuration file of the container when detecting that a modified configuration file is stored in the local cache.
[0113] In one example, the configuration server may also generate and send an update instruction to the manager. Upon receiving the update instruction, the manager may mount and update the configuration file of the container.
[0114] In one example, the method may further include step S2500: detecting whether the container corresponding to the storage address is pre-configured with an automatic update function. If the container is pre-configured with the automatic update function, step S2400 is then performed. If the container is not pre-configured with the automatic update function, there is no need to send the modified configuration file to the administrator of the container.
[0115] Specifically, when the container is generated, the external device can configure whether it has an automatic update function. After the configuration is completed, the container can send information about whether it is pre-configured with the automatic update function to the configuration server through the administrator, and the configuration server pre-stores the information for subsequent viewing when executing step S2500.
[0116] In this way, the configuration files can be automatically updated. In addition, the risk of inconsistency between the application running in the container and the mounted configuration files caused by manual configuration file management can be avoided.
[0117] In one example, if there is a problem with the modified configuration file, the configuration file needs to be rolled back, that is, the modified configuration file mounted in the container is rolled back to any version of the configuration file before the modification. Then, the method may also include the following steps: Figure 4 Steps S4100-S4300 are shown.
[0118] Step S4100, in response to a rollback operation on a configuration file, obtaining a rollback version number of the configuration file.
[0119] Specifically, multiple versions of configuration files may be pre-stored in the storage address of the version control server. Each configuration file has a corresponding version number, so that the version control server can manage configuration files of different versions.
[0120] Specifically, the configuration server may pre-store the current version number of the modified configuration file. Then, the rollback operation on the configuration file may be: an operation of modifying the current version number to any version number before the modification.
[0121] In an example, the operation of rolling back the configuration file may be an operation of rolling back and modifying the version number of the configuration file stored in the external configuration server.
[0122] In another example, the rollback operation on the configuration file may also be the release of a resource object reflecting the rollback of the configuration file, wherein the new resource object includes the rollback version number of the configuration file.
[0123] Step S4200: Obtain a configuration file corresponding to the rollback version number from a version control server according to the rollback version number and the storage address.
[0124] Specifically, the storage address of the modified configuration file in the version control server may be the same as the storage address of the configuration file corresponding to the rollback version number in the version control server. Therefore, the configuration file corresponding to the rollback version number can be obtained through the storage address of the modified configuration file and the rollback version number.
[0125] Step S4300: Send the configuration file corresponding to the rollback version number to the administrator to perform a mount rollback of the container configuration file.
[0126] Specifically, the storage address of the modified configuration file in the version control server and the storage address of the configuration file corresponding to the rollback version number in the version control server may be the same, the container corresponding to the storage address of the modified configuration file in the version control server and the container corresponding to the storage address of the configuration file corresponding to the rollback version number in the version control server may be the same, and the administrator in step S4300 may also be the same as the administrator in step S2400.
[0127] Specifically, the administrator may roll back the configuration file of the container by replacing the modified configuration file mounted in the container with the configuration file corresponding to the rollback version number.
[0128] In this way, if there is a problem with the modified configuration file, the configuration file can be rolled back quickly.
[0129] In one example, the configuration server may also store the obtained modified configuration file in a local cache, so that when a request to obtain the modified configuration file is subsequently received, the locally cached modified configuration file is directly sent to the manager of the container that sent the request for mounting.
[0130] Specifically, after the configuration file is modified, other containers corresponding to the storage address may send a request to obtain the modified configuration file through the corresponding manager. For example, when an application in another container is started, a request to obtain the modified configuration file is sent.
[0131] When the configuration server receives a request from another container to obtain a modified configuration file, if it detects that the modified configuration file is stored in the local cache, it can directly send the modified configuration file stored in the local cache to the manager of the other container. The manager of the other container can mount the received modified configuration file to the other container.
[0132] When reading modified configuration files with high concurrency, since the modified configuration files are stored in the local cache, there is no need to read the modified configuration files from the version control server every time a request to obtain the modified configuration files is received. In this way, other requests in the configuration server and the version control server will not be affected. Moreover, the speed of obtaining the modified configuration files can be accelerated. In addition, the risk of packet loss during the transmission of the modified configuration files can be reduced.
[0133] On this basis, the method may further include deleting the modified configuration file stored in the cache when an event of deleting the modified configuration file stored in the local cache is detected.
[0134] The event of deleting a modified configuration file stored in the cache may include any one or more of the following:
[0135] The configuration server sends the modified configuration files in the local cache to the corresponding administrator;
[0136] The modified configuration file is stored in the local cache for a period of time exceeding the preset time threshold;
[0137] Configure server shutdown; and,
[0138] Configure the server to clear the cache.
[0139] In the event of deleting the modified configuration file in the cache: the configuration server returns the modified configuration file in the cache to the administrator. In the embodiment, the modified configuration file stored in the local cache can be deleted when the configuration server sends the modified configuration file stored in the local cache to the corresponding administrator.
[0140] In the embodiment where the event of deleting the modified configuration file in the cache is: the time when the modified configuration file is stored in the cache of the configuration server exceeds a preset time threshold, the time threshold may be pre-set according to the application scenario. The time threshold may be, for example, but not limited to, 1 hour. Then, in the case where the time when the modified configuration file is stored in the cache of the configuration server exceeds 1 hour, the modified configuration file stored in the local cache is deleted.
[0141] In the embodiment where the event for deleting the modified configuration file in the cache is the shutdown of the configuration server, the modified configuration file stored in the local cache may be deleted when the configuration server is shut down.
[0142] In the embodiment where the event of deleting the modified configuration file in the cache is the configuration server clearing the cache, the modified configuration file stored in the local cache may be deleted when the configuration server clears the cache.
[0143] In this way, by deleting the modified configuration file stored in the local cache when an event of deleting the modified configuration file in the local cache is detected, the memory occupied by the configuration server can be reduced, thereby improving the running speed of the configuration server.
[0144] In one example, the method may also include: Figure 5 Steps S5100-S5200 are shown.
[0145] Step S5100: receiving a feature value sent by a version control server.
[0146] The characteristic value may be obtained by the version server performing characteristic calculation processing on the modified configuration file according to a preset information-digest algorithm.
[0147] The main feature of the information-digest algorithm is that the feature calculation process does not require a key, and the data obtained after the feature calculation cannot be decrypted. Only when the same plaintext data is input and the same information-digest algorithm is used can the same ciphertext be obtained. The information-digest algorithm does not have the problem of key management and distribution, and is suitable for use on distributed networks. For example, the information-digest algorithm can be SHA, or MD5, etc.
[0148] The characteristic value may be, for example, a character string of fixed length that can uniquely characterize the target configuration file. Moreover, the characteristic values obtained by performing characteristic calculation processing on the same configuration file using the same information-digest algorithm are the same, and the characteristic values obtained by performing characteristic calculation processing on different configuration files using the same information-digest algorithm are different.
[0149] In the case where the configuration server stores the modified configuration file in the local cache, the feature value may also be stored in the local cache.
[0150] Step S5200: Send the characteristic value to the administrator to verify the integrity of the received configuration file.
[0151] The administrator in step S5200 is the same as the administrator in step S2400. The administrator can verify the integrity of the received modified configuration file according to the characteristic value.
[0152] Specifically, the step of the administrator verifying the integrity of the received modified configuration file according to the characteristic value may include:
[0153] The received target configuration file is processed by feature calculation according to the information-digest algorithm, and the obtained feature value is used as the verification feature value; the received feature value and the verification feature value are compared to see whether they are the same; and whether the modified configuration file is complete is determined according to the comparison result.
[0154] Specifically, the information-digest algorithm used by the administrator to perform feature calculation processing on the received target configuration file is the same as the information-digest algorithm used by the version control server to perform feature calculation processing on the modified configuration file.
[0155] Thus, when the modified configuration file received by the administrator is complete, the obtained verification characteristic value is the same as the received characteristic value. When the modified configuration file received by the administrator is incomplete, the obtained verification characteristic value is different from the received characteristic value.
[0156] Therefore, whether the received modified configuration file is complete can be determined by comparing the received feature values and verifying whether the feature values are the same.
[0157] If the received feature value is the same as the verification feature value, it can be determined that the received modified configuration file is complete. If the received feature value is different from the verification feature value, it can be determined that the received modified configuration file is incomplete.
[0158] In the case that the modified configuration file received by the administrator is complete, the administrator may mount the received modified configuration file into the container to mount and update the configuration file of the container.
[0159] In the case that the modified configuration file received by the administrator is incomplete, the administrator may re-send a request to the configuration server to read the modified configuration file, so that the configuration server re-sends the modified configuration file to the administrator.
[0160] By verifying the integrity of the received target configuration file and mounting the received target configuration file to the container corresponding to the current application when the target configuration file received by the host is complete, the accuracy of the obtained target configuration file can be improved.
[0161] <Configuration Server>
[0162] In this example, a configuration server 600 is also provided, such as Figure 6 As shown, it includes a first processor 610 and a first memory 620, and the first memory 620 is used to store a first instruction; the first instruction is used to control the first processor 610 to execute any one of the methods for updating the configuration file in the first embodiment.
[0163] In this embodiment, the configuration server 600 may also include other devices or modules, for example, Figure 1 Configuration server 1100 is shown.
[0164] In this embodiment, the configuration server 600 is not limited to a physical implementation form, and the configuration server 600 may be a computer, a blade server, a cloud server, a server group, etc. The configuration server 600 may also implement some functions through external devices, for example, the configuration server 600 may be equipped with an external communication server to manage the communication connection between the configuration server and multiple version control servers; the configuration server 600 may be equipped with an external information server to assist the configuration server 600 in managing the device information of multiple version control servers, and so on.
[0165] Those skilled in the art will appreciate that the configuration server 600 may be implemented in various ways. For example, the configuration server 600 may be implemented by configuring a processor with instructions. For example, instructions may be stored in a ROM, and when the device is started, the instructions may be read from the ROM into a programmable device to implement the configuration server 600. For example, the configuration server 600 may be solidified into a dedicated device (e.g., an ASIC). The configuration server 600 may be divided into independent units, or they may be combined together for implementation. The configuration server 600 may be implemented in one of the various implementations described above, or may be implemented in a combination of two or more of the various implementations described above.
[0166] The present embodiment has been described above in conjunction with the accompanying drawings. According to the present embodiment, a method for updating a configuration file and a configuration server are provided. By detecting the detection result of an event in which a configuration file stored in a version control server is modified, the modified configuration file is obtained from the version control server, and the modified configuration file is sent to the manager of the corresponding container to mount and update the configuration file of the container. In this way, automatic updating of the configuration file can be achieved. In addition, the risk of inconsistency between the application running in the container and the mounted configuration file caused by manual management of the configuration file can be avoided.
[0167] <Second Embodiment>
[0168] <Method>
[0169] In this embodiment, a method for updating a configuration file is provided, which is implemented by a version control server.
[0170] The version control server can be any electronic device with a processor and a memory, for example, a desktop computer, a blade server, a cloud server, etc. In one example, the version control server can be Figure 1 Version control server 1200 is shown.
[0171] The method to update the configuration file, such as Figure 7 As shown, step S7100 is included.
[0172] Step S7100, in response to a modification operation on a pre-stored configuration file, a notification of modification of the configuration file is sent to a configuration server, so that the configuration server can detect whether the configuration file is modified.
[0173] In an example, the method may further include the following steps S7200-S7300.
[0174] Step S7200, determining a web hook associated with the storage address of the configuration file.
[0175] Step S7300: Send a notification of modification of the configuration file to the configuration server via a network hook.
[0176] In this way, the configuration server can determine the storage address of the modified configuration file in the version control server based on the network hook that receives the notification that the configuration file has been modified.
[0177] In an example, the method may further include the following steps S7500-S7600.
[0178] Step S7500: Perform feature calculation processing on the modified configuration file according to a preset information-digest algorithm to obtain a feature value.
[0179] Step S7600: Send the characteristic value to the configuration server.
[0180] Specifically, the configuration server may obtain the feature value while obtaining the modified configuration file from the version control server. Alternatively, when the configuration server obtains the modified configuration file from the version control server, the version control server sends the feature value to the configuration server. The configuration server sends the feature value to the administrator to verify the integrity of the received modified configuration file.
[0181] <version control server>
[0182] In this embodiment, a version control server 800 is also provided. Figure 8 As shown, it includes a second processor 810 and a second memory 820, and the second memory 820 is used to store a second instruction; the second instruction is used to control the second processor 810 to execute any one of the methods for updating the configuration file in the second embodiment.
[0183] In this embodiment, the version control server 800 is not limited to a physical implementation form, and the version control server 800 can be a computer, a blade server, a cloud server, a version control server in a server group, etc. The version control server 800 can also implement some functions through external devices, for example, the version control server 800 can be equipped with an external communication server to manage the communication connection between the version control server and multiple configuration servers; the version control server 800 can be equipped with an external information server to assist the version control server 800 in managing the device information of multiple configuration servers, and so on.
[0184] Those skilled in the art will appreciate that the version control server 800 can be implemented in various ways. For example, the version control server 800 can be implemented by configuring a processor with instructions. For example, the instructions can be stored in a ROM, and when the device is started, the instructions are read from the ROM into a programmable device to implement the version control server 800. For example, the version control server 800 can be solidified into a dedicated device (such as an ASIC). The version control server 800 can be divided into independent units, or they can be combined together for implementation. The version control server 800 can be implemented by one of the various implementations described above, or can be implemented by a combination of two or more of the various implementations described above.
[0185] The present embodiment has been described above in conjunction with the accompanying drawings. According to the present embodiment, a method for updating a configuration file and a version control server are provided. In response to a modification operation on a pre-stored configuration file, the version control server sends a notification of modification of the configuration file to the configuration server, so that the configuration server can detect whether the configuration file has been modified. Then, when the version control server detects that the configuration file has been modified, it obtains the modified configuration file from the version control server, and sends the modified configuration file to the manager of the corresponding container to mount and update the configuration file of the container. In this way, automatic updating of the configuration file can be achieved. In addition, the risk of inconsistency between the application running in the container and the mounted configuration file caused by manual management of the configuration file can be avoided.
[0186] <Third Embodiment>
[0187] <System>
[0188] In this embodiment, a system 900 for updating a configuration file is provided. Fig. 9 As shown, including:
[0189] The configuration server 700 provided in the first embodiment;
[0190] The version control server 800 provided in the second embodiment; and
[0191] The manager 910 is used to receive the modified configuration file sent by the version control server to mount and update the configuration file of the corresponding container.
[0192] Specifically, the administrator 910 may perform the mounting update of the configuration file of the corresponding container by replacing the configuration file mounted in the corresponding container with the modified configuration file.
[0193] When the administrator 910 receives the characteristic value, the characteristic calculation process is performed on the received target configuration file according to the information-digest algorithm, and the obtained characteristic value is used as the verification characteristic value; the received characteristic value and the verification characteristic value are compared to see whether they are the same; and whether the modified configuration file is complete is determined based on the comparison result.
[0194] If the received feature value is the same as the verification feature value, it can be determined that the received modified configuration file is complete. If the received feature value is different from the verification feature value, it can be determined that the received modified configuration file is incomplete.
[0195] In the case that the modified configuration file received by the administrator is complete, the administrator may mount the received modified configuration file into the container to mount and update the configuration file of the container.
[0196] In the case that the modified configuration file received by the administrator is incomplete, the administrator may re-send a request to the configuration server to read the modified configuration file, so that the configuration server re-sends the modified configuration file to the administrator.
[0197] In this embodiment, the system 900 for updating the configuration file may also include other devices, for example, it may also include a communication server for managing the communication connection between the configuration server 700 and the version control server 800; or it may also include an information server for assisting the configuration server 300 in managing the version control server 800, and so on.
[0198] In one example, the system 900 for updating the configuration file may also be as follows: Figure 1 The system 1000 for updating a configuration file is shown. The manager 910 may be provided by the host machine 1300 .
[0199] The present embodiment has been described above in conjunction with the accompanying drawings. According to the present embodiment, a system for updating a configuration file is provided. The configuration server detects the detection result of an event in which a configuration file stored in a version control server is modified, obtains the modified configuration file from the version control server, and sends the modified configuration file to the manager of the corresponding container to mount and update the configuration file of the container. In this way, automatic updating of the configuration file can be achieved. In addition, the risk of inconsistency between the application running in the container and the mounted configuration file caused by manual management of the configuration file can be avoided.
[0200] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0201] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0202] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0203] The computer program instructions for performing the operation of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.
[0204] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.
[0205] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0206] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0207] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a part of a module, a program segment or an instruction, and a part of the module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0208] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. A method for updating a configuration file, wherein: The method is implemented by a configuration server, and comprises: Detecting an event that a configuration file pre-stored in a version control server is modified; Determining, according to a detection result of the event, a storage address of the modified configuration file in the version control server; According to the storage address, obtaining the modified configuration file from the version control server; Send the modified configuration file to the administrator of the container corresponding to the storage address to mount and update the configuration file of the container. The configuration server is responsible for the control and management of the entire cluster, and the container manager is used to process the tasks sent to the node by the configuration server and manage the containers in the node.
2. The method according to claim 1, wherein: The events include any one or more of the following: Receiving a notification from the version control server that the configuration file has been modified; The result obtained by comparing the configuration file at the current moment with the configuration file at the previous moment is that there is a difference; The last modification time of the configuration file has changed.
3. The method according to claim 1, wherein: The event includes: receiving a notification sent by the version control server that the configuration file has been modified; the step of determining the storage address of the modified configuration file in the version control server includes: A storage address associated with a webhook that receives the notification is determined.
4. The method according to claim 1, wherein: The method further comprises: Generate and send an update instruction to the manager, so that the manager can mount and update the configuration file of the container according to the update instruction.
5. The method according to claim 1, wherein: The method further comprises: Detecting whether the container corresponding to the storage address is pre-configured with an automatic update function; In the case where the container is pre-configured with an automatic update function, the step of sending the modified configuration file to the administrator of the container is performed.
6. The method according to claim 1, wherein: The method further comprises: In response to the release of the resource object, recording the corresponding relationship between itself contained in the resource object and the storage address; receiving a correspondence between the container and the resource object sent by the manager; wherein the correspondence between the container and the resource object is sent by the manager when publishing an application running in the container; According to the corresponding relationship between the storage address and the resource object, and the corresponding relationship between the container and the resource object, a container corresponding to the storage address is determined.
7. The method according to claim 1, wherein: The method further comprises: In response to a rollback operation on the configuration file, obtaining a rollback version number of the configuration file; Obtaining a configuration file corresponding to the rollback version number from the version control server according to the rollback version number and the storage address; The configuration file corresponding to the rollback version number is sent to the administrator to perform the mount rollback of the configuration file of the container.
8. The method according to claim 1, wherein: The method further comprises: The modified configuration file is stored in a local cache, so that when a request for obtaining the modified configuration file is received, the modified configuration file in the local cache is sent to the manager of the container that sends the request for mounting.
9. The method according to claim 1, wherein: The method further comprises: Receiving a feature value sent by the version control server, the feature value being obtained by the version control server performing feature calculation processing on the modified configuration file according to a preset information-digest algorithm; The characteristic value is sent to the administrator to verify the integrity of the received configuration file.
10. A method for updating a configuration file, wherein: The method is implemented by a version control server, and includes: In response to a modification operation on a pre-stored configuration file, a notification of the modification of the configuration file is sent to a configuration server, so that the configuration server can detect whether the configuration file has been modified, and send the modified configuration file to the administrator of the corresponding container to mount and update the configuration file of the container. The configuration server is responsible for the control and management of the entire cluster, and the container manager is used to process the tasks sent to the node by the configuration server and manage the containers in the node.
11. The method according to claim 10, wherein: The step of sending a notification includes: Determining a network hook associated with a storage address of the configuration file; A notification of modification of the configuration file is sent to the configuration server through the network hook.
12. The method according to claim 10, wherein: The method further comprises: Performing feature calculation processing on the modified configuration file according to a preset information-digest algorithm to obtain a feature value; The characteristic value is sent to a configuration server.
13. A configuration server, wherein: The method comprises a first processor and a first memory, wherein the first memory is used to store a first instruction, and the first instruction is used to control the first processor to execute the method according to any one of claims 1-9.
14. A version control server, wherein: The method comprises a second processor and a second memory, wherein the second memory is used to store second instructions, and the second instructions are used to control the second processor to execute the method according to any one of claims 10-12.
15. A system for updating a configuration file, characterized in that: It includes a configuration server according to claim 13, a version control server according to claim 14, and a manager, wherein the manager is used to receive a modified configuration file sent by the version control server to mount and update the configuration file of the corresponding container.
Citation Information
Patent Citations
Configuration file management method and system
CN106603281A
Application configuration file updating method and apparatus
CN107368331A
Configuration data dynamic updating system and method based on application cluster
CN107465714A