Data change method and device, equipment and medium

By pre-creating and saving the configuration information of multiple webhooks, matching and applying the target webhook configuration information to API requests, the problem of long development cycle and configuration tampering of webhooks is solved, and the efficiency and speed of processing API requests is improved.

CN119396457APending Publication Date: 2025-02-07CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411489725.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the prior art, the development cycle of Webhooks that handle API requests is long and inefficient, and the risk of Webhook configuration being tampered with.

Method used

By pre-creating and saving the configuration information of multiple webhooks, receiving the client's API request, matching the target webhook configuration information, and controlling the pre-configured container to change the target request object in the API request according to the script of the configuration information.

Benefits of technology

Shorten the webhook development cycle for handling API requests, improve the rate of handling emergency problems through webhooks, and reduce the risk of webhook configuration being tampered with.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396457A_ABST
    Figure CN119396457A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a data change method and device, equipment and a medium. In the embodiment of the invention, a Kubernetes apiserver pre-creates and stores Webhook configuration information of a plurality of Webhooks, after an API request is received, the Kubernetes apiserver can determine target Webhook configuration information used for processing the API request according to the plurality of Webhook configuration information, and the target Webhook configuration information is used for processing the API request according to the target Webhook configuration information. And the pre-configured container is controlled to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information, so that the Webhook development period for processing the API request is shortened, and the rate of processing the emergency problem through the Webhook is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data change method, device, equipment and medium. Background Art

[0002] Kubernetes is the de facto standard in the cloud native field. Kubernetes has the advantages of flexible scheduling, agile delivery, elastic expansion and contraction, etc. Change-type webhooks usually run in Kubernetes clusters as containers (Pods), requiring third parties to write, create, update, and delete on demand. Webhooks process the content carried in the Application Programming Interface (API) request submitted to the Kubernetes apiserver in specific scenarios.

[0003] In the related technology, when the Kubernetes apiserver receives an API request sent by a client, a technician needs to create a Webhook for processing the API request based on the API request and write the corresponding Webhook configuration information. The process of creating a Webhook and writing the corresponding Webhook configuration information includes the entire life cycle of prototype verification, development, testing, and production, and is also accompanied by extremely high code development duplication, which leads to a long development cycle and low efficiency for Webhook that processes API requests, and the risk of Webhook configuration being tampered with. Summary of the invention

[0004] The present application provides a data change method, apparatus, device and medium to solve the problems in the prior art of long development cycle and low efficiency of Webhook for processing API requests and the risk of tampering with Webhook configuration.

[0005] The present application provides a data modification method, which includes:

[0006] Receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request;

[0007] Matching the target request type and the target request object with each pre-created and saved Webhook configuration information to determine the target Webhook configuration information for processing the API request;

[0008] The pre-configured container is controlled to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

[0009] Further, the controlling the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information includes:

[0010] The script and the API request are input into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

[0011] Furthermore, the process of determining each Webhook configuration information includes:

[0012] Receive input configuration file;

[0013] Controlling the container to convert the configuration information carried in the configuration file into a preset format, and writing the configuration information in the preset format into a preset Webhook configuration information template;

[0014] The written Webhook configuration information template is determined as a Webhook configuration information.

[0015] Furthermore, the step of writing the configuration information in the preset format into a preset Webhook configuration information template includes:

[0016] Obtain each sub-information and corresponding identifier carried in the configuration information;

[0017] For each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

[0018] Furthermore, the method further comprises:

[0019] If there are other blank fields that are not filled in the Webhook configuration information template, the default values ​​corresponding to the other blank fields are obtained and filled in the other blank fields with the default values.

[0020] Furthermore, the method further comprises:

[0021] If it is identified that any Webhook configuration information is modified or deleted, the container is controlled to regenerate the Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information and replace the modified or deleted Webhook configuration information.

[0022] The present application provides a data modification device, the device comprising:

[0023] A processing module, used to receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request;

