Container cluster-based task processing methods, devices, equipment, media, and products
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-13
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]本发明提供一种基于容器集群的任务处理方法、装置、设备、介质及产品,用以解决现有技术中人工干预执行流水线任务,导致任务执行耗时长、效率低的缺陷,实现快速执行流水线任务的目的
[0033]本发明提供的基于容器集群的任务处理方法、装置、设备、介质及产品,获取通过通信中心得到的资源对象标识;通过通信中心,从数据库中查找与资源对象标识对应的资源配置文件,该资源配置文件包括:至少两个任务、以及至少两个任务的执行顺序;当确定资源配置文件中的资源状态参数为资源初始参数时,按照执行顺序,依次执行至少两个任务,本发明通过获取资源对象标识,找到资源配置文件,便可以实现多个任务按照流水线顺序依次执行,实现了一键、快速执行流水线任务的目的,解决了现有技术中需要人工干预执行流水线任务,导致流水线任务执行耗时长、效率低的问题。
Smart Images

Figure CN113849291B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a task processing method, apparatus, device, medium and product based on container clusters. Background Technology
[0002] In current public or private clouds, instances can be created by declaring only the target without specifying the process, simplifying the writing of parallel computing code. However, this approach offers limited control over the program's execution, making it particularly challenging when handling pipelined tasks. For example, multiple tasks may not execute in a specified order, and subsequent tasks may depend on the results of previous tasks to execute effectively.
[0003] Therefore, in the existing technology, the execution of pipeline-type tasks can only rely on manual intervention, resulting in long task execution time and low efficiency. Summary of the Invention
[0004] This invention provides a task processing method, apparatus, device, medium, and product based on container clusters, which solves the defects of manual intervention in the execution of pipeline tasks in the prior art, resulting in long task execution time and low efficiency, and achieves the goal of rapid execution of pipeline tasks.
[0005] This invention provides a task processing method based on a container cluster, comprising:
[0006] Obtain the resource object identifier obtained through the communication center;
[0007] The communication center retrieves the resource configuration file corresponding to the resource object identifier from the database. The resource configuration file includes at least two tasks and the execution order of the at least two tasks.
[0008] When the resource status parameter in the resource configuration file is determined to be the resource initial parameter, the at least two tasks are executed sequentially according to the execution order.
[0009] According to a task processing method based on a container cluster provided by the present invention, the step of sequentially executing the at least two tasks according to the execution order includes:
[0010] Determine the current task, add the task identifier of the current task to the array in the resource configuration file, set the task status parameter in the array to the task initial parameter, and execute the current task;
[0011] When the task status parameter of the current task is determined to be the task completion parameter and the resource status parameter is the resource operation parameter, the task identifier of the next task is added to the array, the task status parameter in the array is set to the task initial parameter, and the next task is executed until at least two tasks are completed.
[0012] According to a task processing method based on a container cluster provided by the present invention, the step of adding the task identifier of the current task to an array in the resource configuration file, setting the task status parameters in the array to task initial parameters, and executing the current task includes:
[0013] Add the task identifier of the current task to the array, and set the task status parameters in the array to the initial parameters of the task;
[0014] Update the resource status parameters to the resource operation parameters, execute the current task, and update the task status parameters in the array to the task start parameters;
[0015] And after determining that the current task has been completed, the task status parameters in the array are updated to the task completion parameters.
[0016] According to a task processing method based on a container cluster provided by the present invention, the method further includes:
[0017] When an execution exception occurs during the execution of any of the tasks, the following process is performed: add the task identifier of the exception task to the array, set the task status parameter in the array to the task initial parameter, execute the exception task, and update the task status parameter in the array to the task start parameter;
[0018] Monitor whether the abnormal task can be executed successfully;
[0019] When the abnormal task is executed successfully, the task status parameter corresponding to the abnormal task is updated to the task completion parameter;
[0020] When the abnormal task fails, the processing procedure is repeated. When the number of times the processing procedure is executed reaches a preset number, the resource status parameter is updated to the resource error parameter.
[0021] According to a task processing method based on a container cluster provided by the present invention, after updating the resource status parameter to a resource error parameter when the number of times the second processing procedure is executed reaches a preset number, the method further includes:
[0022] Receive jump command;
[0023] Based on the jump instruction, the resource status parameters are updated to the resource running parameters, the task identifier of the next task of the abnormal task is added to the array, the task status parameters in the array are set to the task initial parameters, and the next task of the abnormal task is executed.
[0024] According to a task processing method based on a container cluster provided by the present invention, the method further includes:
[0025] When it is determined that at least two tasks have been executed successfully, the resource status parameter is updated to the resource completion parameter, and the processing of at least two tasks is completed.
[0026] The present invention also provides a task processing device based on a container cluster, comprising:
[0027] The acquisition module is used to obtain the resource object identifier obtained through the communication center.
[0028] The lookup module is used to search for a resource configuration file corresponding to the resource object identifier in the database through the communication center. The resource configuration file includes at least two tasks and the execution order of the at least two tasks.
[0029] An execution module is used to execute the at least two tasks sequentially according to the execution order when it is determined that the resource status parameter in the resource configuration file is the resource initial parameter.
[0030] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the container cluster-based task processing methods described above.
[0031] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the container cluster-based task processing methods described above.
[0032] The present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, implement the steps of any of the above-described container cluster-based task processing methods.
[0033] The present invention provides a task processing method, apparatus, device, medium, and product based on container clusters. It obtains a resource object identifier obtained through a communication center; through the communication center, it searches a database for a resource configuration file corresponding to the resource object identifier. This resource configuration file includes at least two tasks and the execution order of the at least two tasks. When the resource status parameters in the resource configuration file are determined to be resource initial parameters, at least two tasks are executed sequentially according to the execution order. By obtaining the resource object identifier and finding the resource configuration file, the present invention enables multiple tasks to be executed sequentially in a pipeline order, achieving the goal of one-click and rapid execution of pipeline tasks. This solves the problem in the prior art where manual intervention is required to execute pipeline tasks, resulting in long execution times and low efficiency. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0035] Figure 1 This is one of the flowcharts of the task processing method based on container clusters provided by the present invention;
[0036] Figure 2 This is the second flowchart of the task processing method based on container clusters provided by the present invention;
[0037] Figure 3 This is a schematic diagram of the structure of the container cluster-based task processing device provided by the present invention;
[0038] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0040] The following is combined with Figures 1-2 This invention describes a task processing method based on a container cluster.
[0041] This invention provides a task processing method based on a container cluster. This method can be applied to smart terminals, such as mobile phones, computers, and tablets, as well as servers. The following description uses the application of this method to a server as an example; however, it should be noted that this is merely illustrative and not intended to limit the scope of protection of this invention. Other descriptions in this invention's embodiments are also illustrative and not intended to limit the scope of protection of this invention, and will not be described in detail thereafter.
[0042] The container cluster in this invention is a Kubernetes (k8s) cluster.
[0043] Let me briefly introduce Kubernetes (k8s). k8s is used to manage containerized applications across multiple hosts (nodes) in a cloud platform. A pod is the smallest scheduling and resource unit in k8s, consisting of one or more containers running on various nodes. Let me also briefly introduce a k8s cluster. A cluster is a group of node computers (nodes) used to run containerized applications. Whether on physical machines or virtual machines, k8s clusters can achieve cross-machine scheduling and running of containers, either locally or in the cloud, freeing k8s containers from the constraints of a single computer. k8s can be deployed on any node computer. The specific implementation of the container cluster-based task processing method of this invention is as follows... Figure 1 As shown:
[0044] Step 101: Obtain the resource object identifier obtained through the communication center.
[0045] Specifically, the computer nodes in a container cluster include control nodes and worker nodes, with the control node serving as the cluster's management and control center. The control node comprises a communication center (API Server) and a control center (controllermanager). The API Server provides various CRUD operations and communication interfaces for resources, acting as the data bus and data center for the entire Kubernetes cluster. The communication interfaces include REST interfaces, which are used to perform data lookup operations in Etcd. The controllermanager stores the listener program (pipeline controller).
[0046] In addition, in Kubernetes, only the API Server can directly manipulate the database (Etcd).
[0047] Specifically, after the resource configuration file (pipeline.yaml) is written to Etcd via the API Server, an event is triggered. The listener will detect the triggered task event and obtain the resource object identifier of the task event through the API Server. The resource object identifier is a unique identifier that identifies the task event, and it also uniquely identifies the resource configuration file. See the following code for details:
[0048]
[0049] The parameters "name" and / or "uid" can serve as resource object identifiers. Here, "kind" indicates the type of the newly created resource object, "pipeline" indicates a pipeline task (meaning the newly created resource object type is a pipeline task), "metadata" is used to declare relevant resource information, "name" is the resource name (unique within the same namespace), and "uid" is the resource identifier (unique across the entire container cluster). Users can customize the specific identifier for the resource object based on their application scenarios and actual work needs.
[0050] Specifically, the code above is encoded in pipeline.yaml. The pipeline.yaml file is a description file that defines a series of tasks and their execution order. YAML is another markup language that can easily express data formats such as lists, hash tables, and scalars.
[0051] Step 102: Through the communication center, retrieve the resource configuration file corresponding to the resource object identifier from the database.
[0052] The resource configuration file includes at least two tasks and the execution order of at least two tasks.
[0053] For example, when the resource object is identified as "97762656-f00a-4390-9706-7ef38638ce5b", the APIServer searches for the pipeline.yaml corresponding to 97762656-f00a-4390-9706-7ef38638ce5b in Etcd.
[0054] It can be seen that when Kubernetes detects resource changes in Etcd, it will search for the changed resources and execute corresponding operations based on the changes. This invention utilizes this feature of Kubernetes; after the resource configuration file is written to Etcd through the communication center, no manual operation is required to achieve pipelined tasks executing each task in the correct order, saving labor costs and improving user experience.
[0055] Step 103: When it is determined that the resource status parameter in the resource configuration file is the resource initial parameter, at least two tasks are executed in sequence according to the execution order.
[0056] In one specific embodiment, the execution of at least two tasks sequentially is a loop operation, which is implemented as follows: determine the current task, add the task identifier of the current task to the array in the resource configuration file, set the task status parameter in the array to the task initial parameter, and execute the current task; when it is determined that the task status parameter of the current task is the task completion parameter and the resource status parameter is the resource running parameter, add the task identifier of the next task to the array, set the task status parameter in the array to the task initial parameter, and execute the next task, until at least two tasks are completed.
[0057] In one specific embodiment, the execution of the current task is implemented as follows: add the task identifier of the current task to the array, set the task status parameter in the array to the task initial parameter; update the resource status parameter to the resource running parameter, execute the current task, and update the task status parameter in the array to the task start parameter; and after determining that the current task has been executed, update the task status parameter in the array to the task completion parameter.
[0058] Specifically, the following example code will illustrate this further:
[0059]
[0060]
[0061] In this document, `spec` describes a series of tasks and their execution order. `steps` under `spec` determines the execution order of each task and is represented by `spec.steps`. In this embodiment, steps-a, step-b, and step-c are used as examples. `status` represents the resource status, and `phase` under `status` represents the resource status parameters, represented by `status.phase`. `Init` represents the resource initialization parameters, `Running` represents the resource running parameters, and `Completed` represents the resource completion parameters. `steps` under `status` represents the task parameters, represented by `status.steps`, and `createtime` represents the creation time.
[0062]
[0063] In this context, "phase" under "steps" represents the task status parameters, denoted as "steps.phase". "init" represents the initial parameters of the task, "started" represents the parameters for starting the task, and "completed" represents the parameters for completing the task.
[0064] The following explanation uses the current tasks as step-a and step-b as an example to illustrate the task loop execution process:
[0065] The current task is identified as step-a. The task identifier (step-a) is added to the array of task parameters (steps), and the task status parameter (steps.phase) in the array is set to the task initialization parameter (init). Step-a is then executed. When the task status parameter (steps.phase) of step-a is determined to be the completed parameter (completed), and the resource status parameter (phase) is the running parameter (Running), it is checked whether a next task exists. If a next task exists, the task identifier (step-b) of the next task is determined, and step-b is added to the array. The task status parameter (steps.phase) in the array is set to the task initialization parameter (init), and step-b is executed. This process continues until all tasks are completed. When no next task exists, all tasks are confirmed to be completed, and the resource status parameter (phase) is updated to the completed parameter (Completed).
[0066] The following explanation uses task step-a as an example to illustrate the specific execution process of the current task:
[0067] The current task is identified as step-a. The task identifier (step-a) of step-a is added to the array of task parameters (steps). The task status parameter (steps.phase) in the array is set to the task initial parameter (init). Step-a is executed. At this time, the task status parameter (steps.phase) is updated to the task start parameter (started). After step-a is completed, the task status parameter (steps.phase) is updated to the task completion parameter (completed).
[0068] Among them, any one of the middle tasks does not include the first task.
[0069] The following is an explanation of the specific execution process of the current task, taking task step-a as the first task:
[0070] When the resource status parameter (phase) is determined to be the resource initialization parameter (Init), step-a is added to the task parameter (steps) array. Simultaneously, the task status parameter (steps.phase) is set to the task initialization parameter (init), and the resource status parameter (phase) is updated to the resource running parameter (Running). Step-a is executed; at this point, the task status parameter (steps.phase) is updated to the task start parameter (started), and after step-a is confirmed to have completed, the task status parameter (steps.phase) is updated to the task completion parameter (completed).
[0071] The following is an explanation of the specific execution process of the current task, using task step-a as the last task as an example:
[0072] Add the task identifier (step-a) of step-a to the array of task parameters (steps), set the task status parameter (steps.phase) in the array to the task initial parameter (init), execute step-a, at this time, update the task status parameter (steps.phase) to the task start parameter (started), and after confirming that step-a has been executed, update the task status parameter (steps.phase) to the task completion parameter (completed), and after confirming that all tasks have been executed, update the resource status parameter (phase) to the resource completion parameter (Completed).
[0073] Specifically, the resource status parameter (phase) is the resource initialization parameter (Init). When the first task is executed, if the task status parameter (steps.phase) of the first task is the task initialization parameter (init), the resource status parameter (phase) is updated to the resource running parameter (Running). After that, when executing any next task, the resource status parameter (phase) is always the resource running parameter (Running).
[0074] This invention describes each task and its execution order using pipeline.yaml. This allows for one-click execution of pipeline tasks without manual intervention, saving labor costs. Furthermore, this invention is highly efficient, less prone to errors, and effectively improves the execution efficiency of pipeline tasks, as well as enhancing the user experience.
[0075] In one specific embodiment, the specific implementation method for handling execution exceptions during the execution of any task is as follows: Figure 2 As shown:
[0076] Step 201: When an execution exception occurs during the execution of any task, perform the following processing procedure: add the task identifier of the exception task to the array, set the task status parameter in the array to the task initial parameter, execute the exception task, and update the task status parameter in the array to the task start parameter.
[0077] For example, if an execution exception occurs during the execution of step-c, the second processing procedure is executed based on step-c. Step-c is added back to the task parameter (steps) array, and the task status parameter (steps.phase) is set to the task initial parameter (init). Step-c is then executed, and at this time, the task status parameter (steps.phase) is updated to the task start parameter (started).
[0078] Step 202: Monitor whether the abnormal task can be executed successfully. If the abnormal task is executed successfully, proceed to step 203; otherwise, proceed to step 204.
[0079] For example, monitor whether step-c of the second processing procedure can be executed successfully. If it is, step-c is executed successfully, and step 203 is executed; otherwise, step 204 is executed.
[0080] Step 203: Update the task status parameters corresponding to the abnormal task to the task completion parameters.
[0081] For example, set the task status parameter (steps.phase) of step-c to the task completion parameter (completed).
[0082] Step 204: Repeat the processing procedure. When the number of times the processing procedure is executed reaches the preset number, update the resource status parameters to resource error parameters.
[0083] Specifically, when the number of times the processing procedure is executed reaches the preset number, a voice alarm is issued, prompting manual intervention. The user then uses a command-line tool to successfully execute the abnormal task. After the abnormal task is successfully executed, the resource status parameter is updated from the resource error parameter (Error) to the resource running parameter (Running), and then the next task is executed automatically.
[0084] In one specific embodiment, when the number of times the processing procedure is executed reaches a preset number, the resource status parameters are updated to resource error parameters, and a jump instruction is received; based on the jump instruction, the resource status parameters are updated to resource running parameters, and the task identifier of the next task of the abnormal task is added to the array, the task status parameters in the array are set to the task initial parameters, and the next task of the abnormal task is executed.
[0085] Specifically, the jump instruction can be automatically generated after the resource status parameters are updated to resource error parameters, or it can be triggered by manual intervention.
[0086] In the process of executing pipeline tasks, when an execution exception occurs, the present invention first initiates a self-repair strategy, that is, repeats the processing procedure to repair the abnormal task at the time of the execution exception. If the self-repair strategy cannot effectively solve the exception problem, a jump instruction is triggered to execute the next task of the abnormal task, so as to ensure the completion of the entire pipeline task and effectively improve the user experience.
[0087] In one specific embodiment, when it is determined that the at least two tasks have been executed successfully, the resource status parameter is updated to the resource completion parameter, and the at least two tasks are completed.
[0088] The resource completion parameter can be represented by "Completed".
[0089] This invention solves the problem of executing multiple tasks in a specified order in a container cluster by using resource configuration files and a listener. It records the defined task content and execution order in the spec file, and the execution process, status, and results in status. The listener uses event and resource status parameters to execute corresponding operations to complete the entire pipeline task. The entire process requires no manual intervention, reducing manual maintenance costs and improving task execution efficiency and user experience.
[0090] The present invention provides a task processing method, apparatus, device, medium, and product based on container clusters. It obtains a resource object identifier obtained through a communication center; through the communication center, it searches a database for a resource configuration file corresponding to the resource object identifier. This resource configuration file includes at least two tasks and the execution order of the at least two tasks. When the resource status parameters in the resource configuration file are determined to be resource initial parameters, at least two tasks are executed sequentially according to the execution order. By obtaining the resource object identifier and finding the resource configuration file, the present invention enables multiple tasks to be executed sequentially in a pipeline order, achieving the goal of one-click and rapid execution of pipeline tasks. This solves the problem in the prior art where manual intervention is required to execute pipeline tasks, resulting in long execution times and low efficiency.
[0091] The following describes the container cluster-based task processing device provided by the present invention. The container cluster-based task processing device described below corresponds to the container cluster-based task processing method described above; repeated details will not be repeated. Specifically, as follows... Figure 3 As shown:
[0092] The acquisition module 301 is used to acquire the resource object identifier obtained through the communication center;
[0093] The lookup module 302 is used to search for the resource configuration file corresponding to the resource object identifier in the database through the communication center. The resource configuration file includes at least two tasks and the execution order of at least two tasks.
[0094] When the execution module 303 determines that the resource status parameter in the resource configuration file is the resource initial parameter, it executes at least two tasks in the order of execution.
[0095] In one specific embodiment, the execution module 303 is specifically used to determine the current task, add the task identifier of the current task to an array in the resource configuration file, set the task status parameter in the array to the task initial parameter, and execute the current task; when it is determined that the task status parameter of the current task is the task completion parameter and the resource status parameter is the resource running parameter, the task identifier of the next task is added to the array, the task status parameter in the array is set to the task initial parameter, and the next task is executed, until at least two tasks are completed.
[0096] In one specific embodiment, the execution module 303 is specifically used to add the task identifier of the current task to the array, set the task status parameters in the array to the task initial parameters, update the resource status parameters to the resource running parameters, execute the current task, and update the task status parameters in the array to the task start parameters; and after determining that the current task has been executed, update the task status parameters in the array to the task completion parameters.
[0097] In one specific embodiment, the execution module 303 includes an exception execution submodule, which is used to perform the following processing procedures when an execution exception occurs during the execution of any task: adding the task identifier of the exception task to an array, setting the task status parameter in the array to the task initial parameter, executing the exception task, and updating the task status parameter in the array to the task start parameter; monitoring whether the exception task can be executed successfully; when the exception task is executed successfully, updating the task status parameter corresponding to the exception task to the task completion parameter; when the exception task fails to execute, repeating the processing procedure, and when the number of times the processing procedure is executed reaches a preset number, updating the resource status parameter to the resource error parameter.
[0098] In one specific embodiment, the exception execution submodule is further configured to receive a jump instruction; based on the jump instruction, update the resource status parameters to resource running parameters, add the task identifier of the next task of the exception task to the array, set the task status parameters in the array to the task initial parameters, and execute the next task of the exception task.
[0099] In one specific embodiment, the task processing device based on the container cluster further includes an update module, which is used to update the resource status parameters to resource completion parameters when it is determined that at least two tasks have been successfully executed, indicating that at least two tasks have been completed.
[0100] This invention utilizes an acquisition module 301 to acquire a resource object identifier obtained through a communication center; and a search module 302 to search for a resource configuration file corresponding to the resource object identifier from a database through the communication center. This resource configuration file includes at least two tasks and their execution order. When the execution module 303 determines that the resource status parameters in the resource configuration file are the resource initial parameters, it executes at least two tasks sequentially according to the execution order. By acquiring the resource object identifier and finding the resource configuration file, this invention enables multiple tasks to be executed sequentially in a pipeline order, achieving one-click and rapid execution of pipeline tasks. This solves the problem of long execution times and low efficiency in existing technologies that require manual intervention to execute pipeline tasks.
[0101] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include a processor 401, a communications interface 402, a memory 403, and a communication bus 404. The processor 401, communications interface 402, and memory 403 communicate with each other via the communication bus 404. The processor 401 can invoke logical instructions in the memory 403 to execute a container cluster-based task processing method. This method includes: obtaining a resource object identifier obtained through a communication center; searching a database for a resource configuration file corresponding to the resource object identifier through the communication center, wherein the resource configuration file includes at least two tasks and the execution order of the at least two tasks; and when the resource status parameters in the resource configuration file are determined to be resource initial parameters, executing at least two tasks sequentially according to the execution order.
[0102] Furthermore, the logical instructions in the aforementioned memory 403 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0103] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the task processing method based on container clusters provided by the above methods, the method comprising: obtaining a resource object identifier obtained through a communication center; searching a resource configuration file corresponding to the resource object identifier from a database through the communication center, wherein the resource configuration file comprises: at least two tasks and the execution order of at least two tasks; when it is determined that the resource status parameter in the resource configuration file is a resource initial parameter, executing at least two tasks sequentially according to the execution order.
[0104] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the aforementioned container cluster-based task processing methods. The method includes: obtaining a resource object identifier obtained through a communication center; searching a database for a resource configuration file corresponding to the resource object identifier through the communication center, wherein the resource configuration file includes at least two tasks and an execution order of the at least two tasks; and when it is determined that the resource status parameter in the resource configuration file is a resource initial parameter, executing at least two tasks sequentially according to the execution order.
[0105] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0106] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A task processing method based on a container cluster, characterized in that, The computer nodes in the container cluster include control nodes and worker nodes, wherein the control node includes a communication center; the method includes: Obtain the resource object identifier obtained through the communication center; The communication center retrieves the resource configuration file corresponding to the resource object identifier from the database. The resource configuration file includes at least two tasks and the execution order of the at least two tasks. When the resource status parameter in the resource configuration file is determined to be the resource initial parameter, the at least two tasks are executed sequentially according to the execution order. Obtain the resource object identifier obtained through the communication center, including: After the resource configuration file is written to the database through the communication center, a task event is triggered. The listening program detects the triggered task event and obtains the resource object identifier of the task event through the communication center.
2. The task processing method based on container clusters according to claim 1, characterized in that, The step of executing the at least two tasks sequentially according to the execution order includes: Determine the current task, add the task identifier of the current task to the array in the resource configuration file, set the task status parameter in the array to the task initial parameter, and execute the current task; When the task status parameter of the current task is determined to be the task completion parameter and the resource status parameter is the resource operation parameter, the task identifier of the next task is added to the array, the task status parameter in the array is set to the task initial parameter, and the next task is executed until at least two tasks are completed.
3. The task processing method based on container clusters according to claim 2, characterized in that, The step of adding the task identifier of the current task to the array in the resource configuration file, setting the task status parameters in the array to the task initial parameters, and executing the current task includes: Add the task identifier of the current task to the array, and set the task status parameters in the array to the initial parameters of the task; Update the resource status parameters to the resource operation parameters, execute the current task, and update the task status parameters in the array to the task start parameters; And after determining that the current task has been completed, the task status parameters in the array are updated to the task completion parameters.
4. The task processing method based on a container cluster according to claim 3, characterized in that, The method further includes: When an execution exception occurs during the execution of any of the tasks, the following process is performed: add the task identifier of the exception task to the array, set the task status parameter in the array to the task initial parameter, execute the exception task, and update the task status parameter in the array to the task start parameter; Monitor whether the abnormal task can be executed successfully; When the abnormal task is executed successfully, the task status parameter corresponding to the abnormal task is updated to the task completion parameter; When the abnormal task fails, the processing procedure is repeated. When the number of times the processing procedure is executed reaches a preset number, the resource status parameter is updated to the resource error parameter.
5. The task processing method based on container clusters according to claim 4, characterized in that, When the number of times the processing procedure is executed reaches a preset number, after updating the resource status parameter to the resource error parameter, the procedure further includes: Receive jump command; Based on the jump instruction, the resource status parameters are updated to the resource running parameters, the task identifier of the next task of the abnormal task is added to the array, the task status parameters in the array are set to the task initial parameters, and the next task of the abnormal task is executed.
6. The task processing method based on a container cluster according to any one of claims 1-5, characterized in that, The method further includes: When it is determined that at least two tasks have been executed successfully, the resource status parameter is updated to the resource completion parameter, and the processing of at least two tasks is completed.
7. A task processing device based on a container cluster, characterized in that, The computer nodes in the container cluster include control nodes and worker nodes, and the control node includes a communication center; the device includes: The acquisition module is used to obtain the resource object identifier obtained through the communication center. The lookup module is used to search for a resource configuration file corresponding to the resource object identifier in the database through the communication center. The resource configuration file includes at least two tasks and the execution order of the at least two tasks. An execution module is configured to execute the at least two tasks sequentially according to the execution order when it is determined that the resource status parameter in the resource configuration file is the resource initial parameter; The acquisition module is specifically used to write the resource configuration file into the database through the communication center, trigger a task event, listen to the corresponding task event triggered, and obtain the resource object identifier of the task event through the communication center.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the task processing method based on a container cluster as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the container cluster-based task processing method as described in any one of claims 1 to 6.
10. A computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, implement the steps of the task processing method based on a container cluster as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Task execution method and device, equipment and storage medium
CN113434279A