Task management method, system and device
Through the task management method, in a multi-center and multi-cluster environment, the task control component is used to send task messages to the target cluster, which solves the problem of high operation and maintenance complexity in traditional technology and achieves unified management and efficient task execution of multi-center and multi-cluster. , improving operation and maintenance efficiency.
Patent Information
- Application Number
- CN202410912074.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-22
Smart Images

Figure CN118819782A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud native technology, and in particular to a task management method, system and device. Background Art
[0002] With the development of cloud-native technology, multi-center, multi-cluster deployment mode has become the first choice of many large enterprises and Internet companies, but it also brings about increased operation and maintenance complexity and troubleshooting difficulty.
[0003] In traditional technology, a network dialing tool is deployed and installed in each cluster of a data center. Operation and maintenance personnel manually write configuration files of the network dialing tool for each cluster, and use the network dialing tool to detect the availability of network services in each cluster.
[0004] However, in traditional technologies, operation and maintenance personnel configure and query separate network dialing tools in each cluster. Due to the large number of clusters, the network services in each cluster may be different, resulting in high maintenance complexity and low operation and maintenance efficiency for multi-center and multi-cluster network dialing tasks. Summary of the invention
[0005] Based on this, it is necessary to provide a task management method, apparatus, computer equipment, computer-readable storage medium and computer program product to address the above technical issues.
[0006] In a first aspect, the present application provides a task management method, which is applied to manage a cluster, and the method includes:
[0007] In response to a target task triggering request, obtaining task information corresponding to the target task and a task type corresponding to the target task;
[0008] Based on the task information and the task type, a task message corresponding to the target task is sent to the target cluster through the task control component, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0009] In one embodiment, sending a task message corresponding to the target task to the target cluster based on the task information and the task control component includes:
[0010] Through the task control component and the target cluster included in the task information, query the cluster information corresponding to the target cluster in the database;
[0011] Constructing a task message corresponding to the target task according to the task control component, the task information and the cluster information;
[0012] The task control component sends the task message to the task proxy component of the target cluster, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0013] In one of the embodiments, the target tasks include creating a dialing test task, deleting a dialing test task, modifying a dialing test task, and modifying a dialing test task execution cluster.
[0014] In one of the embodiments, after sending a task message corresponding to the target task to the target cluster based on the task information and the task control component, the method further includes:
[0015] Receiving a completion message sent by the task agent component in the target cluster;
[0016] The execution record of the target task is stored in a database according to the task control component and the completion message.
[0017] In one embodiment, if the target task is a query task execution result, the task information includes a cluster to be queried; the method further includes:
[0018] Constructing a query task message for the cluster to be queried through the task control component;
[0019] Sending the query task message to the task proxy component of the cluster to be queried based on the task control component;
[0020] The task execution result returned by the task proxy component of the cluster to be queried is received, and the cluster to be queried and the task execution result corresponding to the cluster to be queried are displayed through a page display component.
[0021] In one embodiment, if the target task is to modify the execution cluster of the target task, the task information includes a task identifier, an original cluster, and a target cluster; sending a task message corresponding to the target task to the target cluster based on the task information and the task control component, instructing the task agent component in the target cluster to initiate the target task, includes:
[0022] Deleting a first task message of a target task corresponding to the task identifier according to the task control component, the task identifier and the original cluster;
[0023] Constructing a second task message for creating the target task according to the task control component, the task identifier and the target cluster;
[0024] The first task message is sent to the task agent component of the original cluster based on the task control component, and the second task message is sent to the task agent component of the target cluster based on the task control component.
[0025] In a second aspect, the present application provides a task management method, which is applied to a target cluster and includes:
[0026] The task agent component receives and obtains a task message sent by the management cluster, and modifies the original configuration file according to the task information in the task message to obtain a target configuration file; the task message includes the target task;
[0027] Based on the target configuration file, the task configuration refresh component and the target configuration file, the configuration file of the task execution component is updated and loaded to obtain the target task execution component after the target configuration file is loaded;
[0028] The target task is executed according to the target task execution component to obtain a target result corresponding to the target task.
[0029] In one embodiment, the task execution component includes a first task execution component and a second task execution component; the task configuration refresh component includes a first task configuration refresh component corresponding to the first task execution component, a second task configuration refresh component corresponding to the second task execution component, and a monitoring component;
[0030] The updating and loading of the configuration file of the task execution component based on the target configuration file, the task configuration refresh component and the target configuration file to obtain the target task execution component after the target configuration file is loaded includes:
[0031] When the monitoring component confirms that the configuration mode of the first task execution component is updated, the first configuration file of the first task execution component is updated based on the updated configuration mode to obtain an updated first configuration file;
[0032] When the first task configuration refresh component determines that the first configuration file is updated, the first task execution component is triggered to load the updated first configuration file, thereby obtaining the first task execution component after the target configuration file is loaded;
[0033] When the second task configuration refresh component confirms that the second configuration file is updated, the second task execution component is triggered to load the updated second configuration file, thereby obtaining the second task execution component after the target configuration file is loaded.
[0034] In a third aspect, the present application further provides a task management device, which is applied to manage a cluster, including:
[0035] An acquisition module, configured to acquire task information corresponding to the target task and a task type corresponding to the target task in response to a target task trigger request;
[0036] The first sending module is used to send a task message corresponding to the target task to the target cluster through the task control component based on the task information and the task type, and instruct the task proxy component, task configuration refresh component and task execution component in the target cluster to execute the target task.
[0037] In one of the embodiments, the first sending module is specifically used to query the cluster information corresponding to the target cluster in the database through the task control component and the target cluster included in the task information;
[0038] Constructing a task message corresponding to the target task according to the task control component, the task information and the cluster information;
[0039] The task control component sends the task message to the task proxy component of the target cluster, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0040] In one of the embodiments, the target tasks include creating a dialing test task, deleting a dialing test task, modifying a dialing test task, and modifying a dialing test task execution cluster.
[0041] In one embodiment, the device further comprises:
[0042] A receiving module, configured to receive a completion message sent by the task agent component in the target cluster;
[0043] A recording module is used to store the execution record of the target task in a database according to the task control component and the completion message.
[0044] In one embodiment, if the target task is a query task execution result, the task information includes a cluster to be queried; and the device further includes:
[0045] A query module, used to construct a query task message for the cluster to be queried through the task control component;
[0046] A second sending module, configured to send the query task message to the task agent component of the cluster to be queried based on the task control component;
[0047] The display module is used to receive the task execution result returned by the task proxy component of the cluster to be queried, and display the cluster to be queried and the task execution result corresponding to the cluster to be queried through the page display component.
[0048] In one embodiment, if the target task is to modify the execution cluster of the target task, the task information includes a task identifier, an original cluster and a target cluster; the first sending module is specifically used to construct a first task message for deleting the target task corresponding to the task identifier according to the task control component, the task identifier and the original cluster;
[0049] Constructing a second task message for creating the target task according to the task control component, the task identifier and the target cluster;
[0050] The first task message is sent to the task agent component of the original cluster based on the task control component, and the second task message is sent to the task agent component of the target cluster based on the task control component.
[0051] In a fourth aspect, the present application further provides a task management device, which is applied to manage a cluster, including:
[0052] A modification module is used to receive and obtain a task message sent by the management cluster according to the task proxy component, and modify the original configuration file according to the task information in the task message to obtain a target configuration file; the task message includes the target task;
[0053] An updating module, used to update and load the configuration file of the task execution component based on the target configuration file, the task configuration refresh component and the target configuration file, to obtain the target task execution component after the target configuration file is loaded;
[0054] An execution module is used to execute the target task according to the target task execution component to obtain a target result corresponding to the target task.
[0055] In one embodiment, the task execution component includes a first task execution component and a second task execution component; the task configuration refresh component includes a first task configuration refresh component corresponding to the first task execution component, a second task configuration refresh component corresponding to the second task execution component, and a monitoring component;
[0056] The updating module is specifically used for updating the first configuration file of the first task execution component based on the updated configuration mode to obtain the updated first configuration file after the monitoring component confirms that the configuration mode of the first task execution component is updated;
[0057] When the first task configuration refresh component determines that the first configuration file is updated, the first task execution component is triggered to load the updated first configuration file, thereby obtaining the first task execution component after the target configuration file is loaded;
[0058] When the second task configuration refresh component confirms that the second configuration file is updated, the second task execution component is triggered to load the updated second configuration file, thereby obtaining the second task execution component after the target configuration file is loaded.
[0059] In a fifth aspect, the present application also provides a task management system, including:
[0060] A management cluster is used to respond to a target task trigger request, obtain task information corresponding to the target task and the task type corresponding to the target task; based on the task information and the task type, send a task message corresponding to the target task to the target cluster through a task control component, and instruct the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task;
[0061] The target cluster is used to receive and obtain the task message sent by the management cluster according to the task agent component, and modify the original configuration file according to the task information in the task message to obtain the target configuration file; the task message contains the target task; based on the task information, the task configuration refresh component and the target configuration file, the configuration file of the task execution component is updated and loaded to obtain the target task execution component after the target configuration file is loaded; the target task is executed according to the target task execution component to obtain the target result corresponding to the target task.
[0062] In a sixth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0063] In response to a target task triggering request, obtaining task information corresponding to the target task and a task type corresponding to the target task;
[0064] Based on the task information and the task type, a task message corresponding to the target task is sent to the target cluster through the task control component, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0065] In a seventh aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0066] In response to a target task triggering request, obtaining task information corresponding to the target task and a task type corresponding to the target task;
[0067] Based on the task information and the task type, a task message corresponding to the target task is sent to the target cluster through the task control component, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0068] In an eighth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0069] In response to a target task triggering request, obtaining task information corresponding to the target task and a task type corresponding to the target task;
[0070] Based on the task information and the task type, a task message corresponding to the target task is sent to the target cluster through the task control component, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0071] The above-mentioned task management method, system and device, in response to the target task trigger request, obtain the task information corresponding to the target task and the task type corresponding to the target task; based on the task information and the task type, send the task message corresponding to the target task to the target cluster through the task control component, instructing the task proxy component, task configuration refresh component and task execution component in the target cluster to execute the target task. By adopting this method, the task control component sends the task message corresponding to the target task to other clusters, so as to realize the unified management of the target tasks in all clusters in the multi-center in the management cluster, reduce the operation and maintenance complexity of multiple clusters in the multi-center, and improve the operation and maintenance efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0073] Figure 1 An application environment diagram of a task management method in an embodiment;
[0074] Figure 2 A schematic diagram of a process for managing cluster application tasks in one embodiment;
[0075] Figure 3 A schematic diagram of a flow chart of a step of querying cluster information of a target cluster in one embodiment;
[0076] Figure 4A flowchart of a task management recording step in another embodiment;
[0077] Figure 5 A schematic diagram of a process for querying a task execution result of a target cluster in one embodiment;
[0078] Figure 6 A schematic diagram of a process of modifying a task execution cluster in another embodiment;
[0079] Figure 7 A schematic diagram of a process of managing a target cluster application task in one embodiment;
[0080] Figure 8 A schematic diagram of a process for updating a configuration file by a task execution component in one embodiment;
[0081] Fig. 9 A structural block diagram of a task management device for managing a cluster in one embodiment;
[0082] Fig.10 is a structural block diagram of a task management device for a target cluster in one embodiment;
[0083] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0084] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0085] The task management method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown in FIG. 1 , the management cluster 102 communicates with the target cluster 104 through a network. The data storage system (DB, Data Base) can store the data that the management cluster 102 needs to process. Figure 1As shown, the management cluster 102 is a management area K8S (Kubernetes) cluster in the main center or the backup center, the target cluster can be any business area K8S cluster in the main center or the backup center, and the data storage system can be integrated on the server 102, or it can be placed on the cloud or other network servers. The management cluster 102 responds to the target task trigger request initiated by the user and obtains the task information corresponding to the target task; the management cluster 102 sends the task message corresponding to the target task to the target cluster 104 based on the task information and the task control component, instructing the task agent component, the task configuration refresh component and the task execution component in the target cluster 104 to execute the target task. Among them, the management cluster 102 and the target cluster 104 can be a server cluster or distributed system composed of multiple physical servers or virtual servers (nodes), or a cloud server that provides cloud computing services.
[0086] Among them, through the task control components in the backup center and the main center, using the data synchronization function of the database, it is possible to use the backup center to continue to manage the target tasks in multiple clusters when the main center fails, thereby improving the high availability of data management.
[0087] In an exemplary embodiment, Figure 2 As shown, a task management method is provided, which is applied to Figure 1 Taking the management cluster 102 in FIG. 1 as an example, the method includes the following steps 202 to 204. Among them:
[0088] Step 202: In response to the target task triggering request, obtain task information corresponding to the target task and the task type corresponding to the target task.
[0089] In the present application embodiment, Figure 1 As shown, the management cluster also includes a page display component (portal component) for user operation and data display. The user initiates the corresponding target task according to the task type in the page of the management cluster to complete the triggering of the target task. In response to the trigger request for the target task, the management cluster sends the trigger request, task information and the task type corresponding to the target task to the task control component, and further data processing is performed by the task control component.
[0090] The target task may be a management task for a network dial test task, including creating a dial test task, deleting a dial test task, modifying a dial test task, querying a dial test result, and modifying the cluster in which the dial test task is executed. The target information includes the relevant parameters of the target task and the execution cluster of the target task (i.e., the target cluster).
[0091] The embodiments of the present application and the following embodiments are explained by taking the management of network dialing tasks in other clusters by a management cluster as an example. The user initiates the target task according to the button corresponding to the task type in the page for managing the cluster, and enters the task information corresponding to the target task according to the prompt of the page display component. For example, to create a dialing task, it is necessary to enter the target address of the cluster for creating the dialing task, the detection frequency and timeout settings of the dialing task, etc.; for deleting a dialing task, the user needs to specify the unique identifier or name of the dialing task to be deleted; for modifying a dialing task, the user needs to provide the identifier of the dialing task to be modified and the configuration information to be updated, including the adjustment of the monitoring frequency or the update of other monitoring parameters; for querying the dialing results, the user may need to enter query conditions, such as the name of the dialing task, the time range, the target address, etc., to obtain the execution result of a specific dialing task; for modifying the cluster for executing the dialing task, the user needs to provide the identifier of the target dialing task and the new execution cluster information.
[0092] Step 204 , based on the task information and task type, the task control component sends a task message corresponding to the target task to the target cluster, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0093] In the present application embodiment, Figure 1 As shown in the figure, the management cluster includes a task control component (apiserver component) for linking to the database (DB) and controlling the configuration of multi-center and multi-cluster dial-up tasks; the task agent component (agent component) in the target cluster is used to create, query, delete, and modify dial-up tasks. After the management cluster receives and obtains the target task triggered by the user and the task information corresponding to the target task, the management cluster determines the task type of the target task through the triggered request, inputs the task type and task information of the target task into the task control component, and sends a task message to the task agent component (agent component) of the target cluster through the task control component. The task message acts on the target cluster, so that the task configuration refresh component in the target cluster modifies the configuration file of the task execution component in the target cluster, etc. By automatically modifying the configuration file of the task execution component, the task execution component can execute the target task according to the modified configuration file.
[0094] In the above task management method, by sending task messages corresponding to target tasks to other clusters through the task control component, unified management of target tasks in all clusters in the multi-center can be achieved in the management cluster, reducing the operation and maintenance complexity of multiple clusters in the multi-center and improving the operation and maintenance efficiency.
[0095] In an exemplary embodiment, Figure 3As shown, before sending the task message, the management cluster needs to query the information of the target cluster in advance to ensure that the target cluster can receive the task message, and step 204 includes steps 302 to 306. Among them:
[0096] Step 302: query the database for cluster information corresponding to the target cluster through the task control component and the target cluster included in the task information.
[0097] In the embodiment of the present application, the task control component is a component for managing, scheduling and monitoring tasks, including receiving the user's task request and sending the corresponding task message to the task proxy component according to the request content; the target cluster refers to the specific Kubernetes (K8S) cluster where the user wants to perform a specific task. The management cluster uses the identifier of the target cluster specified in the task information (for example, the cluster name, ID, etc. of the target cluster) to retrieve the cluster information of the target cluster from the database through the task control component, and the cluster information may include the configuration, status, node list, etc. of the cluster.
[0098] Step 304: construct a task message corresponding to the target task according to the task control component, task information and cluster information.
[0099] In an embodiment of the present application, after obtaining the necessary task information and target cluster information, the management cluster integrates this information into a complete task message through the task control component. The task message is a structured data packet that contains all instructions and parameters required to execute the target task.
[0100] The content of the task message includes the type of task (eg, create, delete, modify, etc.), specific parameters of the task (eg, target address and frequency of the dial test, etc.), the identifier of the target cluster, and possible other configuration information.
[0101] Step 306 : Based on the task control component, the task message is sent to the task proxy component of the target cluster, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0102] In the embodiment of the present application, once the task message is constructed, the management cluster sends the task message to the task agent component on the target cluster through the network according to the task control component.
[0103] Among them, the task agent component is a service deployed on the target cluster, which is responsible for receiving task messages from the task control component and parsing these messages for subsequent processing.
[0104] After receiving the task message, if the task involves changes to the cluster configuration, the task configuration refresh component will be responsible for updating the cluster configuration information to ensure that the cluster status is consistent with the task requirements. The task execution component will instruct the target cluster to execute specific dialing tasks according to the instructions and parameters in the task message, such as creating a new dialing task or deleting an existing dialing task.
[0105] In this embodiment, detailed information of the target cluster is obtained through database query, which can ensure that the task control component can accurately understand and operate the target cluster, and build a task message based on the task control component, task information and cluster information, which can ensure that all necessary instructions and parameters are included when the task is executed, avoiding omissions or errors in the execution of task messages by the target cluster, realizing task management of target clusters in multiple clusters by the management cluster, and improving the reliability and consistency of task management.
[0106] In an exemplary embodiment, the target tasks include creating a dialing test task, deleting a dialing test task, modifying a dialing test task, querying a dialing test result, and modifying a dialing test task execution cluster.
[0107] The dial test task is to detect the availability of services through multiple detection methods such as HTTP (Hypertext Transfer Protocol), HTTPS (Hypertext Transfer Protocol Secure), DNS (Domain Name System), TCP (Transmission Control Protocol) and ICMP (Internet Control Message Protocol), and export the results in the form of indicators.
[0108] In an exemplary embodiment, Figure 4 As shown, after step 204, the method further includes steps 402 to 404. Among them:
[0109] Step 402: Receive a completion message sent by a task agent component in the target cluster.
[0110] In an embodiment of the present application, after sending a task message, the task control component in the management cluster waits to receive feedback from the target cluster, and after the task agent component of the target cluster feedbacks that it has received the task message, the task control component of the management cluster receives a completion message to obtain the execution status of the target task in the target cluster.
[0111] Step 404: store the execution record of the target task in a database according to the task control component and the completion message.
[0112] In an embodiment of the present application, the management cluster stores the task execution result information in a database through the task control component based on the task execution result information contained in the completion message, thereby forming an execution record of the target task. The execution record includes key information such as the task identification, execution status, execution time, and execution result, which is used to track and record the execution status of the task.
[0113] In this embodiment, the execution record of the target task is stored through the completion message fed back by the task agent component in the target cluster, so that real-time monitoring and recording of the task execution status is achieved, and a comprehensive task management function is provided in the management cluster.
[0114] In an exemplary embodiment, if the target task is to query the task execution result, the task information includes the cluster to be queried; Figure 5 As shown, the method includes steps 502 to 506. Among them:
[0115] Step 502: construct a query task message for the cluster to be queried through the task control component.
[0116] In the embodiment of the present application, the user can trigger the target task of querying the dial test results in the page display component and enter the identifier of the cluster to be queried, which can be the cluster name or ID (Identity Document) of the cluster to be queried.
[0117] The management cluster uses the task control component to combine the user's query request with the identifier of the cluster to be queried (for example, cluster name, ID, etc.) to construct a query task message. The query task message contains specific parameters for the specified query operation, including the name of the dial test task to be queried, the time range, the target address, and other information, so as to determine the dial test result of the dial test task to be queried in the cluster to be queried.
[0118] Step 504: Send the query task message to the task proxy component of the cluster to be queried based on the task control component.
[0119] In an embodiment of the present application, the management cluster sends the constructed query task message to the task agent component on the cluster to be queried through the network through the task control component. After receiving the query task message, the task agent component parses the message content and executes the corresponding query operation, and returns the query result to the management cluster.
[0120] Step 506: receiving the task execution result returned by the task proxy component of the cluster to be queried, and displaying the task execution results corresponding to the cluster to be queried and the cluster to be queried through the page display component.
[0121] In an embodiment of the present application, the task control component waits for the task agent component of the cluster to be queried to return the query result. When the query result is received in the management cluster, the task control component passes the result to the page display component for display, wherein the query result can be displayed in the form of a table, graph or other form, so that the user can view and analyze the execution status and dialing results of the query task.
[0122] In this embodiment, through the interaction between the management cluster and the cluster to be queried, the management cluster can query and display the execution results of the dialing task distributed in multiple clusters, thereby improving the operation and maintenance efficiency of the management cluster for multiple clusters in multiple centers.
[0123] In an exemplary embodiment, if the target task is to modify the execution cluster of the target task, the task information includes the task identifier, the original cluster and the target cluster; Figure 6 As shown, step 204 includes steps 602 to 606. Among them:
[0124] Step 602: Deleting a first task message of a target task corresponding to the task identifier according to the task control component, the task identifier and the original cluster construction.
[0125] In an embodiment of the present application, when a user needs to modify the execution cluster of a dial test task, the user triggers the target task of modifying the execution cluster of the target task in the page display component, and enters the cluster where the original dial test task is located and the target cluster to which the dial test task is to be migrated.
[0126] The management cluster determines that the current target task is the execution cluster of the modified target task in response to the task identifier through the task control component, and determines the relevant parameters corresponding to the current target task, namely, the original cluster, the target cluster and the task identifier of the target task. First, the task control component constructs a first task message for sending to the original cluster to delete the target task in the original cluster.
[0127] Step 604: construct a second task message for creating the target task according to the task control component, the task identifier and the target cluster.
[0128] In an embodiment of the present application, the management cluster constructs the second task message in the same manner as constructing the first task message. Specifically, the management cluster combines the task identifier of the dial test task to be created with the target cluster of the dial test task to be created through the task control component, and generates a second task message representing the dial test task corresponding to the task identifier created in the target cluster, which is used to create the dial test task corresponding to the task identifier in the target cluster.
[0129] Step 606 : Sending the first task message to the task proxy component of the original cluster based on the task control component and sending the second task message to the task proxy component of the target cluster based on the task control component.
[0130] In the embodiment of the present application, the task control component sends the first task message and the second task message to the task proxy component on the original cluster and the task proxy component on the target cluster through the network. After receiving the first task message and the second task message, the task proxy component of the original cluster and the task proxy component of the target cluster parse the task messages and execute the deletion of the dial test task and the creation of the dial test task respectively, to ensure that the dial test task in the original cluster is completely removed and that the dial test task in the target cluster can be successfully configured and executed.
[0131] In this embodiment, the management cluster constructs the first task message and the second task message to realize the function of migrating the target task between different clusters and reconfiguring the task, which can ensure the accuracy and consistency of the management cluster's operation on the target tasks in multiple clusters in multiple centers, and improve the management cluster's management of the target tasks in other clusters in the distributed environment, thereby improving the operation and maintenance efficiency of multiple clusters.
[0132] In an exemplary embodiment, Figure 7 As shown, a task management method is provided, which is applied to Figure 1 Taking the target cluster 104 in the example as an example, the method includes the following steps 702 to 706. Among them:
[0133] Step 702: Receive and obtain a task message sent by the management cluster according to the task proxy component, and modify the original configuration file according to the task information in the task message to obtain a target configuration file.
[0134] The task message includes the target task.
[0135] In the embodiment of the present application, after receiving the task message sent by the management cluster, the task agent component in the target cluster first parses the task message and determines the task type that needs to be executed in the current target cluster according to the task identifier, including creating a dial test task, deleting a dial test task, modifying a dial test task, querying a dial test result, and modifying the cluster in which the dial test task is executed. For different types of target tasks, the task agent component obtains the task information of the target task by parsing the task message, and modifies the original configuration file based on the parameters of the target task in the task information to obtain the target configuration file. For example, when the task type is to create a dial test task, the task information contains information such as the service to be detected and the dial test frequency corresponding to the dial test task to be created. The target cluster constructs the configuration file of the dial test task to be created through the task agent component, that is, obtains the target configuration file.
[0136] In a specific embodiment, when the target task is to create a dial test task, modify a dial test task, or other target tasks that require configuration file modification, the target cluster creates a CRD (CustomResource Define) corresponding to the dial test task through a task agent component, and simultaneously modifies the configuration file used by blackbox_exporter.
[0137] Step 704: Update and load the configuration file of the task execution component based on the target configuration file, the task configuration refresh component and the target configuration file to obtain the target task execution component after the target configuration file is loaded.
[0138] In an embodiment of the present application, the task execution component in the target cluster includes a promethues (a monitoring framework tool for dialing tasks) component and a blackbox exporter (an external service discovery agent of Prometheus, used to monitor the status of external services) component; the task configuration refresh component includes a config-reloader component corresponding to promethues, a config-reloader component corresponding to blackbox exporter, and a promethues-operator component. The target cluster monitors the configuration file of the task execution component through the task configuration refresh component. When the configuration file of the task execution component changes, the task configuration refresh component in the target cluster triggers the operation of reloading the configuration file for the task execution component, obtains the target task execution component, enables the task execution component to load the target configuration file, completes the update of the configuration file of the task execution component, and applies the target configuration file to the environment of the target task.
[0139] Step 706, executing the target task according to the target task execution component to obtain the target result corresponding to the target task.
[0140] In the embodiment of the present application, the target cluster executes the dialing test task by completing the target task execution component that loads the target configuration file, and records the monitoring result of the dialing test task.
[0141] In an optional embodiment, the management cluster also includes a task proxy component, a task configuration refresh component and a task execution component. When the target cluster is the management cluster, the management cluster performs management operations on the target task according to the same principles as steps 702 to 706. The interaction process between the task proxy component, the task configuration refresh component and the task execution component will not be repeated in this embodiment.
[0142] In this embodiment, the task agent component locates and modifies the original configuration file in the management target cluster or queries the execution result of the target task based on the task message sent by the task control component to prepare for task migration, creation or modification of the target task; the task configuration refresh component ensures that the modified configuration file can be correctly loaded and applied by the task execution component, ensuring the stable and effective operation of the task in the new environment, and executes the target task through the target task execution component to obtain the result of the task execution, which can realize task management of multiple clusters in the management cluster and improve the operation and maintenance efficiency of multiple clusters in multiple centers.
[0143] In an exemplary embodiment, the task execution component includes a first task execution component and a second task execution component; the task configuration refresh component includes a first task configuration refresh component corresponding to the first task execution component, a second task configuration refresh component corresponding to the second task execution component, and a monitoring component; Figure 8 As shown, step 704 includes steps 802 to 806. Among them:
[0144] Step 802: When the monitoring component confirms that the configuration mode of the first task execution component is updated, the first configuration file of the first task execution component is updated based on the updated configuration mode to obtain an updated first configuration file.
[0145] Among them, the monitoring component is the promethues-operator component, the first task execution component is the promethues component, the configuration method is CRD, and the first configuration file represents the configuration file of the promethues component.
[0146] In an embodiment of the present application, when the target task involves modifying the configuration file of the task execution component, the task agent component in the target cluster will create, modify or delete the CRD corresponding to the dialing task, and the promethues-operator component in the target cluster will listen to the created CRD, which will trigger the operation of updating the first configuration file of the promethues component to obtain the updated first configuration file.
[0147] Step 804: When the first task configuration refresh component determines that the first configuration file is updated, the first task execution component is triggered to load the updated first configuration file, thereby obtaining the first task execution component after the target configuration file is loaded.
[0148] Among them, the first task configuration refresh component is config-reloader corresponding to the promethues component.
[0149] In an embodiment of the present application, when the first configuration file changes, the config-reloader corresponding to the promethues component will monitor the change of the configuration file used by promethues, and trigger the operation of promethues to reload the configuration file through the config-reloader corresponding to the promethues component (that is, the first task configuration refresh component), and obtain the promethues component that completes loading the target configuration file. At this time, the promethues component can execute the target task according to the target configuration file.
[0150] Step 806: After the second task configuration refresh component confirms that the second configuration file is updated, the second task execution component is triggered to load the updated second configuration file, thereby obtaining the second task execution component after the target configuration file is loaded.
[0151] The second task execution component is the blackbox_exporter component, the second task configuration refresh component is the config-reloader component corresponding to the blackbox_exporter component, and the second configuration file represents the configuration file of the blackbox_exporter.
[0152] In the embodiment of the present application, when the proxy cluster modifies the second configuration file used by blackbox_exporter, the config-reloader component corresponding to the blackbox_exporter component monitors the change in the second configuration file used by blackbox_exporter, and triggers the blackbox_exporter component to reload the second configuration file of the dialing task. The embodiment of the present application does not limit the triggering order of the second task configuration refresh component and the first task configuration refresh component.
[0153] In this embodiment, by combining the task proxy component, the task configuration refresh component and the task execution component, after the management cluster sends a task message, the management cluster can automatically load the configuration file of the task execution component, thereby improving the efficiency of the management cluster in task management of the target cluster.
[0154] In a specific embodiment, when the target task is to create a dial test task, the task management method includes:
[0155] For the management cluster, the user logs in through the portal component and specifies the target cluster to create a dial test task. The portal component sends the task creation message to the apiserver component. The apiserver component obtains the relevant cluster information from the database and sends the message to the agent component on the corresponding cluster based on the cluster information. The apiserver component receives the task creation message from the agent component, records the relevant data of the dial test task creation to the database, and returns a creation success message to the portal component.
[0156] For the target cluster, the agent component returns a completion message to the management cluster after receiving the creation message. The agent component creates a custom resource (CRD) corresponding to the dial-up task on the Kubernetes (K8S) cluster, and modifies the configuration file of the blackbox_exporter component to adapt to the new target task. The config-reloader component corresponding to the blackbox_exporter component listens to changes in the configuration file of the blackbox_exporter component, triggering the blackbox_exporter component to reload the configuration file. The prometheus-operator component listens to the creation of CRD and triggers the update of the configuration file of the prometheus component. The config-reloader corresponding to the prometheus component listens to changes in the configuration file of the prometheus component, triggering the prometheus component to reload the configuration file. Prometheus executes the dial-up task according to the settings in the configuration file and saves the results.
[0157] In a specific embodiment, when the target task is to delete a dial test task, the task management method includes:
[0158] For the management cluster, the user logs in through the portal component and specifies the target cluster to initiate the dial test deletion task. The portal component sends the task deletion dial test task message to the apiserver component. The apiserver component obtains the relevant cluster information from the database and sends the message to the agent component on the corresponding cluster based on the cluster information. The apiserver component receives the message from the agent component, records the relevant data records of the dial test deletion task in the database, and returns the message of successful deletion to the portal component.
[0159] For the target cluster, the agent component returns a completion message to the management cluster after receiving the dial test task deletion message. The agent component deletes the custom resource (CRD) corresponding to the dial test task on the Kubernetes (K8S) cluster, and cleans up the relevant configurations in the blackbox_exporter configuration file. The config-reloader component corresponding to the blackbox_exporter component monitors the changes in the configuration file of the blackbox_exporter component, triggering the blackbox_exporter component to reload the configuration file. The prometheus-operator component monitors the deletion of CRD and triggers the update of the configuration file of the prometheus component. The config-reloader corresponding to the prometheus component monitors the changes in the configuration file of the prometheus component and triggers the prometheus component to reload the configuration file. Prometheus re-executes the dial test task according to the settings in the new configuration file, and the deleted dial test task will no longer be executed.
[0160] In a specific embodiment, when the target task is to modify the dial test task, the task management method includes:
[0161] For the management cluster, the user logs in through the portal component and specifies the target cluster to initiate the modification of the dial test task. The portal component sends the task modification message to the apiserver component. The apiserver component obtains the relevant cluster information from the database and sends the task modification message to the agent component on the corresponding cluster based on the cluster information. The apiserver component receives the message from the agent component, records the relevant data records of the modified dial test task from the database, and returns the message of successful modification to the portal component.
[0162] For the target cluster, the agent component returns a completion message to the management cluster after receiving the task modification message. The agent component modifies the custom resource (CRD) corresponding to the dial-up task on the Kubernetes (K8S) cluster, and modifies the relevant configuration in the blackbox_exporter configuration file. The config-reloader component corresponding to the blackbox_exporter component monitors the changes in the configuration file of the blackbox_exporter component, triggering the blackbox_exporter component to reload the configuration file. The prometheus-operator component monitors the changes in the CRD and triggers the update of the configuration file of the prometheus component. The config-reloader corresponding to the prometheus component monitors the changes in the configuration file of the prometheus component and triggers the prometheus component to reload the configuration file. Prometheus executes a new dial-up task according to the new configuration file and saves the result.
[0163] In an exemplary embodiment, a task management system is provided, including a management cluster and a target cluster, wherein the management cluster is used to respond to a target task trigger request, obtain task information corresponding to the target task and the task type corresponding to the target task; based on the task information and the task type, send a task message corresponding to the target task to the target cluster through the task control component, instructing the task agent component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0164] The target cluster is used to receive and obtain the task message sent by the management cluster according to the task agent component, and modify the original configuration file according to the task information in the task message to obtain the target configuration file; the task message contains the target task; based on the task information, the task configuration refresh component and the target configuration file, the configuration file of the task execution component is updated and loaded to obtain the target task execution component after loading the target configuration file; the target task is executed according to the target task execution component to obtain the target result corresponding to the target task.
[0165] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0166] Based on the same inventive concept, the embodiment of the present application also provides a task management device for implementing the task management method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more task management device embodiments provided below can refer to the limitations on the task management method above, and will not be repeated here.
[0167] In an exemplary embodiment, Fig. 9 As shown, a task management device 900 is provided, and the device 900 is applied to manage a cluster, comprising: an acquisition module 901 and a first sending module 902, wherein:
[0168] The acquisition module 901 is used to obtain the task information corresponding to the target task and the task type corresponding to the target task in response to the target task trigger request;
[0169] The first sending module 902 is used to send a task message corresponding to the target task to the target cluster through the task control component based on the task information and task type, and instruct the task proxy component, task configuration refresh component and task execution component in the target cluster to execute the target task.
[0170] In one embodiment, the first sending module 902 is specifically used to query the cluster information corresponding to the target cluster in the database through the task control component and the target cluster included in the task information;
[0171] Construct a task message corresponding to the target task based on the task control component, task information and cluster information;
[0172] The task control component sends the task message to the task agent component of the target cluster, instructing the task agent component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
[0173] In one embodiment, the target task includes creating a dialing test task, deleting a dialing test task, modifying a dialing test task, and modifying a dialing test task execution cluster.
[0174] In one embodiment, the apparatus 900 further includes:
[0175] A receiving module, used to receive a completion message sent by a task agent component in a target cluster;
[0176] The recording module is used to store the execution record of the target task in the database according to the task control component and the completion message.
[0177] In one embodiment, if the target task is to query the execution result of the task, the task information includes the cluster to be queried; the device 900 also includes:
[0178] The query module is used to construct a query task message for the cluster to be queried through the task control component;
[0179] A second sending module is used to send the query task message to the task agent component of the cluster to be queried based on the task control component;
[0180] The display module is used to receive the task execution results returned by the task proxy component of the cluster to be queried, and to display the task execution results corresponding to the cluster to be queried and the cluster to be queried through the page display component.
[0181] In one embodiment, if the target task is to modify the execution cluster of the target task, the task information includes the task identifier, the original cluster and the target cluster; the first sending module 902 is specifically used to construct a first task message of the target task corresponding to the task identifier according to the task control component, the task identifier and the original cluster;
[0182] A second task message for creating a target task is constructed according to the task control component, the task identifier and the target cluster;
[0183] The first task message is sent to the task proxy component of the original cluster based on the task control component, and the second task message is sent to the task proxy component of the target cluster based on the task control component.
[0184] In an exemplary embodiment, Fig.10 As shown, a task management device 1000 is provided, which is applied to a target cluster and includes: a modification module 1001, an update module 1002 and an execution module 1003, wherein:
[0185] The modification module 1001 is used to receive and obtain the task message sent by the management cluster according to the task agent component, and modify the original configuration file according to the task information in the task message to obtain the target configuration file; the task message includes the target task;
[0186] An updating module 1002 is used to update and load the configuration file of the task execution component based on the target configuration file, the task configuration refresh component and the target configuration file, and obtain a target task execution component after the target configuration file is loaded;
[0187] The execution module 1003 is used to execute the target task according to the target task execution component to obtain the target result corresponding to the target task.
[0188] In one embodiment, the task execution component includes a first task execution component and a second task execution component; the task configuration refresh component includes a first task configuration refresh component corresponding to the first task execution component, a second task configuration refresh component corresponding to the second task execution component, and a monitoring component;
[0189] The updating module 1002 is specifically used to update the first configuration file of the first task execution component based on the updated configuration mode after the monitoring component confirms that the configuration mode of the first task execution component is updated, so as to obtain the updated first configuration file;
[0190] When the first task configuration refresh component determines that the first configuration file is updated, the first task execution component is triggered to load the updated first configuration file, thereby obtaining the first task execution component after the target configuration file is loaded;
[0191] When the second task configuration refresh component confirms that the second configuration file is updated, the second task execution component is triggered to load the updated second configuration file, thereby obtaining the second task execution component after the target configuration file is loaded.
[0192] Each module in the above task management device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0193] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.11As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cluster information and task data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task management method is implemented.
[0194] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0195] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0196] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0197] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0198] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0199] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0200] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0201] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A task management method, characterized in that: The method is applied to manage a cluster, and the method comprises: In response to a target task triggering request, obtaining task information corresponding to the target task and a task type corresponding to the target task; Based on the task information and the task type, a task message corresponding to the target task is sent to the target cluster through the task control component, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
2. The method according to claim 1, characterized in that The sending a task message corresponding to the target task to the target cluster based on the task information and the task control component includes: Through the task control component and the target cluster included in the task information, query the cluster information corresponding to the target cluster in the database; Constructing a task message corresponding to the target task according to the task control component, the task information and the cluster information; The task control component sends the task message to the task proxy component of the target cluster, instructing the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task.
3. The method according to claim 1, characterized in that The target tasks include creating a dialing test task, deleting a dialing test task, modifying a dialing test task, and modifying a dialing test task execution cluster.
4. The method according to claim 1, characterized in that: After sending a task message corresponding to the target task to the target cluster based on the task information and the task control component, the method further includes: Receiving a completion message sent by the task agent component in the target cluster; The execution record of the target task is stored in a database according to the task control component and the completion message.
5. The method according to claim 1, characterized in that If the target task is a query task execution result, the task information includes a cluster to be queried; and the method further includes: Constructing a query task message for the cluster to be queried through the task control component; Sending the query task message to the task proxy component of the cluster to be queried based on the task control component; The task execution result returned by the task proxy component of the cluster to be queried is received, and the cluster to be queried and the task execution result corresponding to the cluster to be queried are displayed through a page display component.
6. The method according to claim 1, characterized in that If the target task is to modify the execution cluster of the target task, the task information includes a task identifier, an original cluster, and a target cluster; and sending a task message corresponding to the target task to the target cluster based on the task information and the task control component includes: Deleting a first task message of a target task corresponding to the task identifier according to the task control component, the task identifier and the original cluster; Constructing a second task message for creating the target task according to the task control component, the task identifier and the target cluster; The first task message is sent to the task agent component of the original cluster based on the task control component, and the second task message is sent to the task agent component of the target cluster based on the task control component.
7. A task management method, characterized in that: The method is applied to a target cluster, and the method comprises: The task agent component receives and obtains a task message sent by the management cluster, and modifies the original configuration file according to the task information in the task message to obtain a target configuration file; the task message includes the target task; Based on the target configuration file, the task configuration refresh component and the target configuration file, the configuration file of the task execution component is updated and loaded to obtain the target task execution component after the target configuration file is loaded; The target task is executed according to the target task execution component to obtain a target result corresponding to the target task.
8. The method according to claim 7, characterized in that The task execution component includes a first task execution component and a second task execution component; the task configuration refresh component includes a first task configuration refresh component corresponding to the first task execution component, a second task configuration refresh component corresponding to the second task execution component, and a monitoring component; The updating and loading of the configuration file of the task execution component based on the target configuration file, the task configuration refresh component and the target configuration file to obtain the target task execution component after the target configuration file is loaded includes: When the monitoring component confirms that the configuration mode of the first task execution component is updated, the first configuration file of the first task execution component is updated based on the updated configuration mode to obtain an updated first configuration file; When the first task configuration refresh component determines that the first configuration file is updated, the first task execution component is triggered to load the updated first configuration file, thereby obtaining the first task execution component after the target configuration file is loaded; When the second task configuration refresh component confirms that the second configuration file is updated, the second task execution component is triggered to load the updated second configuration file, thereby obtaining the second task execution component after the target configuration file is loaded.
9. A task management system, characterized in that: The system comprises: A management cluster is used to respond to a target task trigger request, obtain task information corresponding to the target task and the task type corresponding to the target task; based on the task information and the task type, send a task message corresponding to the target task to the target cluster through a task control component, and instruct the task proxy component, the task configuration refresh component and the task execution component in the target cluster to execute the target task; The target cluster is used to receive and obtain the task message sent by the management cluster according to the task agent component, and modify the original configuration file according to the task information in the task message to obtain the target configuration file; the task message contains the target task; based on the task information, the task configuration refresh component and the target configuration file, the configuration file of the task execution component is updated and loaded to obtain the target task execution component after the target configuration file is loaded; the target task is executed according to the target task execution component to obtain the target result corresponding to the target task.
10. A task management device, characterized in that: The device is applied to manage a cluster, and the device comprises: An acquisition module, configured to acquire task information corresponding to the target task and a task type corresponding to the target task in response to a target task trigger request; The first sending module is used to send a task message corresponding to the target task to the target cluster through the task control component based on the task information and the task type, and instruct the task proxy component, task configuration refresh component and task execution component in the target cluster to execute the target task.