[0024] A matching module, used to match the target request type and the target request object with each pre-created and saved Webhook configuration information, and determine the target Webhook configuration information for processing the API request;

[0025] The processing module is used to control the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

[0026] Furthermore, the processing module is specifically used to input the script and the API request into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

[0027] Furthermore, the processing module is also used to receive an input configuration file; control the container to convert the configuration information carried in the configuration file into a preset format, and write the configuration information in the preset format into a preset Webhook configuration information template; and determine the written Webhook configuration information template as a Webhook configuration information.

[0028] Furthermore, the processing module is specifically used to obtain each sub-information and the corresponding identifier carried in the configuration file; for each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, and determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

[0029] Furthermore, the processing module is also used to obtain the saved default values ​​corresponding to other blank fields if there are other blank fields that are not filled in the Webhook configuration information template, and fill the default values ​​into the other blank fields.

[0030] Furthermore, the processing module is also used to control the container to regenerate the Webhook configuration information and replace the modified or deleted Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information if it is identified that any Webhook configuration information is modified or deleted.

[0031] An embodiment of the present application further provides an electronic device, the electronic device comprising a processor, the processor being configured to implement the steps of any of the above-mentioned data changing methods when executing a computer program stored in a memory.

[0032] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the steps of any of the data changing methods described above are implemented.

[0033] An embodiment of the present application further provides a computer program product, which includes: a computer program code, which, when executed on a computer, enables the computer to execute the steps of any of the above-mentioned data changing methods.

[0034] In an embodiment of the present application, an API request sent by a client is received, and a target request type and a target request object carried in the API request are obtained; the target request type and the target request object are matched with each pre-created and saved Webhook configuration information, and the target Webhook configuration information for processing the API request is determined; and a pre-configured container is controlled to change the target request object carried in the API request according to a script corresponding to the target Webhook configuration information. In an embodiment of the present application, the Kubernetes apiserver pre-creates and saves Webhook configuration information of multiple Webhooks. After receiving an API request, the Kubernetes apiserver can determine the target Webhook configuration information for processing the API request based on the multiple Webhook configuration information, and control the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information, thereby shortening the Webhook development cycle for processing API requests and improving the rate of handling emergency issues through Webhooks. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments 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 drawings can be obtained based on these drawings without paying any creative work.

[0036] Figure 1 A schematic diagram of a data change process provided in an embodiment of the present application;

[0037] Figure 2 An architecture flow chart provided for an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the structure of a data changing device provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0041] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0042] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0043] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.

[0044] In the related technology, when the Kubernetes apiserver receives an API request sent by a client, a technician needs to create a Webhook for processing the API request based on the API request and write the corresponding Webhook configuration information. The process of creating a Webhook and writing the corresponding Webhook configuration information includes the entire life cycle of prototype verification, development, testing, and production, and is also accompanied by extremely high code development duplication, which leads to a long development cycle and low efficiency for Webhook that processes API requests, and the risk of Webhook configuration being tampered with.

[0045] Therefore, the embodiment of the present application provides a data change method, device, equipment and medium. In the embodiment of the present application, an API request sent by a client is received, and a target request type and a target request object carried in the API request are obtained; the target request type and the target request object are matched with each pre-created and saved Webhook configuration information, and the target Webhook configuration information for processing the API request is determined; and a pre-configured container is controlled to change the target request object carried in the API request according to a script corresponding to the target Webhook configuration information.

[0046] Embodiment 1:

[0047] Figure 1 A schematic diagram of a data change process provided in an embodiment of the present application, the process includes:

[0048] S101: Receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request.

[0049] A data change method provided in an embodiment of the present application is applied to a Kubernetes apiserver, where the Kubernetes apiserver is deployed on an electronic device, which may be a PC or a server.

[0050] In the embodiment of the present application, the client sends an API request to the Kubernetes apiserver, and the API request carries a target request type and a target request object. The target request type can be deletion, addition, and modification, etc. The target request object is the object to be operated, which can be an API or a container, etc., without limitation.

[0051] After the Kubernetes apiserver receives the API request sent by the client, the Kubernetes apiserver obtains the target request type and target request object carried in the API request.

[0052] S102: Match the target request type and the target request object with each pre-created and saved Webhook configuration information to determine the target Webhook configuration information for processing the API request.

[0053] In actual application, Webhook usually runs in Kubernetes cluster as Pod, requiring third party to write corresponding Webhook configuration information as needed, and process API requests submitted to Kubernetes apiserver in specific scenarios according to the corresponding Webhook configuration information. However, in related technologies, every time an API request is received, code development needs to be started from scratch. On the one hand, this increases the workload of code development; on the other hand, when Webhook runs in Kubernetes cluster as a container, the newly written Webhook always needs to be deployed once before it can work. Therefore, there is a certain delay between the generation of demand and its implementation, and Webhook cannot be quickly implemented in Kubernetes cluster.

[0054] Based on this, in order to shorten the Webhook development cycle for processing API requests and increase the rate of handling emergency problems through Webhooks, in an embodiment of the present application, multiple Webhooks are pre-built and saved, corresponding Webhook configuration information is written for each Webhook, and the Webhook configuration information of each Webhook is saved in the Kubernetes apiserver, avoiding the process of starting code development from scratch every time an API request is received.

[0055] The Webhook configuration information carries the request type and the request object, and the Kubernetes apiserver saves each Webhook configuration information. When the Kubernetes apiserver receives an API request, it can obtain the target request type and the target request object carried in the API request, and determine the target Webhook configuration information corresponding to the target request type and the target request object in each saved Webhook configuration information.

[0056] S103: Control the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

[0057] In order to process API requests, a runtime framework is constructed in an embodiment of the present application. The runtime framework runs in a Kubernetes cluster in the form of a container. The runtime framework creates multiple Webhooks and saves the Webhook configuration information corresponding to each Webhook. The Kubernetes apiserver can call the container to process the API request using the target Webhook configuration information.

[0058] Specifically, the Kubernetes apiserver sends the API request to the container corresponding to the runtime framework. After receiving the API request, the container matches the API request with each webhook configuration information again, determines the target webhook configuration information for processing the API request, and uses the target webhook configuration information to change the target request object carried in the API request.

[0059] The container corresponding to the runtime framework returns the processed API request to the Kubernetes apiserver, and the Kubernetes apiserver performs subsequent processes based on the processed API request.

[0060] In an embodiment of the present application, Webhook configuration information of multiple Webhooks is pre-created and saved in the Kubernetes apiserver. After receiving an API request, the Kubernetes apiserver can determine the target Webhook configuration information for processing the API request based on the multiple Webhook configuration information, and control the pre-configured container to change the target request object carried in the API request according to the target Webhook configuration information, thereby shortening the Webhook development cycle for processing API requests and improving the rate of handling emergency problems through Webhook.

[0061] Embodiment 2:

[0062] In order to shorten the Webhook development cycle for processing API requests and improve the rate of handling emergency problems through Webhook, based on the above embodiments, in the embodiment of the present application, the target request type and the target request object are matched with each pre-created and saved Webhook configuration information, and the target Webhook configuration information for processing the API request is determined to include:

[0063] Get the request type and request object carried in each saved Webhook configuration information;

[0064] The Webhook configuration information that matches the carried request type and request object with the target request type and the target request object is determined as the target Webhook configuration information.

[0065] In an embodiment of the present application, the Webhook configuration information carries a request type and a request object. The Kubernetes apiserver can match the target Webhook configuration information for processing the API request from each Webhook configuration information based on the request type and request object carried in each Webhook configuration information and the target request type and target request object carried in the API request.

[0066] Specifically, the Kubernetes apiserver obtains the request type and request object carried in each pre-created and saved Webhook configuration information, and obtains the target request type and target request object carried in the received API request. The Kubernetes apiserver determines that the request type carried in each Webhook configuration information is the target request type and the request object is the Webhook configuration information of the target request object, and determines the Webhook configuration information as the target Webhook configuration information for processing the API request.

[0067] Embodiment 3:

[0068] In order to shorten the Webhook development cycle for processing API requests and improve the rate of handling emergency problems through Webhook, based on the above embodiments, in the embodiment of the present application, the control of the pre-configured container changes the target request object carried in the API request according to the script corresponding to the target Webhook configuration information, including:

[0069] The script and the API request are input into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

[0070] In the embodiment of the present application, each Webhook configuration information is stored in the container. After receiving an API request, the container determines the target Webhook configuration information for processing the API request based on the API request and each Webhook configuration information stored locally. The method by which the container determines the target Webhook configuration information in lua format is consistent with the method by which the Kubernetes apiserver determines the target Webhook configuration information, which will not be described in detail here.

[0071] In an embodiment of the present application, the container also stores a script corresponding to each Webhook configuration information. After determining the target Webhook configuration information, the container determines the script corresponding to the target Webhook configuration information, and inputs the script into the corresponding script language virtual machine or script language interpreter in the API request, so that the virtual machine or script language interpreter changes the target request object carried in the API request according to the change rules carried in the script.

[0072] In the embodiment of the present application, the scripts stored in the container can be in multiple formats, and each format of the script corresponds to a different virtual machine or script language interpreter. For example, if the script is in lua format, the API request and the script are input into the lua virtual machine, that is, the format of the script is consistent with the format of the virtual machine.

[0073] Specifically, the container inputs the Lua script and the API request into the Lua virtual machine, so that the Lua virtual machine changes the target request object carried in the API request according to the processing conditions carried in the Lua script, and outputs the processing result, which is the processed API request.

[0074] In an embodiment of the present application, the virtual machine or script language interpreter may also be configured in the Webhook, that is, after the container determines the target Webhook configuration information, the container sends the API request to the Webhook corresponding to the target Webhook configuration information, and the Webhook calls its corresponding script, and inputs the script and the API request into the virtual machine or script language interpreter, and performs change processing on the target request object carried in the API request.

[0075] In addition, after the container obtains the processing result output by the virtual machine, the container can also write the processing result into a processing message, and send the written processing message to the Kubernetes apiserver, so that the Kubernetes apiserver obtains the processing result.

[0076] Embodiment 4:

[0077] In order to shorten the development cycle of Webhook for processing API requests and improve the speed of handling emergency problems through Webhook, based on the above embodiments, in the embodiment of the present application, the process of determining each Webhook configuration information includes:

[0078] Receive input configuration file;

[0079] Controlling the container to convert the configuration information carried in the configuration file into a preset format, and writing the configuration information in the preset format into a preset Webhook configuration information template;

[0080] The written Webhook configuration information template is determined as a Webhook configuration information.

[0081] In order to shorten the Webhook development cycle for processing API requests and improve the rate of handling emergency problems through Webhook, in an embodiment of the present application, multiple Webhooks are pre-built, that is, multiple configuration files are pre-written, each configuration file carries the Webhook configuration information written for the corresponding Webhook, and the Webhook configuration information of each Webhook is saved in the Kubernetes apiserver.

[0082] Specifically, in an embodiment of the present application, the Kubernetes apiserver receives an input configuration file, wherein the configuration file is a ConfigMap, and the information carried in the configuration file is in any format, such as lua, etc. The container also stores a preset format, which is a format that the Kubernetes apiserver can read and write. The container obtains configuration information from the configuration file and converts the format of the configuration information into the preset format.

[0083] Furthermore, in order to better manage each Webhook configuration information, in an embodiment of the present application, the container will obtain the configuration information from the configuration file, convert it into a preset format, and write it into a preset Webhook configuration information template. The container will determine the written Webhook configuration information template as a Webhook configuration information and send it to the Kubernetes apiserver.

[0084] The following description assumes that the data format contained in ConfigMap is in Lua format. The following method is also applicable to other formats:

[0085] ConfigMap contains the group, version, and kind information of the Kubernetes resource object to be processed, the namespace selector and object selector acting on the request object, an array specifying the running stage, a lua script containing multiple lua functions, and an array specifying the lua function name. Among them, the group and version, the namespace filter, and the object filter are used to identify the request object; the kind is used to identify the request type; the lua script of the lua function is used to change the API request, and the array of lua function names lists the functions contained in the lua script.

[0086] Moreover, in the embodiment of the present application, after receiving the ConfigMap, the container will perform a validity check on the ConfigMap, and will load the above fields after the check passes. And generate the following according to the loaded content: 1. Webhook configuration information (MutatingWebhook Configuration), which describes what kind of API request will be sent to which webhook for processing by the Kubernetes apiserver after meeting what conditions; 2. Based on the factory method, a Webhook handler (Webhook handler) is instantiated, i.e., Webhook, which will expose a URL path to receive API requests, and call the lua script to change the operation content in the received API request.

[0087] The runtime framework verifies the legitimacy of the monitored ConfigMap, including:

[0088] 1. Check whether the Group, Version, and Kind fields conform to the Kubernetes primitives and can match the corresponding request objects;

[0089] 2. Verify that the name space Selector and object Selector conform to Kubernetes primitives;

[0090] 3. Check whether the value in stages corresponds to the allowed value of Mutating WebhookConfiguration.rules.operations;

[0091] 4. Verify whether the contents in the Lua script are all legal Lua functions;

[0092] 5. Check whether the values ​​in the funcNames array are all from the function names in the Lua script.

[0093] The funcNames array is allowed to contain only some function names in the Lua script, not all. This design is to take into account that in the actual operating environment, Kubernetes administrators or users can have better adjustment control over Lua functions to support temporary enabling or disabling of certain Lua functions. At the same time, the Webhook handler instantiated by the runtime framework will call Lua functions in the order specified by funcNames, which allows Kubernetes administrators or users to have a certain amount of design and arrangement space for how to call Lua functions.

[0094] After the container corresponding to the runtime framework passes the validity check of the ConfigMap, if the ConfigMap is a creation event, the container will instantiate a new webhook handler; if the ConfigMap is an update event, the container will update the MutatingWebhook Configuration as needed according to the content carried in the ConfigMap, and reload the Lua script as needed, that is, the configuration information in Lua format.

[0095] The lua function is designed to accept only one parameter, which is a map in the golang context, where the key is a string type and the value is an interface{}, that is, any type; in the lua context, it is a lua table type; whether it is golang or lua, this parameter is reflected as a key-value pair. This allows Kubernetes administrators or users to write lua scripts without having to worry about the original format of the request object in Kubernetes semantics. This is also the basis for instantiating the Webhook handler through the factory method to directly call the Lua function, avoiding the problem of decoding and encoding the original type of the request object during the Webhook writing process in traditional Kubernetes.

[0096] At the same time, the Lua function is designed to have no return value, that is, all modifications to the request object in the Lua function will be directly reflected in the request object itself, which reduces the difficulty for Kubernetes administrators or users to write Lua functions and avoids reading the return value of the Lua function, thereby improving performance.

[0097] Moreover, in the embodiment of the present application, a lazy loading design is adopted for the loading of Lua functions. Under this design, the Webhook handler will not recognize the update of the ConfigMap content at the first time. It will check the ConfigMap content update and try to load the unloaded Lua function only when and when the new change request is received and processed. This makes it more flexible for Kubernetes administrators or users to adjust the Lua script content and avoid the additional Lua script function loading overhead caused by frequent script changes.

[0098] The processing of Lua script content is based on the solution of the open source community library. Under this solution, the text content of the Lua script will be pre-compiled into a byte stream to facilitate sharing between different Lua virtual machines. When there are multiple Lua virtual machines, loading the pre-compiled byte stream will have better performance than directly letting the Lua virtual machines reload the Lua script separately.

[0099] Embodiment 5:

[0100] In order to shorten the Webhook development cycle for processing API requests and improve the rate of handling emergency problems through Webhook, based on the above embodiments, in the embodiment of the present application, the configuration information in the preset format is written into the preset Webhook configuration information template, including:

[0101] Obtain each sub-information and corresponding identifier carried in the configuration file;

[0102] For each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

[0103] In an embodiment of the present application, there are blank fields in the Webhook configuration information template for filling in the Webhook configuration information. In order to accurately fill in the Webhook configuration information template, the Kubernetes apiserver stores the identifier of the target sub-information to be filled in corresponding to each blank field in the Webhook configuration information template. The configuration file received by the Kubernetes apiserver also carries each sub-information and the corresponding identifier. The Kubernetes apiserver can fill in each sub-information carried in the configuration file into the Webhook configuration information template according to the identifier of the target sub-information to be filled in corresponding to each blank field in the saved Webhook configuration information template.

[0104] Specifically, for each sub-information, the Kubernetes apiserver determines the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, and determines the target blank field whose identifier is the identifier of the sub-information. The Kubernetes apiserver writes the sub-information into the target blank field.

[0105] In order to shorten the development cycle of Webhooks for processing API requests and improve the speed of handling emergency problems through Webhooks, based on the above embodiments, in the embodiment of the present application, the method further includes:

[0106] If there are other blank fields that are not filled in the Webhook configuration information template, the default values ​​corresponding to the other blank fields are obtained and filled in the other blank fields with the default values.

[0107] In the embodiment of the present application, since the Webhook configuration information template is applicable to multiple Webhook configuration information, the number of blank fields included in the Webhook configuration information template may be greater than the number of sub-information carried in the configuration information.

[0108] Based on this, after the Kubernetes apiserver writes each sub-information carried in the Webhook configuration information into the corresponding target blank field, there may be other blank fields that are not filled in. In order to make the final Webhook configuration information complete, in an embodiment of the present application, the Kubernetes apiserver also saves the default value corresponding to each blank field in the Webhook configuration information template. If there are other blank fields that are not filled in the Webhook configuration information template, the default values ​​corresponding to the other blank fields are obtained and the default values ​​are filled in the other blank fields.

[0109] Embodiment 6:

[0110] In order to shorten the development cycle of Webhooks for processing API requests and improve the speed of handling emergency problems through Webhooks, based on the above embodiments, in the embodiment of the present application, the method further includes:

[0111] If it is identified that any Webhook configuration information is modified or deleted, the container is controlled to regenerate the Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information and replace the modified or deleted Webhook configuration information.

[0112] In an embodiment of the present application, the Kubernetes apiserver also monitors the locally saved Webhook configuration information. If the Kubernetes apiserver identifies that any Webhook configuration information has been modified or deleted, the Kubernetes apiserver restores the Webhook configuration information.

[0113] Specifically, if the Kubernetes apiserver recognizes that any Webhook configuration information is modified or deleted, the Kubernetes apiserver controls the container to regenerate the Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information and replace the modified or deleted Webhook configuration information.

[0114] In addition, in an embodiment of the present application, the operation of monitoring the Webhook configuration information can also be completed by the container, that is, a specific controller is run in the container corresponding to the runtime framework, and the controller is responsible for monitoring the Webhook configuration information (Mutating Webhook Configuration) in the Kubernetesapiserver. When it is found that the Mutating Webhook Configuration is updated, it is checked whether the content has been tampered with. If it has been tampered with, it is automatically recreated according to the loaded Lua format Webhook configuration information; when it is found that the MutatingWebhookConfiguration is deleted, it is automatically recreated according to the loaded Lua format target Webhook configuration information.

[0115] The specific implementation method of monitoring can be directly based on the informer technology of Kubernetes, or it can be implemented by the controller-runtime or operator encapsulated on the basis of the informer.

[0116] Figure 2 An architecture flow chart provided for an embodiment of the present application, such as the Figure 2 As shown, the process includes: Webhook configuration information creation process, API request processing process and Webhook configuration information monitoring process.

[0117] The Webhook configuration information creation process includes: the Kubernetes apiserver receives the input configuration file (ConfigMap) and sends the configuration file to the container corresponding to the runtime framework. The container generates the corresponding Webhook configuration information according to the configuration file and sends the Webhook configuration information to the Kubernetes apiserver.

[0118] The API request processing process includes: the API sends an API request to the Kubernetes apiserver, and the Kubernetes apiserver determines whether there is a target Webhook configuration information for processing the API request based on the target operation type and target request object carried in the API request. If so, the API request is sent to the container, and the container processes the API request based on the target Webhook configuration information.

[0119] The monitoring process of the Webhook configuration information includes: the Kubernetes apiserver or the container monitors the Webhook configuration information in the Kubernetes apiserver. If other modified Webhook configuration information is identified, the control container regenerates the other Webhook configuration information based on the original Lua format Webhook configuration information and sends it to the Kubernetes apiserver for replacement.

[0120] Embodiment 7:

[0121] Based on the same inventive concept, the embodiment of the present application provides a data changing device. Figure 3 A schematic diagram of a data changing device structure provided in the embodiment of the present application is provided in FIG. Figure 3 , the device comprises:

[0122] The processing module 301 is used to receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request;

[0123] A matching module 302, configured to match the target request type and the target request object with each pre-created and saved Webhook configuration information, and determine the target Webhook configuration information for processing the API request;

[0124] The processing module 301 is further used to control the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

[0125] In a possible implementation, the processing module 301 is specifically used to input the script and the API request into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

[0126] In a possible implementation, the processing module 301 is also used to receive an input configuration file; control the container to convert the configuration information carried in the configuration file into a preset format, and write the configuration information in the preset format into a preset Webhook configuration information template; and determine the written Webhook configuration information template as a Webhook configuration information.

[0127] In a possible implementation, the processing module 301 is specifically used to obtain each sub-information and the corresponding identifier carried in the configuration file; for each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, and determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

[0128] In a possible implementation, the processing module 301 is further used to obtain the saved default values ​​corresponding to other blank fields if there are other unfilled blank fields in the Webhook configuration information template, and fill the default values ​​into the other blank fields.

[0129] In a possible implementation, the processing module 301 is also used to control the container to regenerate the Webhook configuration information and replace the modified or deleted Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information if any Webhook configuration information is identified as being modified or deleted.

[0130] Embodiment 8:

[0131] Based on the same inventive concept, an embodiment of the present application provides an electronic device, which can implement the steps of the data changing method discussed above. Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, it includes: a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;

[0132] The memory 403 stores a computer program. When the program is executed by the processor 401, the processor 401 performs the following steps:

[0133] Receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request;

[0134] Matching the target request type and the target request object with each pre-created and saved Webhook configuration information to determine the target Webhook configuration information for processing the API request;

[0135] The pre-configured container is controlled to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

[0136] In a possible implementation, controlling the preconfigured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information includes:

[0137] The script and the API request are input into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

[0138] In a possible implementation, the process of determining each Webhook configuration information includes:

[0139] Receive input configuration file;

[0140] Controlling the container to convert the configuration information carried in the configuration file into a preset format, and writing the configuration information in the preset format into a preset Webhook configuration information template;

[0141] The written Webhook configuration information template is determined as a Webhook configuration information.

[0142] In a possible implementation, writing the configuration information in the preset format into a preset Webhook configuration information template includes:

[0143] Obtain each sub-information and corresponding identifier carried in the configuration file;

[0144] For each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

[0145] In a possible implementation, the method further includes:

[0146] If there are other blank fields that are not filled in the Webhook configuration information template, the default values ​​corresponding to the other blank fields are obtained and filled in the other blank fields with the default values.

[0147] In a possible implementation, the method further includes:

[0148] If it is identified that any Webhook configuration information is modified or deleted, the container is controlled to regenerate the Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information and replace the modified or deleted Webhook configuration information.

[0149] Since the principle of solving the problem by the above electronic device is similar to the data changing method, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.

[0150] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 402 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0151] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0152] Embodiment 9:

[0153] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor executes any of the data change methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the data change method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.

[0154] Embodiment 10:

[0155] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the data change methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the data change method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.

[0156] In an embodiment of the present application, the Kubernetes apiserver pre-creates and saves Webhook configuration information of multiple Webhooks. After receiving an API request, the Kubernetes apiserver can determine the target Webhook configuration information for processing the API request based on the multiple Webhook configuration information, and control the pre-configured container to process the API request according to the script corresponding to the target Webhook configuration information, thereby shortening the Webhook development cycle for processing API requests and improving the rate of handling emergency problems through Webhook.

[0157] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0158] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0159] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0161] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data modification method, characterized in that: The method comprises: Receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request; Matching the target request type and the target request object with each pre-created and saved Webhook configuration information to determine the target Webhook configuration information for processing the API request; The pre-configured container is controlled to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

2. The method according to claim 1, characterized in that The controlling the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information includes: The script and the API request are input into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

3. The method according to claim 1, characterized in that The process of determining each Webhook configuration information includes: Receive input configuration file; Controlling the container to convert the configuration information carried in the configuration file into a preset format, and writing the configuration information in the preset format into a preset Webhook configuration information template; The written Webhook configuration information template is determined as a Webhook configuration information.

4. The method according to claim 3, characterized in that Writing the configuration information in the preset format into the preset Webhook configuration information template includes: Obtain each sub-information and corresponding identifier carried in the configuration information; For each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

5. The method according to claim 4, characterized in that The method further comprises: If there are other blank fields that are not filled in the Webhook configuration information template, the default values ​​corresponding to the other blank fields are obtained and filled in the other blank fields with the default values.

6. The method according to claim 1, characterized in that The method further comprises: If it is identified that any Webhook configuration information is modified or deleted, the container is controlled to regenerate the Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information and replace the modified or deleted Webhook configuration information.

7. A data changing device, characterized in that: The device comprises: A processing module, used to receive an API request sent by a client, and obtain a target request type and a target request object carried in the API request; A matching module, used to match the target request type and the target request object with each pre-created and saved Webhook configuration information, and determine the target Webhook configuration information for processing the API request; The processing module is further used to control the pre-configured container to change the target request object carried in the API request according to the script corresponding to the target Webhook configuration information.

8. The device according to claim 7, characterized in that The processing module is specifically used to input the script and the API request into a corresponding scripting language virtual machine or a scripting language interpreter, so that the virtual machine or the scripting language interpreter changes the target request object carried in the API request according to the change rule carried in the script.

9. The device according to claim 7, characterized in that The processing module is further used to receive an input configuration file; control the container to convert the configuration information carried in the configuration file into a preset format, and write the configuration information in the preset format into a preset Webhook configuration information template; The written Webhook configuration information template is determined as a Webhook configuration information.

10. The device according to claim 9, characterized in that The processing module is specifically used to obtain each sub-information and the corresponding identifier carried in the configuration file; for each sub-information, obtain the identifier of the target sub-information corresponding to each blank field in the pre-saved Webhook configuration information template and the identifier corresponding to the sub-information, determine the target blank field corresponding to the sub-information; and write the sub-information into the target blank field.

11. The device according to claim 10, characterized in that The processing module is also used to obtain the saved default values ​​corresponding to other blank fields if there are other blank fields that are not filled in the Webhook configuration information template, and fill the default values ​​into the other blank fields.

12. The device according to claim 7, characterized in that The processing module is also used to control the container to regenerate the Webhook configuration information and replace the modified or deleted Webhook configuration information according to other configuration files corresponding to the saved Webhook configuration information if it is identified that any Webhook configuration information is modified or deleted.

13. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the steps of the data changing method according to any one of claims 1 to 6 when executing a computer program stored in a memory.

14. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the data changing method as claimed in any one of claims 1 to 6.

15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the steps of the data changing method as claimed in any one of claims 1 to 6.