Dependency list acquisition method, kubernetes resource protection method, and terminal

By using an inverted index table and FIFO queue management, the problem of low efficiency in obtaining the dependency list is solved, the efficiency of obtaining and updating the dependency list is improved, and the protection of Kubernetes resources and data consistency are ensured.

CN117033740BActive Publication Date: 2026-04-10XFUSION DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XFUSION DIGITAL TECH CO LTD
Filing Date
2023-06-28
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

The existing technology of obtaining the dependency list by traversing the resource list is inefficient, resulting in low efficiency in updating the dependency list and the cache.

Method used

An inverted index table is used to quickly locate resource identifiers. Dependencies are quickly obtained through words and indexes in the inverted index table, simplifying the data structure of the dependency list. A FIFO queue is used to manage the operation order, reducing redundant data comparison and update operations.

Benefits of technology

It improves the efficiency of dependency list retrieval and update performance, reduces redundant data processing, ensures the accuracy and consistency of data updates, and protects the integrity of Kubernetes resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117033740B_ABST
    Figure CN117033740B_ABST
Patent Text Reader

Abstract

The application discloses a dependency list acquisition method, a Kubernetes resource protection method and a terminal. An inverted index table is obtained based on a resource list. The identity of a first Kubernetes resource and the identity of a second Kubernetes resource are obtained from the resource list based on the word and the index, and the second Kubernetes resource has a dependency relationship with the first Kubernetes resource. A first dependency list is obtained based on the identity of the first Kubernetes resource and the identity of the second Kubernetes resource. The identity of the resource is obtained through the inverted index, the influence of the efficiency of cyclic iteration and one-by-one matching on the acquisition of the dependency list is reduced, and therefore the efficiency of acquiring the dependency list 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 browsers, and in particular to a dependency list obtaining method, a Kubernetes resource protection method and a terminal. BACKGROUND

[0002] At present, a dependency list is obtained by traversing a resource list, the dependency list is used to indicate the dependency relationship between resources, and the dependency list is saved in a cache. Whenever the resource list is updated, the updated dependency list is determined by traversing the resource list again, and the historical dependency list in the cache is updated based on the updated dependency list.

[0003] However, the above method has low efficiency in obtaining the dependency list. SUMMARY

[0004] Embodiments of the present application provide a dependency list obtaining method, a Kubernetes resource protection method and a terminal, which can improve the efficiency of obtaining the dependency list. The technical solutions are as follows.

[0005] In a first aspect, a dependency list obtaining method is provided, which is applied to a browser, and the method comprises: obtaining an inverted index table based on a resource list, the resource list comprising data of at least one Kubernetes resource, and the inverted index table comprising a word in the resource list and an index corresponding to the word; obtaining an identifier of a first Kubernetes resource and an identifier of a second Kubernetes resource from the resource list based on the word and the index, the second Kubernetes resource having a dependency relationship with the first Kubernetes resource; and obtaining a first dependency list based on the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource, the first dependency list being used to protect at least one of the first Kubernetes resource or the second Kubernetes resource, and the first dependency list comprising the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource.

[0006] Since the inverted index table records the word in the resource list and the index corresponding to the word, the corresponding word can be quickly located in the resource list through the inverted index table, so as to obtain the identifier of the resource, without traversing each piece of data in the resource list and each field in each piece of data, and without matching each piece of data in the resource list and each field in each piece of data, thereby reducing the influence of the loop traversal and the one-by-one matching on the efficiency of obtaining the dependency list, and improving the efficiency of obtaining the dependency list.

[0007] In a possible implementation, the obtaining, based on the word and the index, the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource from the resource list comprises: determining, based on the index, the data of the first Kubernetes resource from the resource list, the index being used to identify a position of the data of the first Kubernetes resource in the resource list; and obtaining, based on the word, the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource from the data of the first Kubernetes resource, the data of the first Kubernetes resource comprising a key-value pair, a key in the key-value pair comprising the word, and a value in the key-value pair comprising the identifier of the second Kubernetes resource.

[0008] Since the index can be used to quickly locate the data of the first Kubernetes resource in the resource list without matching the data of each resource in the resource list one by one, and since the word and the key-value pair can be used to quickly obtain the identifier of the Kubernetes resource, the speed of obtaining the resource identifier is improved.

[0009] In a possible implementation, the obtaining, based on the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource, the first dependency list comprises: in response to determining that the first Kubernetes resource is a parent resource of the second Kubernetes resource, writing the identifier of the first Kubernetes resource into a value field of the first dependency list, and writing the identifier of the second Kubernetes resource into a key field of the first dependency list; or, in response to determining that the first Kubernetes resource is a child resource of the second Kubernetes resource, writing the identifier of the first Kubernetes resource into the key field of the first dependency list, and writing the identifier of the second Kubernetes resource into the value field of the first dependency list.

[0010] By taking the identifier of the child resource as the index (key) in the dependency list and taking the identifier of the parent resource as the value in the dependency list, the data structure of the dependency list is unified, which is equivalent to determining, from the perspective of the child resource, which parent resources the child resource has from the value field included in the child resource. Therefore, when an operation instruction is triggered for the child resource, the identifier of the parent resource can be quickly retrieved based on the dependency list, so as to prompt which parent resources will be affected when the child resource is operated.

[0011] In a possible implementation, the first dependency list includes a first version of a dependency list and a second version of a dependency list, and the resource list includes a first version of a resource list and a second version of a resource list, the first version of the dependency list is obtained based on the first version of the resource list, the second version of the dependency list is obtained based on the second version of the resource list, and after the first dependency list is obtained based on the inverted index table and the resource list, the method further includes: in response to an operation type corresponding to the first version of the resource list being modification, comparing the first version of the dependency list and the second version of the dependency list to obtain a first dependency relationship, the first dependency relationship being a dependency relationship that is modified in the first version of the dependency list compared with the second version of the dependency list; and saving the first dependency relationship to a queue.

[0012] Since the data amount of the dependency list is far less than that of the resource list, the dependency list is equivalent to a simplified resource list, and redundant data irrelevant to determining dependency is removed from the resource list, and the dependency list almost only includes data that needs to be considered for determining dependency, for example, a dependency relationship can be composed of identifiers of two resources. Therefore, compared with comparing two original resource lists, comparing two dependency lists has less data amount to process and greatly reduced processing complexity, thereby improving the speed and performance of comparison.

[0013] In a possible implementation, the second dependency list is saved in the cache of the computing device, and after the first dependency relationship is saved to the queue, the method further includes: in response to an operation instruction, obtaining the first dependency relationship from the queue, the operation instruction indicating deletion or modification of the first Kubernetes resource; and synchronizing the first dependency relationship to the second dependency list to obtain a third dependency list.

[0014] Since the dependency list in the cache is updated again when the operation instruction is triggered, the dependency relationship indicated by the dependency list in the cache and the dependency relationship indicated by the obtained resource list are kept consistent at intervals, for example, the dependency list in the cache is updated once when the update instruction is triggered once, and the dependency relationship indicated by the dependency list in the cache and the dependency relationship indicated by the received resource list do not need to be kept consistent in real time, thereby reducing the number of update operations on the cache and improving the update performance.

[0015] In a possible implementation, the queue is a first-in first-out queue, and the saving of the first dependency relationship into the queue comprises adding the first dependency relationship to a tail end of the first-in first-out queue; and the obtaining of the first dependency relationship from the queue comprises obtaining the first dependency relationship from a head end of the first-in first-out queue.

[0016] Since the operation data is saved through the FIFO queue, the access order of the operation data is limited, the execution order of the operation data has certain certainty, that is, the operation data is executed in the order from early to late according to the time point at which the operation data is obtained, and therefore the accuracy of data updating is improved. For example, if an operation data indicating to add a first Kubernetes resource is obtained first, and then an operation data indicating to delete the first Kubernetes resource is obtained. If the access order of the two operation data is not limited, the operation data indicating to delete the first Kubernetes resource may be taken out from the queue first and the delete operation is executed, and the operation data indicating to add the first Kubernetes resource is taken out later and the add operation is executed, and according to the operation data indicating to delete the first Kubernetes resource, the first Kubernetes resource does not exist, which causes a conflict. By saving the operation data through the first-in first-out queue, the conflict is avoided, and the accuracy of data synchronization is improved.

[0017] In a possible implementation, the inverted index table further comprises a number of occurrences of the word in the resource list, and before the comparison of the dependency list of the first version and the dependency list of the second version, the method further comprises: comparing the number of the Kubernetes resource identifiers obtained based on the word with the number of occurrences; and determining that the number of the Kubernetes resource identifiers is same as the number of occurrences.

[0018] Since the step of subsequent modification comparison is performed again in the case where the number of the Kubernetes resource identifiers in the inverted index table is same as the number of occurrences of the word in the resource list, pre-checking of modification comparison is implemented, the risk of missing statistics is reduced, and therefore the accuracy of comparison is improved.

[0019] In a possible implementation, after the comparison of the number of the Kubernetes resource identifiers obtained based on the word with the number of occurrences, the method further comprises: in response to a determination that the number of the Kubernetes resource identifiers is different from the number of occurrences, displaying first prompt information.

[0020] In a case where the number of the identifiers of the Kubernetes resources in the determined inverted index table is different from the number of occurrences of the word in the resource list, the prompt information is displayed, so that the user is prompted of possible errors, and thus the accuracy of the comparison is improved.

[0021] In a possible implementation, after the first dependency relationship is synchronized to the second dependency list to obtain a third dependency list, the method further includes: obtaining the identifier of the second Kubernetes resource based on the identifier of the first Kubernetes resource and the third dependency list; and displaying second prompt information based on the identifier of the second Kubernetes resource, the second prompt information being used to prompt a risk caused by the first Kubernetes resource to the second Kubernetes resource.

[0022] By prompting the risk of the parent resource of the child resource caused by the deletion or modification operation on the child resource before the child resource is deleted or modified, the running of the parent resource affected by the deletion or modification of the child resource is reduced, and thus the parent resource is protected.

[0023] In a second aspect, a Kubernetes resource protection method is provided, and the method is applied to a browser, and the method includes:

[0024] In response to detecting a modification operation or a deletion operation triggered for a first Kubernetes resource, obtaining an identifier of a second Kubernetes resource dependent on the first Kubernetes resource based on the identifier of the first Kubernetes resource and a dependency list;

[0025] Displaying second prompt information in an interface of the browser based on the identifier of the second Kubernetes resource, the second prompt information including the identifier of the second Kubernetes resource, and the second prompt information being used to prompt a risk caused by the first Kubernetes resource to the second Kubernetes resource.

[0026] Because the browser side obtains the identifier of the parent resource dependent on the resource based on the dependency list by means of human-computer interaction when detecting the deletion operation or the modification operation on the resource, and outputs prompt information including the identifier of the parent resource, the risk of deleting or modifying the child resource is prompted, the influence of the deletion or modification of the child resource on the parent resource is reduced, and the first Kubernetes resource and the second Kubernetes resource are protected.

[0027] In a third aspect, a dependency list obtaining apparatus is provided, and the apparatus is applied to a browser, and the apparatus includes:

[0028] The first obtaining module is configured to obtain an inverted index table based on a resource list, the resource list including data of at least one Kubernetes resource, and the inverted index table including a word in the resource list and an index corresponding to the word;

[0029] The second obtaining module is configured to obtain an identification of a first Kubernetes resource and an identification of a second Kubernetes resource from the resource list based on the word and the index, the second Kubernetes resource having a dependency relationship with the first Kubernetes resource;

[0030] The third obtaining module is configured to obtain a first dependency list based on the identification of the first Kubernetes resource and the identification of the second Kubernetes resource, the first dependency list being used to protect at least one of the first Kubernetes resource or the second Kubernetes resource, and the first dependency list including the identification of the first Kubernetes resource and the identification of the second Kubernetes resource.

[0031] In a possible implementation, the second obtaining module is configured to determine data of a first Kubernetes resource from the resource list based on the index, the index being used to identify a position of the data of the first Kubernetes resource in the resource list; and obtain the identification of the first Kubernetes resource and the identification of the second Kubernetes resource from the data of the first Kubernetes resource based on the word, the data of the first Kubernetes resource including a key-value pair, a key in the key-value pair including the word, and a value in the key-value pair including the identification of the second Kubernetes resource.

[0032] In a possible implementation, the third obtaining module is configured to, in response to determining that the first Kubernetes resource is a parent resource of the second Kubernetes resource, write the identification of the first Kubernetes resource into a value field of the first dependency list and write the identification of the second Kubernetes resource into a key field of the first dependency list; or, in response to determining that the first Kubernetes resource is a child resource of the second Kubernetes resource, write the identification of the first Kubernetes resource into the key field of the first dependency list and write the identification of the second Kubernetes resource into the value field of the first dependency list.

[0033] In a possible implementation, the first dependency list includes a first version of a dependency list and a second version of the dependency list, and the resource list includes a first version of a resource list and a second version of the resource list, the first version of the dependency list is obtained based on the first version of the resource list, the second version of the dependency list is obtained based on the second version of the resource list, and the apparatus further includes:

[0034] The comparison module is configured to, in response to the operation type corresponding to the first version of the resource list being modification, compare the first version of the dependency list and the second version of the dependency list to obtain a first dependency relationship, the first dependency relationship being a dependency relationship that is modified in the first version of the dependency list compared with the second version of the dependency list.

[0035] The saving module is configured to save the first dependency relationship to a queue.

[0036] In a possible implementation, the computing device has a second dependency list saved in a cache, and the apparatus further includes:

[0037] The fourth obtaining module is configured to, in response to an operation instruction, obtain the first dependency relationship from the queue, the operation instruction indicating deleting or modifying the first Kubernetes resource.

[0038] The updating module is configured to synchronize the first dependency relationship to the second dependency list to obtain a third dependency list.

[0039] In a possible implementation, the queue is a first-in-first-out queue, and the saving module is configured to add the first dependency relationship to a tail end of the first-in-first-out queue.

[0040] The fourth obtaining module is configured to obtain the first dependency relationship from a head end of the first-in-first-out queue.

[0041] In a possible implementation, the apparatus further includes:

[0042] The comparison module is configured to compare the number of identities of the Kubernetes resource obtained based on the word with the occurrence frequency.

[0043] The determination module is configured to determine that the number of identities of the Kubernetes resource is the same as the occurrence frequency.

[0044] In a possible implementation, the apparatus further includes:

[0045] The display module is configured to, in response to determining that the number of identities of the Kubernetes resource is different from the occurrence frequency, display first prompt information.

[0046] In a possible implementation, the apparatus further includes:

[0047] a fifth obtaining module, configured to obtain the identifier of the second Kubernetes resource based on the identifier of the first Kubernetes resource and the third dependency list;

[0048] a display module, configured to display second prompt information based on the identifier of the second Kubernetes resource, the second prompt information being used to prompt a risk caused by the first Kubernetes resource to the second Kubernetes resource.

[0049] In a fourth aspect, a protection apparatus of a Kubernetes resource is provided, and the apparatus is applied to a browser, and the apparatus includes:

[0050] an obtaining module, configured to obtain an identifier of a second Kubernetes resource based on an identifier of the first Kubernetes resource and a dependency list in response to a modification operation or a deletion operation triggered for a first Kubernetes resource, the dependency list being obtained based on the method in the first aspect or any possible implementation of the first aspect;

[0051] a display module, configured to display second prompt information in an interface of the browser based on the identifier of the second Kubernetes resource, the second prompt information being used to prompt a risk caused by the first Kubernetes resource to the second Kubernetes resource.

[0052] In a fifth aspect, a terminal is provided, and the terminal includes a display, a processor and a memory, the memory stores computer program instructions, the display is configured to display an interface, and the processor executes the computer program instructions, so that the terminal executes the method in the first aspect or any possible implementation of the first aspect or the method in the second aspect.

[0053] In a sixth aspect, a chip is provided, and the chip includes a memory and a processor, the memory is configured to store computer instructions, and the processor is configured to call and run the computer instructions from the memory, so as to execute the method in the first aspect or any possible implementation of the first aspect or the method in the second aspect.

[0054] In a seventh aspect, a computer readable storage medium is provided, and the storage medium stores at least one instruction, and the instruction is used to make a computer execute the method in the first aspect or any possible implementation of the first aspect or the method in the second aspect when the instruction is run on the computer.

[0055] In an eighth aspect, a computer program product is provided, which comprises one or more computer program instructions, when the computer program instructions are loaded and executed by a computer, causing the computer to perform the method of the first aspect or any optional mode of the first aspect or the method of the second aspect. BRIEF DESCRIPTION OF DRAWINGS

[0056] Figure 1 is a schematic diagram of an architecture of a computing system provided by an embodiment of the present application;

[0057] Figure 2A is a flowchart of a dependency query method provided by an embodiment of the present application;

[0058] Figure 2B is a flowchart of another dependency query method provided by an embodiment of the present application;

[0059] Figure 3 is a flowchart of a resource protection method provided by an embodiment of the present application;

[0060] Figure 4 is a flowchart of a process of obtaining a dependency relationship based on an inverted index provided by an embodiment of the present application;

[0061] Figure 5 is a flowchart of a dependency query method provided by an embodiment of the present application;

[0062] Figure 6 is a flowchart of a process of updating a dependency list based on an operation queue provided by an embodiment of the present application;

[0063] Figure 7 is a structural schematic diagram of a dependency query apparatus 600 provided by an embodiment of the present application;

[0064] Figure 8A is a structural schematic diagram of an apparatus for obtaining a dependency list provided by an embodiment of the present application;

[0065] Figure 8B is a structural schematic diagram of a protection apparatus for a Kubernetes resource provided by an embodiment of the present application;

[0066] Figure 9 is a structural schematic diagram of a terminal provided by an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical scheme and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0068] Some terms and concepts related to the embodiments of the present application will be explained below.

[0069] (1) Kubernetes

[0070] Kubernetes, also known as K8s or kube, is an open-source container orchestration platform for automating deployment, scaling, and management of containerized applications.

[0071] (2) Kubernetes resources

[0072] Kubernetes resources refer to resources in Kubernetes that are used to deploy, run, or manage applications. Kubernetes resources can also be referred to as Kubernetes objects. Examples of Kubernetes resources include deployments, stateful sets, pods, config maps, secrets, services, replica sets, namespaces, volumes, daemon sets, jobs, or cron jobs.

[0073] A pod is the smallest computing unit in Kubernetes, which represents one or more related containers and the storage and network resources they share. A config map is a collection of key-value pairs, which is used to store non-sensitive configuration data such as application environment variables, command-line parameters, configuration files, and other data. A secret is used to store and manage sensitive configuration data. A service provides a single stable network entry for a group of pods. A deployment is used to manage a set of pod replicas to achieve horizontal scaling, rollback, and updates for applications. A replica set is used to keep a specified number of replicas running and automatically create new replicas when the number of replicas is insufficient. A namespace is used to divide a Kubernetes cluster into multiple virtual clusters, which can be used to isolate a group of resources and manage and authorize them separately. A volume provides persistent storage resources to containers or pods. A stateful set is used to make one or more stateful pods run in a fixed order and have unique identifiers and network names. A daemon set runs one or more pods on each node to perform specific tasks such as log collection, monitoring, data collection, and other tasks. A job and cron job are used to perform one-time or scheduled tasks such as data backup or periodic data cleanup. In addition to the above-mentioned resource types, Kubernetes resources can also be application programming interfaces (APIs). For example, Kubernetes resources for horizontalpodautoscaler, verticalpodautoscaler, poddisruption budget, network policy, and other resources are used to implement automatic scaling, network security, load balancing, and other advanced functions.

[0074] For the sake of simplicity, the embodiments of the present application will be represented in the form of "type + identifier" to simplify the representation of specific resources without introducing understanding difficulties, for example, pod1 represents a resource of type pod and name 1.

[0075] (3) Key-value pair

[0076] A key-value pair is a data structure used to store and represent a set of related data. A key-value pair includes a key and a value. The key is an identifier that identifies the location or attribute of the data; the value is the data content or attribute associated with the key. The key can also be called an index, keyword, or keyword.

[0077] For the sake of simplicity, the embodiments of the present application subsequently use the form of "key->value" to simplify the data structure of key-value pair without introducing understanding difficulties, for example, use pod1->deployment 1 to represent a key-value pair with the key of pod1 and the value of deployment 1. The symbol -> in the computer program code can be replaced by a colon, an equal sign or other symbols used to represent the separator between the key and the value.

[0078] Some possible implementations of the present application involve the case that one key in a key-value pair corresponds to multiple values. For the sake of simplicity, the embodiments of the present application subsequently use the curly braces to identify the multiple values corresponding to one key without introducing understanding difficulties, and the curly braces contain each value contained in the key. For example, use the form of pod1->{deployment 1, deployment2} to simplify the key-value pair with the key of pod1 and the value including deployment 1 and deployment 2.

[0079] (4) Resource list

[0080] The resource list includes the data of one or more Kubernetes resources. For example, one entry in the resource list is the data of one Kubernetes resource. For example, the resource list is a file in the format of JavaScript Object Notation (JSON), and the data of one resource is a JSON object in the resource list. For example, one key-value pair in the resource list is the data of one resource. For example, the pod list includes the data of one or more pods, and the deployment list includes the data of one or more deployments.

[0081] For example, in Kubernetes and OKD (Origin Community Distribution of Kubernetes), after an operation such as deployment, update or deletion in a cluster, the Kubernetes API Server sends a notification message containing a resource list of the executed operation to the corresponding subscriber (such as kubectl command line tool, controller or other browsers), which is usually represented in JSON format, containing detailed information of the operated resource, such as resource type, name, namespace, label, configuration parameter, etc. By parsing this resource list, the subscriber can obtain information about the operation and perform corresponding processing as needed. For example, when using the kubectl command line tool to create a Pod resource in the OKD cluster, OKD will send a corresponding request to the API Server, and after successful creation, a resource list containing the Pod resource information will be returned to the kubectl command line tool. The kubectl command line tool will parse the resource list and display the result on the terminal for the user to view.

[0082] The data of the resource is, for example, metadata of the resource, a state of the resource, or a scheduling policy for the resource.

[0083] The metadata of the resource is used to describe the resource. The metadata of the resource is, for example, an identification of the resource. The identification of the resource includes at least one of a name of the resource, a unique identifier (UID) of the resource, a type of the resource, or a label of the resource. The metadata of the resource can further include a type of the resource, a specification of the resource, or a version of the resource, etc. Optionally, the metadata of the resource further includes metadata of other resources (such as parent resources or child resources) in a dependency list of the resource.

[0084] For example, the Kubernetes resource is a container group, and the container group list includes data of each of the three container groups. The data of each container group includes a name of the container group, a type of the container group (pod), a name of an application dependent on the container group, and a name of a volume dependent on the container group. For another example, the Kubernetes resource is a stateless application, and the stateless application list includes data of three stateless applications. The data of each stateless application includes a name of the stateless application, a type of the stateless application, and a name of a container group dependent on the stateless application.

[0085] (5) Dependency relationship

[0086] Dependency refers to a relationship between different resources in Kubernetes. Generally speaking, if a first Kubernetes resource directly or indirectly utilizes a second Kubernetes resource, the relationship between the first Kubernetes resource and the second Kubernetes resource can be defined as a dependency. The term dependency can be expressed in various ways. For example, dependency can also be referred to as parent-child relationship, master-slave relationship, control and controlled relationship, or management and managed relationship. For example, if a first Kubernetes resource depends on a second Kubernetes resource, the relationship between the first Kubernetes resource and the second Kubernetes resource can also be expressed in the following ways:

[0087] The first Kubernetes resource is the parent resource, and the second Kubernetes resource is the child resource.

[0088] The first Kubernetes resource has a higher level than the second Kubernetes resource.

[0089] The first Kubernetes resource is the control node or management node of the second Kubernetes resource.

[0090] (6) Dependency query

[0091] Dependency query refers to searching for other resources that have a dependency relationship with a resource using the identifier of the resource as an index.

[0092] In one possible implementation, the dependency query includes a process of searching for a parent based on a child. For example, in the process of dependency query, the identifier of the parent resource (or the resource that depends on the resource) of a resource is searched using the identifier of the resource as an index. In one example scenario, in response to a deletion operation on a pod, a dependency query is performed based on the identifier of the pod to obtain the identifier of the stateless application that depends on the pod. In another example scenario, in response to a deletion operation on a volume, a dependency query is performed based on the identifier of the volume to obtain the identifier of the pod that depends on the volume.

[0093] In another possible implementation, the dependency query is a process of searching for a child based on a parent. For example, in the process of dependency query, the identifier of the child resource (or the resource that the resource depends on) of a resource is searched using the identifier of the resource as an index.

[0094] (7) Inverted index table

[0095] An inverted index table is a data structure used in text retrieval to quickly find the locations of occurrences of a certain word (single word or phrase). The inverted index table indicates the mapping relationship between the words appearing in the document and the documents containing the words. By constructing the inverted index table, each word appearing in the document can be converted into a key that can be indexed. In the query phase, when a specific word needs to be queried, the word can be used as an index to find all documents containing the word by looking up the inverted index table, without the need to temporarily traverse each document and match the word to be queried with each word in each document, thereby improving search speed and search efficiency.

[0096] For example, there are three documents containing the words "apple", "banana" and "orange" respectively, and the IDs of the three documents are Document 1, Document 2 and Document 3 respectively. The inverted index table can record as follows:

[0097] apple->Document 1

[0098] banana->Document 2

[0099] orange->Document 3

[0100] When a user queries the word "apple", Document 1 can be obtained based on the word "apple" and the inverted index table, without the need to traverse Document 1, Document 2 and Document 3, and match the word "apple" with each word in Document 1, Document 2 and Document 3.

[0101] (8) First-in-first-out queue (FIFO queue)

[0102] A first-in-first-out queue is a data structure used to manage multiple operations, which are processed in the order in which they enter the queue. New operations are added to the end of the queue, while the earliest added operations are at the front of the queue and are processed first. In addition, the operations inserted into the queue first are usually deleted from the queue first. Through the first-in-first-out queue, it helps to process the operations in the order in which they enter the queue, thereby improving correctness and stability.

[0103] For example, there are three operations that need to be processed in turn, and the first-in-first-out queue can record as follows:

[0104] action 1->action 2->action 3

[0105] When preparing to process the three operations, the three operations are processed in the order in which they entered the queue, thereby providing an ordered processing approach.

[0106] (9) Owner reference

[0107] Owner references are a key to a field in Kubernetes that identifies a dependency relationship between resources. Owner references can be used to indicate that one resource is the owner (also understood as the owner, manager, or parent resource) of another resource. The value of the owner references field in the data of a resource includes the identification of the parent resource of the resource. For example, a pod is created in a resource of type replica set, named nginx, and the value of the owner references parameter of the pod is as follows.

[0108]

[0109] The above means that the value of the "owner references" parameter includes the type replica set, named nginx. Through the "owner references", the dependency list between the resource of type replica set and named nginx and the pod can be identified, and the resource of type replica set and named nginx is the owner of the pod. The resource of type replica set and named nginx is the parent resource of the pod, and the pod is the child resource of the resource of type replica set and named nginx. The resource of type replica set and named nginx can manage the pod. The ellipsis... indicates that although not shown, the key-value pair is optionally included.

[0110] (10) Created by

[0111] created-by is part of the key of a key-value pair in Kubernetes, which represents the creator information of a resource in Kubernetes. The full name of this key is "kubernetes.io / created-by". The value of the kubernetes.io / created-by field includes the type of the object that created the resource and the name of the object that created the resource. Through the value of the created-by field, it can be used to track the creation process of the resource, understand how the resource was created, and which objects participated in the creation of the resource. The created-by parameter is located in the annotation field.

[0112] As a specific example, in a resource of type replica set and name nginx, a pod is created, and the data of the pod includes a key-value pair, with the key being kubernetes.io / created-by and the value being { "kind": "SerializedReference", "apiVersion": "v1", "reference": { "kind": "ReplicaSet", "namespace": "default", "name": "nginx-deployment-abcde", "uid": "f8a8c9e9-9f20-11e9-8e67-080027a3f7e0", "apiVersion": "apps / v1", "resourceVersion": "123456"}}

[0113] The above indicates that the resource of type replica set and name nginx created the pod.

[0114] (11) Label

[0115] Label is a field in Kubernetes used to identify resources. Each Kubernetes resource can contain multiple label fields, and label fields include key-value pairs, such as "app=my-deployment". Labels can be used to classify, filter and select objects. For example, in the deployment list, each pod replica is assigned a label, which is automatically created and managed by the deployment controller. Label selector can be used to query all pod replicas that a certain deployment depends on, such as "app=my-deployment".

[0116] The application scenarios of the embodiments of the present application are described below.

[0117] The embodiments of the present application can be applied to scenarios of deploying, running or managing application programs based on Kubernetes.

[0118] For example, the embodiments of the present application can be applied to scenarios of protecting resources based on dependency query. Specifically, if a parent resource of a certain resource is not prompted in time before the certain resource is deleted or modified, the business may be affected. For example, a container instance is controlled by an application instance, and the application instance is the parent resource of the container instance. If the container instance is deleted, the application instance cannot continue to control the container instance, and the running of the application instance is affected. Therefore, when an operation instruction is triggered for a resource, it is necessary to query whether the resource has a parent resource, prompt the user to operate the resource to affect the parent resource, so as to protect the parent resource.

[0119] In a possible implementation of the dependency query, based on a keyword as an index, a for loop is used to traverse each field in the data of each resource in the resource list, the keyword is matched with each field in the data of each resource, the field corresponding to the keyword is determined through the loop traversal process, and the identifier of the second Kubernetes resource having a dependency relationship with the first Kubernetes resource is determined from the field corresponding to the keyword. However, the resource list may contain a large amount of resource data, and the data of each resource may contain many fields. The amount of data to be processed is large by using the loop traversal query method, and the retrieval speed is slow. For example, a resource list contains n pieces of resource data, and each piece of resource data contains m fields. The process of traversal and one-by-one matching causes a(n*m) level of time complexity calculation, resulting in slow retrieval speed, a huge amount of data to be processed, slow retrieval speed, and low retrieval performance.

[0120] Based on this, in a possible implementation of the present application, the resource list is inverted to obtain the dependency list. Specifically, since the inverted index table records the correspondence between the keyword and the occurrence position of the keyword in the resource list, the occurrence position in the resource list can be determined through the inverted index table, the keyword corresponding field is located in the resource list based on the occurrence position of the keyword, and the identifier of the second Kubernetes resource is obtained from the keyword corresponding field, so it is not necessary to traverse each piece of data in the entire resource list and each field in each piece of data, and it is not necessary to match the keyword with each piece of data in the entire resource list and each field in each piece of data, thereby reducing the computational complexity caused by the loop traversal and one-by-one matching, improving the speed of retrieving the identifier of the second Kubernetes resource, and reducing the processing overhead of the device and improving the performance. As a specific example, the resource list contains 10 pieces of resource data, and the inverted index table records the occurrence of the keyword in the 7th piece of data, so based on the identifier of the 7th piece of data recorded in the inverted index table, the 7th piece of data is located in the resource list, and the identifier of the second Kubernetes resource dependent on the first Kubernetes resource is obtained from the 7th piece of data in the resource list, without traversing the 1st to 6th pieces of data and the 8th to 10th pieces of data.

[0121] If necessary, the embodiments of the present application can optionally support the function of dependency reversal. The dependency reversal function has special advantages in the scenario of retrieving the identifier of a child resource based on the list of a parent resource (hereinafter referred to as parent-based child retrieval) and the scenario of one resource being controlled and managed by multiple resources (hereinafter referred to as one child corresponding to multiple parents).

[0122] Dependency reversal can also be referred to as primary-secondary conversion. Simply put, dependency reversal refers to swapping the key and value in the key-value pair of the resource list, so that the value can be used as an index to find the key. For example, dependency reversal is to reverse the original mapping relationship (key-value) to form a new mapping relationship (value-key), in which the value is used as the key, and the original key becomes the value. As a specific example of dependency reversal, the first key-value pair in the resource list includes deployment1->pod1, and the second key-value pair corresponding to the first key-value pair in the dependency list is pod1->deployment 1.

[0123] In one possible implementation of dependency inversion, the data structure of the dependency list is determined based on the relationship between resources. The index (key) in the dependency list is the identification of the child resource, and the value of the dependency list is the identification of the parent resource, so that the data structure of the dependency list is unified. For example, the key field in the dependency list output for various resource lists includes the identification of the resource as a child, and the value field in the dependency list includes the identification of the resource as a parent. By limiting and unifying the data structure of the dependency list, when triggering the operation instruction for the child resource, the identification of the parent resource can be quickly retrieved based on the dependency list, so as to prompt which parent resources will be affected when the child resource is operated.

[0124] For example, the key in the first key-value pair includes the identification of the resource as a parent. The value in the first key-value pair includes the identification of the resource as a child. The first key-value pair is inversely mapped to obtain a second key-value pair. The key in the second key-value pair includes the identification of the resource as a child. The value in the first key-value pair includes the identification of the resource as a parent.

[0125] In one possible implementation of dependency inversion, the identification of the second Kubernetes resource is obtained from the data of the first Kubernetes resource in the resource list based on the inverted index table. In response to determining that the first Kubernetes resource is the parent resource of the second Kubernetes resource, the identification of the first Kubernetes resource is written to the value field of the dependency list, and the identification of the second Kubernetes resource is written to the key field of the dependency list, thereby obtaining the dependency list with the data structure of the child as the key and the parent as the value. Alternatively, in response to determining that the first Kubernetes resource is the child resource of the second Kubernetes resource, the identification of the first Kubernetes resource is written to the key field of the dependency list, and the identification of the second Kubernetes resource is written to the value field of the dependency list, thereby obtaining the dependency list with the data structure of the child as the key and the parent as the value.

[0126] As an exemplary scenario based on parent searching, the obtained resource list is a deployment list, and the first Kubernetes resource is deployment 1 in a plurality of deployments to which the deployment list belongs. In a piece of data of deployment 1 in the resource list, the key field includes deployment 1 (an identifier of the first Kubernetes resource), and the value field includes pod1 (an identifier of the second Kubernetes resource), so that the resource list records a correspondence of deployment 1->pod1. After obtaining pod1 and deployment 1 from the resource list, in response to determining that deployment 1 is the parent resource of pod1, the pod1 is written into the key field of the dependency relationship, and the deployment 1 is written into the value field of the dependency relationship, so as to obtain a dependency relationship of a data structure with pod1 as the key and deployment 1 as the value, which indicates a correspondence of pod1->deployment 1.

[0127] As another exemplary scenario based on parent searching, the obtained resource list is a pod list, and the first Kubernetes resource is pod1 in a plurality of pods to which the pod list belongs. In a piece of data of pod1 in the resource list, the key field includes pod1 (an identifier of the first Kubernetes resource), and the value field includes volume1 (an identifier of the second Kubernetes resource), so that the resource list records a correspondence of pod1->volume1. After obtaining volume1 and pod1 from the resource list, in response to determining that pod1 is the parent resource of volume1, the volume1 is written into the key field of the dependency relationship, and the pod1 is written into the value field of the dependency relationship, so as to obtain a dependency relationship of a data structure with volume1 as the key and pod1 as the value, which indicates a correspondence of volume1->pod1.

[0128] In a sub-to-multiple-parent scenario, considering that in the original resource list, there can be a case that a sub is scattered in the data of different parents, for example, an identifier of a sub resource is simultaneously located in the value field of the data of different resources depending on the resource, causing that when searching for the identifier of the parent resource based on the sub resource in the resource list, a plurality of pieces of data of the parent resource need to be matched one by one to obtain the identifiers of the respective parent resources, causing slow searching speed.

[0129] Based on this, in a possible implementation of the present application, not only the data structure of the dependency list is limited, but also the identifiers of the multiple parent resources corresponding to the same child resource are written into the same value field, so as to realize the normalization and merging of the identifiers of the multiple parent resources corresponding to the same child resource into the value field of the child resource. Through the normalization and merging of the data, it is equivalent to determining which parent resources the child resource has from the value field of the child resource from the perspective of the child resource. Therefore, when the index of the child resource is searched in the dependency list, the identifiers of the multiple parent resources can be obtained in batch at one time, so as to further improve the search speed.

[0130] For example, based on the inverted index table, the identifier of the second Kubernetes resource is obtained from the data of the first Kubernetes resource in the resource list; the identifier of the second Kubernetes resource is obtained from the data of the third resource in the resource list. In response to determining that the first Kubernetes resource and the third resource are both parent resources of the second Kubernetes resource, the identifier of the second Kubernetes resource is written into the key field of the dependency list, and the identifier of the first Kubernetes resource and the identifier of the third resource are written into the value field of the dependency list, so as to obtain the dependency list with the data structure of taking the child as the key and the multiple parents as the value.

[0131] As an exemplary scenario of one-to-many, the obtained resource list is a deployment list, the first Kubernetes resource is deployment 1 in a plurality of deployments to which the deployment list belongs, and the third resource is deployment 2 in the plurality of deployments to which the deployment list belongs. In a piece of data of deployment 1 in the resource list, the key field includes deployment 1 (an identifier of the first Kubernetes resource), and the value field includes pod1 (an identifier of the second Kubernetes resource). In a piece of data of deployment 2 in the resource list, the key field includes deployment 2 (an identifier of the third resource), and the value field includes pod1 (an identifier of the second Kubernetes resource), so that the resource list records the corresponding relationship of deployment 1->pod1 and deployment 2->pod1. After obtaining deployment 1, pod1 and deployment 2 from the resource list, in response to determining that deployment 1 and deployment 2 are both parent resources of pod1, the pod1 is written into the key field of the dependency list, and the deployment 1 and the deployment 2 are written into the value field of the dependency list, so as to obtain a dependency relationship of a data structure taking pod1 as the key and deployment 1 and deployment 2 as the value, which indicates the corresponding relationship of pod1->{deployment 1, deployment 2}. Therefore, when retrieving the parent resources of pod1, one dependency relationship can be matched based on pod1, and the identifiers of the two parent resources of deployment 1 and deployment 2 can be obtained at one time, without separately matching the data of deployment 1 and the data of deployment 2, so as to further improve the speed of retrieval.

[0132] The keyword used for retrieving in the resource list based on the inverted index table can be a specific type of keyword. For example, the keyword is used to identify a resource that has a dependency relationship with the resource to which the resource list belongs. In a possible implementation, the keyword is determined based on the hierarchy of the resource to which the resource list belongs. For example, the resource list is a list of first Kubernetes resources, and the keyword is determined based on the hierarchy of the first Kubernetes resource and the corresponding relationship between the hierarchy and the keyword. Alternatively, the keyword is determined based on the type of the resource to which the resource list belongs. For example, the resource list is a list of first Kubernetes resources, and the keyword is determined based on the first type and the corresponding relationship between the resource type and the keyword.

[0133] By combining the scenario of Kubernetes, the type of resource or the hierarchy of resource is combined to determine the keyword used for retrieval, so that the scheme is applicable to the scenario of parent retrieval based on child, and also applicable to the scenario of child retrieval based on parent, so that the scheme has higher flexibility and is more general.

[0134] For example, in the scenario of child retrieval based on parent, based on the type of the first Kubernetes resource belonging to child resource or the hierarchy of the first Kubernetes resource being greater than or equal to 2, the determined keyword is the first keyword. The first keyword is used to identify the parent resource (or the resource dependent on the first Kubernetes resource) of the first Kubernetes resource. For example, the first keyword includes at least one of owner reference or created-by.

[0135] In the scenario of parent retrieval based on child, based on the type of the first Kubernetes resource belonging to parent resource or the hierarchy of the first Kubernetes resource being 1, the determined keyword is the second keyword. The second keyword is used to identify the child resource (or the resource dependent on the first Kubernetes resource) of the first Kubernetes resource. For example, the second keyword includes label.

[0136] If necessary, the embodiments of the present application can select to support modification comparison based on inverted index, so as to improve the efficiency of comparison.

[0137] Specifically, in the case that the operation type of the resource list is modification, it is necessary to determine whether the data related to the dependency relationship in the resource list is modified, such as whether the parent resource or the child resource of a resource is modified. However, if the data of each resource in the current obtained resource list and the last obtained resource list is directly compared, since the data amount of the resource list is large, comparing the entire resource list leads to the need to compare the resource list data by data, resulting in a large amount of data to be processed, thereby affecting the performance. In addition, since the resource list contains data irrelevant to the dependency relationship, such as the state of the resource, the API version of the resource, the scheduling strategy of the resource, etc., these data have little effect on determining whether the dependency relationship is modified, and can be regarded as redundant data. Comparing the redundant data in the resource list will cause many useless operations to be performed, affecting the efficiency of comparison and possibly affecting the accuracy of comparison.

[0138] Based on this, in a possible implementation of the present application, if the operation type of the resource list is modification, the current obtained resource list and the last obtained resource list are inverted indexed to obtain two dependency lists, the two dependency lists are compared, and based on the comparison result, it is determined whether the dependency relationship is modified and the modified dependency relationship.

[0139] In order to distinguish the description of the resource list, the resource list at different time points is described as "version one resource list" and "version two resource list" below. The two limited expressions of version one and version two distinguish different time points. It can also be said that the resource list of version one is the old resource list, and the resource list of version two is the new resource list. For example, version one and version two can be represented by two different time stamps or two version numbers. The time point of obtaining the resource list of version one is earlier than the time point of obtaining the resource list of version two. For example, the resource list of version two is the current obtained resource list, and the resource list of version one is the last obtained resource list. For example, the resource list of version one comes from the first message sent by the server, and the resource list of version two comes from the second message sent by the server, and the time stamp of the second message is later than that of the first message. For example, the version number corresponding to the resource list of version two is greater than the version number corresponding to the resource list of version one.

[0140] In order to distinguish the description of the dependency list obtained based on different resource lists, the dependency list obtained based on the resource list of version two is described as "version two dependency list", and the dependency list obtained based on the resource list of version one is described as "version one dependency list".

[0141] In a possible implementation of the modification comparison, the keys in the dependency list of version two and the keys in the dependency list of version one are compared, and the values in the dependency list of version two and the values in the dependency list of version one are compared; in response to determining that the keys in the dependency list of version two are consistent with the keys in the dependency list of version one, and the values in the dependency list of version two are consistent with the values in the dependency list of version one, it is determined that the dependency list has not been modified.

[0142] As a specific example, the dependency list of version one is pod1->deployment 1, indicating that pod1 is a child resource of deployment 1. The dependency list of version two is pod1->deployment 1, indicating that pod1 is a child resource of deployment 1. The comparison of pod1->deployment 1 and pod1->deployment 1 is performed, and in response to determining that pod1->deployment 1 is the same as pod1->deployment 1, it is determined that the dependency list of pod1 has not been modified.

[0143] In another possible implementation of the modification comparison, the keys in the dependency list of version two are compared with the keys in the dependency list of version one, and the values in the dependency list of version two are compared with the values in the dependency list of version one; in response to determining that the keys in the dependency list of version two and the keys in the dependency list of version one both include an identification of a first Kubernetes resource, and the values in the dependency list of version two include an identification of a third resource and the values in the dependency list of version one do not include the identification of the third resource, it is determined that the third resource is added to the parent resource of the first Kubernetes resource.

[0144] As a specific example, the dependency list of version two is pod1->{deployment 1, deployment 2}, indicating that pod1 is a child resource of deployment 1 and deployment 2. The dependency list of version one is pod1->deployment 1, indicating that pod1 is a child resource of deployment 1. The pod1->deployment 1 and pod1->{deployment 1, deployment 2} are compared. In response to determining that the keys of the dependency list of version two and the dependency list of version one both include pod1, and the values in the dependency list of version two include deployment 2 and the values in the dependency list of version one do not include deployment 2, it is determined that the dependency list of pod1 is modified, and deployment 2 is added to the parent resource of pod1.

[0145] In another possible implementation of the modification comparison, the keys in the dependency list of version two are compared with the keys in the dependency list of version one, and the values in the dependency list of version two are compared with the values in the dependency list of version one; in response to determining that the keys in the dependency list of version two and the keys in the dependency list of version one both include an identification of a first Kubernetes resource, and the values in the dependency list of version two do not include an identification of a third resource and the values in the dependency list of version one include the identification of the third resource, it is determined that the third resource is deleted from the parent resource of the first Kubernetes resource.

[0146] As a specific example, the dependency list of version two is pod1->deployment 1, indicating that pod1 is a child resource of deployment 1. The dependency list of version one is pod1->{deployment 1, deployment 2}, indicating that pod1 is a child resource of deployment 1 and deployment 2. A comparison is made between pod1->{deployment 1, deployment 2} and pod1->deployment 1. In response to determining that the key of the dependency list of version two and the key of the dependency list of version one both include pod1, the value in the dependency list of version two does not include deployment 2 and the value of the dependency list of version one includes deployment 2, it is determined that the dependency list of pod1 is modified, and deployment 2 is deleted from the parent resource of pod1.

[0147] In yet another possible implementation of the modification comparison, a comparison is made between the key in the dependency list of version two and the key in the dependency list of version one, and a comparison is made between the value in the dependency list of version two and the value in the dependency list of version one; in response to determining that the value in the dependency list of version two and the value in the dependency list of version one both include the identification of the second Kubernetes resource, and the key in the dependency list of version two is the identification of the first Kubernetes resource, and the key in the dependency list of version one is the identification of the third resource, it is determined that the child resource of the second Kubernetes resource is modified from the third resource to the first Kubernetes resource.

[0148] As a specific example, the dependency list of version two is pod1->deployment 1, indicating that pod1 is a child resource of deployment 1. The dependency list of version one is pod2->deployment 1, indicating that pod2 is a child resource of deployment 1. A comparison is made between pod1->deployment 1 and pod2->deployment 1, and in response to determining that the value in pod1->deployment 1 and the value in pod2->deployment 1 both include deployment 1, and the key in pod1->deployment 1 is pod1 and the key in pod2->deployment 1 is pod2, it is determined that the child resource of deployment 1 is modified, and the child resource of deployment 1 is modified from pod1 to pod2.

[0149] By the above-mentioned implementation manners, whether the resource and / or the sub-resource of a resource is subjected to an addition operation, a deletion operation or a modification operation can be determined by comparing two dependency lists. Since the data quantity of the dependency list is far less than that of the resource list, the dependency list is equivalent to a simplified resource list, and the redundant data irrelevant to the determination of the dependency is removed from the resource list, and the dependency list almost only includes the data required to be considered for the determination of the dependency, for example, a dependency relationship can be composed of the identifiers of two resources. Therefore, compared with comparing two original resource lists, the data quantity processed during the comparison of the two dependency lists is less, and the processing complexity of the comparison is greatly reduced, so that the speed of the comparison is improved, and the comparison performance is also improved. In addition, since the comparison of the dependency list does not need to compare the redundant data, the operation caused by the comparison of the redundant data is reduced, and the comparison efficiency is improved.

[0150] In addition, the dependency list of all historical versions does not need to be saved in the cache, and the resource list of all historical versions does not need to be saved in the cache, but the dependency list of the current version and the dependency list of the last version are saved, so that whether the parent resource and / or the sub-resource is subjected to an addition operation, a deletion operation or a modification operation can be determined, thereby avoiding the storage space occupied by saving all historical versions of the resource list and all historical versions of the dependency list, and greatly reducing the occupied cache space.

[0151] If necessary, the embodiment of the present application can select to support the pre-check of the modification comparison based on the inverted index, so as to improve the accuracy of the comparison.

[0152] Specifically, considering that there is a risk of missing statistics in the process of keyword-based retrieval in the resource list, for example, not all dependencies are retrieved based on the keyword, or there are some dependencies in the resource list that are not correctly associated with the keyword, which affects the accuracy of the modification comparison.

[0153] Based on this, in a possible implementation manner of the present application, the number of occurrences of the keyword in the inverted index table is compared with the number of resources retrieved based on the keyword in the resource list. If the number of occurrences of the keyword in the inverted index table is consistent with the number of resources retrieved based on the keyword in the resource list, the retrieval result is checked, and the subsequent modification comparison step is continued to be performed. If the number of occurrences of the keyword in the inverted index table is inconsistent with the number of resources retrieved based on the keyword in the resource list, the retrieval result is not checked, and the subsequent modification comparison step is cancelled.

[0154] As a specific example of the pre-check, in the scenario of retrieving parents based on children, the number of occurrences of owner references in the inverted index table constructed based on the version one resource list is one, and the number of parent resources retrieved from the resource list using owner references as the keyword is one. The number of occurrences of owner references in the inverted index table constructed based on the version two resource list is three, and the number of resources retrieved from the resource list using owner references as the keyword is two. Since the number of occurrences of owner references in the version one resource list is consistent with the number of parent resources retrieved, the retrieval result check of the version one resource list passes. Since the number of occurrences of owner references in the version one resource list is inconsistent with the number of parent resources retrieved, the retrieval result check of the version two resource list fails, so the step of comparing the dependency list of the version one with the dependency list of the version two is cancelled, and the prompt information that the version two resource list has an error is output.

[0155] As a specific example of the pre-check, in the scenario of retrieving children based on parents, the number of occurrences of persistent volume claim in the inverted index table constructed based on the resource list is three, and the number of pod identifiers retrieved from the resource list using persistent volume claim as the keyword is two. It is determined that the retrieval result check of the resource list fails, so the step of generating operation data based on the retrieved pod identifier is cancelled.

[0156] If necessary, the embodiments of the present application can select to support the delayed update mode, thereby reducing the impact of the real-time update mode on performance.

[0157] The real-time update mode refers to taking the obtained resource list as the trigger condition for updating the dependency list in the cache. For example, whenever a resource list is received from the server, the dependency list is obtained based on the received resource list, and the cache is written based on the dependency list, thereby updating the dependency list saved in the cache, so that the dependency relationship indicated by the dependency list in the cache is consistent with the dependency relationship indicated by the received resource list in real time.

[0158] However, when the real-time update mode is adopted, since a write operation needs to be performed on the cache every time a resource list is received, it is necessary to frequently perform read and write operations on the cache, and frequent read and write operations will affect the performance of the cache and cause the cache to have a large pressure.

[0159] Based on this, in a possible implementation of the present application, the trigger condition for updating the dependency list in the cache is improved, and the trigger condition for updating the dependency list in the cache is delayed from obtaining the resource list to triggering the operation instruction for the resource.

[0160] In order to distinguish the dependency list obtained based on the resource list from the dependency list saved in the cache, the dependency list obtained based on the resource list is described as a "first dependency list" and the dependency list saved in the cache is described as a "second dependency list" below. The first dependency list includes at least one of the version one dependency list or the version two dependency list.

[0161] For example, operation data is obtained based on the first dependency list and the operation type; and the second dependency list is updated based on the operation data in response to the operation instruction triggered for the resource.

[0162] The operation type includes added, modified, and deleted. The operation data includes the operation type, the identification of the resource to which the operation is directed, and the dependency relationship of the resource.

[0163] The operation data of the added type is used to indicate the added dependency relationship. For example, in the scenario of adding a child resource, the operation data of the added type includes the identification of the added child resource and the identification of the parent resource corresponding to the added child resource. For another example, in the scenario of adding a parent resource, the operation data of the added type includes the identification of the added parent resource and the identification of the child resource corresponding to the added parent resource.

[0164] The operation data of the deleted type is used to indicate the deleted existing dependency relationship. For example, in the scenario of adding a child resource, the operation data of the deleted type includes the identification of the child resource to be deleted. For another example, in the scenario of deleting a parent resource, the operation data of the deleted type includes the identification of the parent resource to be deleted and the identification of the child resource corresponding to the parent resource.

[0165] The operation data of the modified type is used to indicate the modified existing dependency relationship. For example, in the scenario of modifying a child resource, the operation data of the modified type includes the identification of the child resource to be modified and the identification of the parent resource corresponding to the identification of the child resource. For another example, in the scenario of modifying a parent resource, the operation data of the modified type includes the identification of the parent resource to be modified and the identification of the child resource corresponding to the parent resource.

[0166] Since the dependent list in the cache is updated when the operation instruction is triggered, the dependent relationship indicated by the dependent list in the cache and the dependent relationship indicated by the obtained resource list are intermittently consistent, for example, the dependent list in the cache is updated once when the update instruction is triggered once, and it is not required that the dependent relationship indicated by the dependent list in the cache and the dependent relationship indicated by the received resource list are real-time consistent, thereby reducing the number of update operations on the cache and improving the update performance.

[0167] If necessary, the embodiment of the present application can select to support the combination of the dependent list and the FIFO queue, thereby improving the accuracy of updating data.

[0168] For example, when obtaining an operation data, the operation data is saved to the tail end of the operation queue. In response to the operation instruction triggered for the resource, the operation data is obtained from the head end of the operation queue, and the second dependent list is updated based on the operation data.

[0169] The operation queue is used to save operation data in sequence. In a possible implementation, the operation queue is a first-in first-out queue. The operation queue is used to save operation data in sequence from early to late according to the time point of obtaining the operation data. The earlier the time point of obtaining the operation data, the closer the position in the operation queue to the head end of the queue, so that the operation data obtained earlier is processed later.

[0170] Since the operation data is saved through the FIFO queue, the access order of the operation data is limited, so that the execution order of the operation data has a certain certainty, that is, the operation data is executed in sequence from early to late according to the time point of obtaining the operation data, thereby improving the accuracy of data updating. For example, if an operation data indicating adding a first Kubernetes resource is obtained first, and then an operation data indicating deleting the first Kubernetes resource is obtained. If the access order of the two operation data is not limited, it may cause that the operation data indicating deleting the first Kubernetes resource is taken out from the queue first and the delete operation is executed, and then the operation data indicating adding the first Kubernetes resource is taken out and the add operation is executed, and according to the operation data indicating deleting the first Kubernetes resource, the first Kubernetes resource does not exist, which causes a conflict. By saving the operation data through the first-in first-out queue, it is helpful to avoid the conflict and improve the accuracy of data synchronization.

[0171] In one possible implementation of updating the dependency list through the operation queue, each operation data for the same type of resource within a period of time is sequentially saved to the queue; in response to the operation instruction triggered for the resource, the second dependency list is updated based on each operation data in the queue in the order of arrangement of the operation data in the queue. In this way, the multiple update operations in the queue are combined into one batch update operation, further reducing the number of updates to the cache and improving performance.

[0172] The following illustrates a hardware architecture associated with an application scenario.

[0173] The application is not limited to the above-mentioned hardware architecture. Figure 1 Fig. 1 shows a schematic diagram of an architecture of a computing system 100 according to an embodiment of the present application. The computing system 100 includes a terminal 120 and a server system 140. The terminal 120 and the server system 140 are connected through a communication network 160.

[0174] A terminal refers to a device that supports human-computer interaction function and has the ability to access a network, and is usually equipped with an operating system. The terminal 120 can be, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a desktop computer, a car, a vehicle-mounted terminal, a wearable device, a handheld game console, etc. The terminal 120 can also be referred to as a user equipment (UE), a smart terminal, a mobile terminal user device, or a terminal device. The terminal 120 runs a browser 1201, and the terminal 120 interacts with the server system 140 through the browser 1201. The browser 1201 is software. The browser 1201 can be, for example, a world wide web (Web) application, or a standalone software browser, or an applet. An applet refers to a child application that depends on a parent application for running.

[0175] The server system 140 is configured to provide a resource list. The server system 140 can be a standalone server, or a cluster or distribution including multiple servers, or a cloud computing platform or a virtualization center. The servers included in the server system 140 can be physical servers, or virtual machines, containers, or virtualized devices based on network function virtualization (NFV). The servers included in the server system 140 can be physical servers, or virtual machines, containers, etc.

[0176] The communication network 160 is configured to support data communication connections for the terminal 120 and the server system 140. The communication network 160 typically supports standard communications technologies and / or protocols. The communication network 160 is typically the Internet, but can also be any combination of LANs, MANs, WANs, mobile, wired, or wireless networks, private networks, or virtual private networks. The communication network 160 includes one or more network devices, such as switches, routers, etc.

[0177] In the process of acquiring the dependency relationship, the server system 140 can optionally undertake the main data processing task, and the terminal 120 undertakes the secondary data processing task; or the server system 140 undertakes the secondary data processing task, and the terminal 120 undertakes the main data processing task; or the terminal 120 and the server system 140 cooperatively undertake the data processing task.

[0178] The server system 140 can include multiple servers. For example, the server system 140 includes a front-end server system 140-a and a back-end server system 140-b.

[0179] The front-end server refers to the server close to the terminal 120. The front-end server is configured to manage the front-end resources of the 100, such as HTML pages, JavaScript source code or TS source code, and CSS. The front-end server is configured to provide the user with the front-end interface of the website and the interaction function. The back-end server system 140-b is configured to process the business logic and the database operation. The back-end server receives the data request submitted by the front-end server, processes the request, and returns the corresponding result to the front-end server.

[0180] The front-end server and the back-end server can be arranged on different physical servers. The front-end server system 140-a and the back-end server system 140-b communicate through the network and the HTTP protocol. The front-end server and the back-end server can also be integrated on the same physical server.

[0181] Optionally, the computing system 100 further comprises a storage device 180. The storage device 180 is used to save data required by the server system 140 when obtaining the dependency relationship. For example, the storage device 180 is an external hard disk array, a storage server, cloud storage, etc. Alternatively, the storage device 180 can also be located inside the server system 140 and exchange data with the server system 140 through a bus.

[0182] Optionally, the server system 140 is connected with a Kubernetes platform through a network. The Kubernetes platform is used to undertake the function of container scheduling. The server system 140 can interact with the Kubernetes platform through the network, for example, the server system 140 can send an operation instruction to the Kubernetes platform, and the Kubernetes platform schedules resources based on the received operation instruction.

[0183] The method flow of the embodiment of the present application is illustrated below.

[0184] The Figure 2A is a flowchart of a dependency query method provided by the embodiment of the present application.

[0185] The Figure 2A The execution subject of the method 200 shown includes multiple cases. In one possible implementation, the execution subject of the method 200 is a terminal. For example, the method 200 is executed by the terminal by running a browser 1201. In another possible implementation, the execution subject of the method 200 is a single server or a cluster or distribution composed of multiple servers. In still another possible implementation, the Figure 2A The method 200 shown is executed by the interaction of the browser and the server. For example, please refer to the browser and the server interaction diagram shown in FIG. 2. Figure 2B The Figure 2B The flowchart of the method 200 executed by the interaction of the browser and the server is shown.

[0186] The method 200 includes S220, S240 and S260. Optionally, the method 200 further includes S200, S210, S270, S280 and S290. The method 200 executed by the interaction of the browser and the server is taken as an example for illustration.

[0187] S220, the browser obtains a first dependency list based on the resource list and the inverted index table.

[0188] The inverted index table is used to indicate the correspondence between the keyword in the resource list and the position of the keyword in the resource list. For example, the inverted index table includes the keyword and the identification of the document. The identification of the document is used to identify the document where the keyword in the resource list is located.

[0189] The first dependency list includes an identification of the first Kubernetes resource and an identification of the second Kubernetes resource. The first Kubernetes resource is a child resource of the second Kubernetes resource. Alternatively, the first Kubernetes resource is a parent resource of the second Kubernetes resource.

[0190] In a possible implementation, the inverted index table includes the first keyword and an identification of the first document. The first document is determined from the resource list based on the identification of the first document; the first field is determined from the first document based on the first keyword, the first keyword indicating the identification of the first Kubernetes resource, a key of the first field including the first keyword, and a value of the first field including the identification of the first Kubernetes resource; and the identification of the first Kubernetes resource is obtained from the first field.

[0191] Thanks to the first keyword and the identification of the first document recorded in the inverted index table, the first field can be quickly located from the resource list, the identification of the first Kubernetes resource is obtained from the first field, and thus it is not necessary to traverse each data in the resource list and each field in each data, so that the speed of obtaining the identification of the first Kubernetes resource is improved.

[0192] In a possible implementation, the inverted index table includes the second keyword and an identification of the second document. The second document is determined from the resource list based on the identification of the second document; the second field is determined from the second document based on the second keyword, the second keyword indicating the identification of the second Kubernetes resource, a key of the second field including the second keyword, and a value of the second field including the identification of the second Kubernetes resource; and the identification of the second Kubernetes resource is obtained from the second field.

[0193] Thanks to the second keyword and the identification of the second document recorded in the inverted index table, the second field can be quickly located from the resource list, the identification of the second Kubernetes resource is obtained from the second field, and thus it is not necessary to traverse each data in the resource list and each field in each data, so that the speed of obtaining the identification of the second Kubernetes resource is improved.

[0194] In a possible implementation, the first dependency list includes a key field and a value field. In response to determining that the first Kubernetes resource is a child resource of the second Kubernetes resource, the identifier of the first Kubernetes resource is written into the key field of the first dependency list, and the identifier of the second Kubernetes resource is written into the value field of the first dependency list. Alternatively, in response to determining that the first Kubernetes resource is a parent resource of the second Kubernetes resource, the identifier of the second Kubernetes resource is written into the key field of the first dependency list, and the identifier of the first Kubernetes resource is written into the value field of the first dependency list. Since the data structure in the first dependency list is child as key and parent as value, it is helpful to quickly retrieve the identifier of the resource as parent in the scenario of resource protection.

[0195] S240, the browser obtains operation data based on the operation type corresponding to the resource list and the first dependency list.

[0196] In a possible implementation, in response to the operation type being modification, the first dependency list of version one and the first dependency list of version two are compared; and operation data is obtained based on the comparison result. The first dependency list of version one is obtained based on the resource list of version one. The first dependency list of version two is obtained based on the resource list of version two.

[0197] S260, in response to the operation instruction triggering, the browser updates the second dependency relationship in the cache based on the operation data, to obtain a third dependency relationship.

[0198] The operation instruction is used to indicate operation on the first Kubernetes resource. The operation instruction includes an operation type and an identifier of the first Kubernetes resource. For example, the operation instruction is a deletion instruction, which is used to indicate deletion of the first Kubernetes resource. For another example, the operation instruction is a modification instruction, which is used to indicate modification of a parameter of the first Kubernetes resource.

[0199] The method provided in this embodiment can quickly obtain dependency relationships by using the inverted index table, and when the operation instruction triggers, the obtained dependency relationships are used to update the dependency relationships in the cache, thereby reducing the number of times of updating the cache, and thus improving the performance of dependency query.

[0200] S270, the browser performs dependency query based on the identifier of the first Kubernetes resource and the third dependency relationship, to obtain an identifier of a second Kubernetes resource.

[0201] For example, the identity of the first Kubernetes resource matches the key in the third dependency relationship. In response to the identity of the first Kubernetes resource matching the key in the third dependency relationship, the identity of the second Kubernetes resource is obtained from the value in the third dependency relationship.

[0202] S280, the browser outputs prompt information based on the identity of the second Kubernetes resource.

[0203] The prompt information is used to prompt that the operation on the first Kubernetes resource will cause a risk to the second Kubernetes resource. The prompt information is, for example, alarm information, and is, for example, error report information. In one possible implementation of outputting the prompt information, the browser displays the prompt information in the interface. For example, the browser displays a pop-up window in the interface, and the pop-up window includes the prompt information. For another example, the browser displays a pop-up window in the interface, and the pop-up window includes the prompt information. By outputting the prompt information, the user is timely warned of the risk of operation before the operation on the first Kubernetes resource, thereby protecting the second Kubernetes resource. Optionally, the pop-up window further includes a confirmation option, and the confirmation option is used to indicate whether to confirm the operation on the first Kubernetes resource. The pop-up window generally restricts the user's operation in the current window until the user closes the pop-up window or completes a certain operation, so as to execute S290 before obtaining the user's confirmation.

[0204] In another possible implementation, the browser sets the control that triggers the operation instruction in the interface to an inactive state, thereby intercepting the operation on the first Kubernetes resource.

[0205] As a specific example, the first Kubernetes resource is pod1, and when receiving a delete instruction or an update instruction triggered for pod1, the value field corresponding to pod1 in the dependency list is queried with pod1 as the key. If there is a resource identity in the value field corresponding to pod1, it indicates that there is a resource dependent on pod1, and then the prompt information is outputted, thereby preventing pod1 from being deleted or updated.

[0206] S290, in response to the confirmation instruction, the browser sends an operation instruction to the server.

[0207] Optionally, if the user confirms the operation on the first Kubernetes resource, the browser sends an operation instruction to the server.

[0208] The method provided by the embodiment obtains the dependency list through the inverted index, without traversing each piece of data in the entire resource list and each field in each piece of data, and without matching based on the keyword and each piece of data in the entire resource list and each field in each piece of data, thereby reducing the computational complexity caused by the loop traversal and one-by-one matching, and improving the efficiency of obtaining the dependency list.

[0209] The following describes the resource protection scenario in Kubernetes in combination with the accompanying Figure 2A The embodiment is further illustrated in detail. Please refer to the accompanying Figure 3 , the accompanying Figure 3 is a flowchart of a resource protection method provided by the embodiment, and the accompanying Figure 3 The method shown in the embodiment includes S301 to S303.

[0210] S301, receiving a resource list 310, traversing the resource list 310, taking all keywords in the resource list 310 as indexes, and taking the number of occurrences of each keyword as a value to obtain an inverted index table. The resource list 310 is converted into a dependency list 330 based on the inverted index table. The dependency list 330 is, for example, a JSON object. The resource list 310 includes a currently received resource list 312 and a last received resource list 311. The currently received resource list 312 is, for example, a currently obtained resource list. The last received resource list 311 is, for example, a last obtained resource list.

[0211] S302, in response to the operation type corresponding to the resource list 310 being modification 321, repeating S301 based on the currently received resource list 312 and the last received resource list 311 to obtain two dependency lists 330; comparing the two dependency lists 330, and obtaining operation data based on the comparison result. The operation data includes the identifier of the resource to which the modification operation is directed, and the resource identifier is used to indicate the resource that is modified in the currently received resource list 312 compared with the last received resource list 311. The operation data is saved to an operation queue 340.

[0212] In response to the operation type corresponding to the resource list 310 being non-modification (such as addition 323 or deletion 322), S301 is performed based on the last received resource list 311 to obtain a dependency list 330. Operation data is obtained based on the dependency list 330, and the operation data is saved to the operation queue 340. For example, an append operation is performed on the operation data, and the operation data is added to the tail end of the operation queue 340.

[0213] When the operation type is modification, the comparison is based on the indexed inverted dependency list 330, rather than on the currently received resource list 312 and the previously received resource list 311. This improves the efficiency of comparison and, consequently, the efficiency of identifying changed resources. Specifically, comparing the data of each resource in the currently received resource list 312 and the previously received resource list 311 one by one would result in many redundant operations, impacting efficiency, because the resource lists contain a lot of redundant data. Redundant data refers to data unrelated to dependencies, such as resource status, API version, and scheduling policies. For example, comparing the status of resources in the currently received resource list 312 and the previously received resource list 311 would be redundant, as changes in resource status are almost irrelevant for determining the dependency list. Since dependency list 330 eliminates redundant data, comparing dependency list 330 helps reduce redundant operations, thereby improving comparison efficiency. Furthermore, due to the large amount of data in the resource list, comparing the entire resource list would require comparing each data entry individually, resulting in a large amount of data to process and impacting performance. However, since dependency list 330 is essentially a simplified resource list with a much smaller and more concise data set, comparing dependency list 330 does not require comparing all the data in resource list 310, thus reducing the amount of data processed and improving performance.

[0214] S303, in response to operation instruction 380, performs data synchronization using operation queue 340 and dependency list 390 stored in cache.

[0215] In one possible implementation, such as Figure 3 As shown in S303a, each operation data stored in the operation queue 340 is retrieved. Following the order of each operation data in the operation queue 340, each operation data is sequentially merged into the dependency list 390, thereby updating the dependency list 390. For example, if the operation queue 340 contains operation data 1, operation data 2, and operation data 3 from beginning to end, operation data 1 is first merged into the dependency list 390, then operation data 2 is merged into the dependency list 390, and then operation data 3 is merged into the dependency list 390. After merging the operation data into the dependency list 390, in S303b, the operation data in the operation queue 340 is deleted, thereby releasing the space occupied by the operation data in the operation queue.

[0216] For the manner of obtaining the operation instruction 380, in a possible implementation, the operation instruction 380 is obtained by listening to the operation on the interface through the event handler 370. The event handler 370 is a computer program code for processing specific events, and is usually used in the development of graphical interface applications and web page applications. When an event (such as mouse click, keyboard input, etc.) that needs to be processed occurs in the page, the corresponding event handler is called to execute to process the operation required by the event. In this embodiment, the operation on the resource 540 saved in the browser cache can be listened to through the event handler 550, and the event handler 550 can timely notify the relevant components and modules to process the operation instruction in response to the operation on the resource 540 in the browser cache 530.

[0217] The following describes the accompanying drawings Figure 2A The establishment process of the inverted index table in S220 in the embodiment is exemplarily described.

[0218] Please refer to Figure 4 , Figure 4 is a flowchart of a process of obtaining a dependency relationship based on an inverted index provided in the embodiment of the present application, Figure 4 The flowchart shown can be used to implement S220. Figure 4 The flowchart shown includes S420 and S430, and optionally further includes S410, S440, S450, S460 and S470.

[0219] S410, receiving an updated resource list.

[0220] S420, obtaining at least one document based on the resource list, and pre-processing each document to obtain a word list, the word list including each word in each document.

[0221] The document is a basic unit when establishing the inverted index. In a possible implementation, one document is used to save the data of one resource in the resource list. In a possible implementation of obtaining the document, the data of the first Kubernetes resource is obtained from the resource list, and the data of the first Kubernetes resource is saved to the first document. Similarly, the data of the second Kubernetes resource is obtained from the resource list, and the data of the second Kubernetes resource is saved to the second document. Exemplarily, in response to determining that the resource list includes data of n resources, n documents are created, and each document is used to save the parameters of one resource. For example, the pod list includes parameters of three pods, and three documents are created, and each document includes parameters of one pod.

[0222] In this way, since a document is defined for each resource, each resource corresponds to an independent document, so that statistics can be more conveniently performed when building the inverted index. In contrast, if the parameters of multiple resources are combined into one document, the structure of the document may become chaotic and complex, making it difficult to perform statistics and management. For example, if the parameters of multiple pod resources are combined into one document, then statistics need to be performed on the parameters of each pod in the document, and the parameters of different pods may be repeated or conflicting, resulting in an inaccurate inverted index table built subsequently. Therefore, by establishing a document for each resource, the document can better reflect the characteristics of each resource, facilitating statistics and management, and improving the accuracy and efficiency of the inverted index.

[0223] Optionally, the document is a JSON format document.

[0224] The document preprocessing process includes the following S420a-S420c.

[0225] S420a, tokenizing each document to obtain each word in each document.

[0226] Tokenization refers to the process of dividing text into independent words or symbols. Through tokenization, continuous character sequences in a document can be converted into discrete words, facilitating subsequent text processing. Tokenization methods include the following methods.

[0227] Tokenization method one, rule-based tokenization method. The document is divided into words according to the set rules. For example, tokenization can be performed according to spaces, punctuation marks, English capitalization, etc. For example, tokenization is performed based on grammar rules or based on lexical rules.

[0228] Tokenization method two, statistical tokenization method. For example, tokenization is performed through a statistical model. The statistical model can determine word boundaries and tokenization results by statistically analyzing the frequency and probability of word occurrence in the document. Statistical models include n-gram models, hidden Markov models (HMM), conditional random fields (CRF), maximum entropy models, etc.

[0229] Tokenization method three, dictionary-based tokenization method. For example, the text is matched based on a saved dictionary, and the matched text is divided into words.

[0230] The fourth word segmentation manner is word segmentation based on deep learning. For example, a deep learning model such as a deep neural network (DNN) or a convolutional neural network (CNN) is used to determine the representation and boundaries of words in a document. For example, a model such as a recurrent neural network or a Transformer can be used.

[0231] S420b, removing stop words from each word in each document.

[0232] Stop words refer to words that appear frequently in text but do not have actual meaning. For example, "the", "a", "an", "in", "on", and the like. By removing stop words, the length of the word list can be reduced, improving the efficiency and accuracy of subsequent processing.

[0233] S420c, performing stemming on the words to obtain a word list, the word list including each word in each document.

[0234] Stemming refers to extracting the stem of a word from the word, deleting other parts of the word other than the stem. Stemming can be performed by deleting the suffix of a word (such as a word that identifies tense, plural form, or passive voice). By performing stemming, subsequent steps (such as searching) can be performed using the stem without saving and using all the characters in the word, thereby saving storage space, improving search speed, and helping to find documents containing the word faster. In addition, different words can be mapped to the same stem, thereby reducing the length and complexity of the word list. For example, for owner references, the result of performing stemming on owner references can be owner refer, removing the suffixes.

[0235] S430, constructing an inverted index table.

[0236] For each word, determine each document containing the word, and obtain an inverted index table based on the document ID of each document containing the word and the stem of the word.

[0237] For example, a pod list is received, the pod containing data of two pods, one of which has a name (name) of pod1, and the data of pod1 includes the following text, in which unimportant parameters are omitted.

[0238]

[0239] The above includes the owner references field and the annotations field. The value of the owner references field is an array, and in this example, the owner references array contains one element, indicating that the owner of the pod is a resource named nginx-deployment-abcde of the type replica set. The UID of the owner of the pod is f8a8c9e9-9f20-11e9-8e67-080027a3f7e0. The controller and block owner deletion attributes are both set to true, indicating that the replica set resource is the controller of the pod resource (i.e., the object that creates and manages the pod resource), and the pod resource will be deleted when the replica set resource is deleted.

[0240] The value of the annotations field is a key-value pair, used to store the annotation information of the pod resource. In this example, the annotations contain an annotation named "kubernetes.io / created-by", and the value is a serialized JSON string. The JSON string describes the creation information of the pod. Among them, kind indicates that the pod is created by a resource of the type replica set, name indicates that the resource of the type ReplicaSe has the name nginx-deployment-abcde, uid indicates the unique identifier of the replica set, apiVersion indicates that the API version of the replica set is apps / v1, and resourceVersion indicates that the version number of the replica set is 123456.

[0241] For the scenario of a pod list including 2 pods, a document collection is created, and the document collection contains two documents, each containing the parameters of a pod. The two JSON format documents are converted into strings using json.dumps. Tokenization is performed on each string form document. Stemming is performed on each word obtained by tokenization to obtain the stem of each word.

[0242] The json.dumps() function is used to serialize a JSON format document into a JSON format string. Considering that a JSON format document contains a large amount of non-text data, such as objects, arrays, and the like, it is difficult to directly perform tokenization and stem extraction on the JSON format document. After the JSON format document is converted into a string, text processing such as tokenization and stem extraction can be conveniently performed.

[0243] An inverted index is established based on the extracted stems, and an inverted index table as shown in Table 1 is obtained, and the inverted index table is output.

[0244] Table 1

[0245] term indexes ownerrefer [1] api [0,1] version [0,1] kind [0,1] replicas [0] set [0,1] Name [0,1] nginx [0,1] Deploy [0,1] Abcde [0,1] uid [0,1] controller [0] Blockownerdelet [0] Kubernet [1] Io [1] Created [1] By [1] Serial [1] refer [1] Namespace [1] default [1] Resourcevers [1]

[0246] indexes is a list of document numbers corresponding to the occurrence of the term. Through indexes, it can be determined in which documents the term appears. The numbers in the square brackets represent the document numbers in which the term appears, and the document numbers start from 0. [1] indicates that the word "ownerrefer" only appears in document 2 (the number is calculated from 0). [0, 1] indicates that the words "api", "version", "kind", "replicas", "set", "name", "nginx", "deploym", "abcde", and "uid" appear in document 1 and document 2. [0] indicates that the words "replicas", "set", and "name" only appear in document 1.

[0247] S440, based on the keyword search in the document set, the name of the parent resource and the type of the parent resource are obtained.

[0248] For example, based on the inverted index table shown in Table 1, the metadata of the corresponding resource is searched in the document set based on the keyword ownerrefer and the keyword created. Taking the search based on the keyword ownerrefer as an example, the name attribute of the keyword ownerrefer is obtained to obtain the name of the parent resource of the pod, for example, the name of the parent resource of the pod is obtained as nginx-deployment-abcde; the kind attribute of the keyword ownerrefer is obtained to obtain the type of the parent resource of the pod, for example, the type of the parent resource of the pod is obtained as replica set; in this way, it is determined that the pod depends on the resource with the kind of replica set and the name of nginx-deployment-abcde.

[0249] In a possible implementation, the document set is retrieved in a chained retrieval manner. The chained retrieval generally refers to obtaining the name of a parent resource and the type of the parent resource through a plurality of nested attribute paths. Specifically, the chained retrieval can be implemented by using a dot (.) or a square bracket ([ ]) to access the attributes and array elements of a JSON object. For example, a retrieval with ownerrefer.name as the index obtains nginx-deployment-abcde. A retrieval with ownerrefer.kind as the index obtains replica set.

[0250] S450, generating a dependency list based on the name of the retrieved parent resource and the type of the parent resource.

[0251] For example, the document set is processed into a string in the following JSON format. The following JSON format is a specific example of the dependency list. The key in the following dependency list is pod1, the value in the following dependency list is "replica set":"nginx-deployment-abcde", and the meaning of the following dependency list is that pod1 is dependent on a resource of the type replica set and the name nginx-deployment-abcde.

[0252]

[0253] S460, writing the dependency list into the browser cache.

[0254] By saving the dependency list in the browser cache, when the dependency list needs to be accessed to query the dependency relationship, the browser can obtain the dependency list from the local cache space to perform dependency query, without sending a request to the server to obtain the dependency list, thereby further improving the performance and response speed of the dependency query and reducing the burden on the server.

[0255] In a possible implementation, each time the resource list is updated, the dependency list is obtained based on the resource list through an inverted index process. The obtained dependency list is written into the browser cache.

[0256] The browser cache used to store the dependency list includes but is not limited to session storage, local storage, and index database (Index DB).

[0257] Session storage and local storage are two storage mechanisms provided by HTML5 for storing data in the browser. Both session storage and local storage are key-value pair storage methods, and data can be read and written through running code. Session storage is a storage method in the HTML5 Web Storage API, which is used to store data during the session maintained by the user when accessing the same website in the same window (or tab). When the session ends, the data is automatically cleared. The data stored in local storage has no expiration time and exists in the browser until it is actively deleted. Local storage can be shared between different pages under the same domain name, and data between different domain names is independent of each other. Session storage and local storage are both simple data storage methods based on key-value pairs, mainly used to store string type data.

[0258] Index DB is a browser built-in key-value pair storage database. Index DB supports key-value pair storage, transaction operation and index query, which helps efficient data retrieval and processing in the browser. Index DB can be used to store a large amount of structured data. The storage capacity of local storage is usually limited, and the limit size is different in different browsers. The storage capacity of local storage is generally between 5-10 megabytes (MB). Index DB can store larger data sets, which can generally reach hundreds of MB or even gigabytes (GB).

[0259] In one possible implementation, the type of browser cache selected when storing the dependency list is determined based on the amount of data in the dependency list. For example, if the amount of data in the dependency list is greater than a threshold, Index DB is used to save the dependency list, and if the amount of data in the dependency list is less than the threshold, local storage is used to save the dependency list.

[0260] The following examples illustrate the implementation of writing a dependency list based on different types of browser caches.

[0261] In the case of saving the dependency list in session storage, in one possible implementation, the dependency list is saved to the session storage using the session storage.setItem('key', 'value') method. Here, key is the key of the data to be stored (e.g., the identifier of a child resource), and value is the value of the data to be stored (e.g., the identifier of a parent resource). This method returns undefined or is not assigned a value (undefined).

[0262] In the case of saving the dependency list in local storage, in one possible implementation, the dependency list is saved to the local storage using the local storage.setItem('key', 'value') method. Here, key is the key of the data to be stored (e.g., the identifier of a child resource), and value is the value of the data to be stored (e.g., the identifier of a parent resource). This method returns undefined.

[0263] In the case of saving the dependency list in Index DB, in one possible implementation, a database is created or opened. The indexedDB.open() method can be used to create or open a database named databaseName, and if the database does not exist, the database is created; then, an object storage space is created. The IDBDatabase.createObjectStore() method can be used to create an object storage space, similar to creating a database table; then, the dependency list is stored in the object storage space. The IDBObjectStore.put() or IDBObjectStore.add() method can be used to store the dependency list in the object storage space.

[0264] S470, in response to the deletion instruction or the update instruction, obtaining the dependency list from the browser cache, querying the dependency list based on the identifier of the first Kubernetes resource, obtaining the identifier of the second Kubernetes resource, and performing pre-warning or interception based on the identifier of the second Kubernetes resource.

[0265] In the case of saving the dependency list in session storage, in one possible implementation of obtaining the dependency list, the value (the identifier of the second Kubernetes resource) corresponding to the specified key (the identifier of the first Kubernetes resource) in the session storage is obtained through the session storage.getItem(key) method. Specifically, it is checked whether the specified key (the identifier of the first Kubernetes resource) exists in the session storage. If the identifier of the first Kubernetes resource exists in the session storage, the corresponding value (the identifier of the second Kubernetes resource) is returned, otherwise, a null value or an empty object (null) is returned.

[0266] In the case of saving the dependency list in local storage, in one possible implementation of obtaining the dependency list, the value (the identifier of the second Kubernetes resource) corresponding to the specified key (the identifier of the first Kubernetes resource) in the local storage is obtained through the local storage.getItem(key) method. Specifically, it is checked whether the specified key (the identifier of the first Kubernetes resource) exists in the local storage. If the identifier of the first Kubernetes resource exists in the local storage, the corresponding value (the identifier of the second Kubernetes resource) is returned, otherwise, null is returned.

[0267] In the case of saving the dependency list in Index DB, in one possible implementation of obtaining the dependency list, the indexedDB.open() method is used to open the Index DB database to be accessed. A transaction object is obtained using the transaction() method, and then the objectStore() method is used to obtain the object storage space to be accessed. The get() or openCursor() method is used to obtain the data stored in the object storage space, and the data is quickly found and retrieved through the identifier of the first Kubernetes resource as the index.

[0268] The following describes the accompanying drawings Figure 2A The obtaining manner of the resource list and the operation type in the embodiment is exemplified.

[0269] In one possible implementation, the browser and the server obtain the resource list and the operation type through interaction. The following describes the obtaining manner of the resource list and the operation type in the embodiment with reference to the accompanying drawings. Figure 2B S200 and S210 in the accompanying drawings.

[0270] S200, the server sends the resource list and the operation type to the browser.

[0271] In a possible implementation, the server sends an event message to the browser, and the event message includes the resource list and the operation type. The event message is used to notify an event that a resource is updated. For example, in response to a successful creation of a resource, the server sends an event message of an added type to the browser, and the event message includes an identifier of the created resource and the added type. In response to a modification of metadata of a resource, the server sends an event message of a modified type to the browser, and the event message includes an identifier of the resource whose metadata is modified and the modified type. In response to deletion of a resource, the server sends an event message of a deleted type to the browser, and the event message includes an identifier of the modified resource and the deleted type.

[0272] S210, the browser receives the resource list and the operation type sent by the server.

[0273] In a possible implementation, the browser receives the event message sent by the server, and the browser obtains the resource list and the operation type from the event message.

[0274] In a possible implementation, the browser receives the resource list and the operation type through a web socket interface. The web socket interface is a network interface implemented based on a web socket protocol. The web socket interface is usually a software virtual interface, and the browser establishes a connection with the server based on the web socket protocol, thereby creating the web socket interface. The web socket protocol is a network communication protocol supporting full-duplex communication, and can establish a long connection between the browser and the server after one TCP handshake, thereby realizing bidirectional communication.

[0275] By using the web socket interface to transmit the resource list, the communication overhead and latency of transmitting the resource list can be reduced, and the performance can be improved. Specifically, the difference between the web socket and the normal HTTP protocol includes the length of the connection establishment. The connection established based on the HTTP protocol is a short connection. Specifically, the HTTP protocol is based on the request-response mode, and a new connection needs to be established each time the data is requested, and the connection is disconnected after the request is completed. The connection established based on the web socket protocol is a long connection. Specifically, the web socket is a two-way communication protocol based on the TCP protocol, and the connection will remain open after the connection is established until the connection is explicitly closed. Therefore, by using the web socket interface to transmit the resource list, the server can continuously push the current resource list to the browser within a certain period of time, and the browser can continuously receive the current resource list, without having to re-establish a connection and send an HTTP request to obtain the current list of resources each time the parameters of the resources are updated, thereby reducing the overhead of establishing and closing the connection, improving the efficiency of transmitting the list, and reducing the situation that the browser frequently requests the list from the server, reducing the pressure on the browser and the occupation of network bandwidth.

[0276] In a possible implementation, the browser receives the resource list and the operation type through a WSS (web socket secure) interface. The WSS interface is a network interface based on the web socket protocol, and the WSS interface uses an encrypted version of the web socket, which can communicate through a secure connection of the transport layer security (TLS) or the secure sockets layer (SSL), thereby improving the security of transmitting the resource list.

[0277] In a possible implementation, the browser receives the resource list and the operation type through a WSS watch interface. The watch interface refers to an interface for monitoring data changes, and the notification of data updates can be obtained in real time through the interface. The WSS watch interface is an interface implemented based on the web socket protocol, and the WSS watch interface can realize real-time pushing of data. The interface is usually used for the browser to register a data observer to the server, and the server pushes data to the browser. The function of this interface is to send data to the observer in time when an event occurs, thereby realizing real-time information transmission.

[0278] In one possible implementation, whenever the server has an updated resource list, the server pushes the updated resource list to the browser through the web socket protocol. In one possible implementation, the browser subscribes to the resource list, thereby triggering the server to push the updated resource list. For example, the procedure of subscribing to the resource list includes the following steps.

[0279] Step one, the browser sends a subscription request to the server, the subscription request indicating subscription to the resource list.

[0280] Step two, the server sends a subscription result to the browser, the subscription result including the initial resource list.

[0281] Step three (S200), in response to listening to the resource being operated, the server sends an event message to the browser, the event message including the updated resource list and the operation type.

[0282] In one possible implementation, the browser receives and processes the event message sent by the server through the onmessage event processing function. The onmessage event processing function is an event processing function in the web socket protocol, which is used to receive the message sent by the server and process the message accordingly. Specifically, when the web socket receives the message sent by the server, the onmessage event is triggered, and the corresponding event processing function is called to process the event message to obtain the resource list and the operation type.

[0283] For example, the resource is a pod, the resource list is a pod list, and the pod list includes the metadata and state of each pod in the plurality of pods. The browser subscribes to the pod list in OKD using the web socket to obtain the state and metadata of the pod in real time. When a new pod is added or modified, the web socket sends an event message of the added or modified type, and the event message contains the corresponding pod list. When a pod is deleted, the web socket sends an event message of the deleted type, and the event message contains the corresponding pod list. The browser processes these messages in the onmessage event processing function and displays or deletes the corresponding pod data in the page.

[0284] OKD (open shift Kubernetes distribution) is an open source container application platform that provides a series of enterprise-level functions and services based on Kubernetes, including application building, deployment, automated operation and maintenance, etc. OKD can help developers quickly build and deploy cloud-native applications, improve development efficiency and application performance.

[0285] The following describes the method shown in Fig. 5 in combination with the producer-consumer model. Figure 2A Embodiments are further illustrated. Please refer to the accompanying drawings. Figure 5 , the accompanying drawings Figure 5 The method shown in Fig. 5 includes the following steps. The following S501 to S504 can be regarded as producers, and S504 to S506 can be regarded as consumers.

[0286] S501, the browser listens to the resource list from the Kubernetes API 510.

[0287] In Kubernetes, watch refers to a mechanism for real-time monitoring of changes in Kubernetes API resources. By watching the Kubernetes resource list, changes to these resources can be obtained in real time, such as creation, update, and deletion operations. This mechanism can help discover and handle resource changes in a timely manner, thereby better managing and operating Kubernetes clusters. The Kubernetes API Server supports RESTful API, which can access the API server through HTTP requests. Among them, the GET method is used to obtain the resource list, and the WATCH method can be used to monitor resource changes in real time. When the browser accesses a certain resource, the API Server returns a long-polling connection, and actively pushes notification messages to the browser when the resource changes. The browser can parse and process these notification messages to achieve real-time monitoring of resource changes.

[0288] S502, the browser receives event messages 522 through the WSS interface 520, and the event messages 522 include the resource list and the operation type. The browser parses the event messages 522 to obtain the resource list and the operation type, and saves the resource list and the operation type to the browser cache 530.

[0289] S503, the browser performs inverted indexing and dependency inversion on the resource list to obtain a dependency list 540, and writes the dependency list 540 to the browser cache 530.

[0290] The dependency list 540 includes a first Kubernetes resource list 541 and a second resource list 542. The first Kubernetes resource list 541 includes dependency relationships of a plurality of resources belonging to the first Kubernetes resource. The second resource list 542 includes dependency relationships of a plurality of resources belonging to the second resource. For example, the first Kubernetes resource is a pod, and the pod list includes a dependency relationship 5411 of pod1, a dependency relationship 5412 of pod2, a dependency relationship 5413 of pod3, and a dependency relationship 5414 of pod4. The dependency relationship 5411 of pod1 includes an identification of a parent resource 543 dependent on pod1. For example, the second resource is a volume, and the volume list includes a dependency relationship 5421 of volume1, a dependency relationship 5422 of volume2, a dependency relationship 5423 of volume3, and a dependency relationship 5424 of volume4. The dependency relationship 5421 of volume1 includes an identification of a parent resource 544 dependent on volume1.

[0291] S504, the browser subscribes to the dependency list in the browser cache 530 using the event handler 550. In response to the deletion instruction for volume1, the dependency relationship 5411 of pod1 is obtained from the browser cache 530, the dependency relationship 5411 is queried with the identification of volume1 as the index, and the identification of the resource 544 is obtained.

[0292] S505, the event handler 580 outputs the identification of the resource 544 to the eventconfirm 580 through the two-way data binding 570.

[0293] Two-way data binding is a front-end development technique that can help developers achieve automatic synchronization between data and UI, thereby simplifying the complexity of front-end development. Specifically, two-way data binding can bind data models and views, automatically updating views when data models change, and automatically updating data models when data is entered in views. In two-way data binding, the binding between data models and views is usually achieved through instructions or properties. For example, in the Angular JS framework, instructions can be used to achieve two-way binding between data models and form elements. When the value of the form element changes, the instruction automatically updates the value of the data model and synchronizes the new value to other bound views. The role of two-way data binding is to simplify the complexity of front-end development, improve development efficiency and user experience. Through two-way data binding, developers can more easily build interactive web applications and achieve dynamic data display and interaction. In addition, two-way data binding can improve code readability and maintainability, reducing the need for manual data and interface synchronization.

[0294] S506, the warning or interception before operation is performed through the event confirm 580.

[0295] The event confirm 580 is a kind of prompt box type built in the browser, which can be used to pop up a confirmation box to ask the user whether to confirm the operation on the resource. The confirm prompt box usually contains a text message and two buttons (a confirm button and a cancel button), and the user can select to click the confirm button or the cancel button to respond to the confirmation box. If the user clicks the confirm button, true is returned, otherwise false is returned. Through the confirm prompt box, a security protection mechanism is provided to avoid the user from performing an incorrect operation inadvertently. For example, when the resource is deleted, modified or other operations that need to be confirmed by the user, the confirm prompt box is added to prompt the user to confirm the operation again and improve the accuracy of the operation.

[0296] The process of updating the dependency list based on the operation queue is further described below.

[0297] In a possible implementation, the first operation data is taken out from the head of the operation queue, the dependency relationship contained in the first operation data is synchronized to the dependency list, and then the first operation data is deleted from the operation queue; then the second operation data is taken out from the head of the operation queue, the dependency relationship contained in the first operation data is synchronized to the dependency list, and then the second operation data is deleted from the operation queue. In this way, the dependency relationship contained in each operation data in the operation queue is synchronized to the dependency list until the operation queue is empty.

[0298] Exemplarily, refer to Figure 6 , Figure 6 The flowchart of updating the dependency list based on the operation queue is shown.

[0299] As shown in (a) of Figure 6 , the browser updates the dependency list 610 based on the operation queue 620. The operation queue 620 sequentially saves six operation data in the order from the head to the tail, and the six operation data are the operation data 630 of the increase type, the operation data 631 of the delete type, the operation data 632 of the increase type, the operation data 633 of the increase type, the operation data 634 of the modification type and the operation data 635 of the modification type.

[0300] The process of updating the dependency list based on the operation data 630 is as shown in Figure 6As shown in (b), the browser retrieves operation data 630 from the head of operation queue 620, causing operation data 630 to be dequeued from operation queue 620. Based on operation data 630, the browser performs an add operation on dependency list 610; for example, the browser adds the resource identifier from operation data 630 to dependency list 610. The browser removes operation data 630 from operation queue 620, resulting in operation queue 621.

[0301] The process by which the browser updates the dependency list based on operation data 631 is as follows: Figure 6 As shown in (c), the browser retrieves operation data 631 from the head of operation queue 621, causing operation data 631 to be dequeued from operation queue 620. Based on operation data 631, the browser performs a deletion operation on dependency list 611, resulting in dependency list 612. For example, the browser removes the resource identifier from operation data 631 in dependency list 610. The browser then removes operation data 631 from operation queue 620, resulting in operation queue 622.

[0302] For the process of updating the dependency list based on operation data 632 and 633, please refer to the process of updating the dependency list based on operation data 630. After updating the dependency list sequentially based on operation data 632 and 633, the browser deletes operation data 632 and 633 sequentially from the operation queue 620. After the deletion of operation data 632 and 633, modification-type operation data 634 and 635 are moved to the head of the operation queue simultaneously because they were saved to the queue at the same time. Modification-type operation data 634 corresponds to the operation data of the old version of the dependency list. Modification-type operation data 635 corresponds to the operation data of the new version of the dependency list.

[0303] like Figure 6 As shown in (d), the browser obtains operation data 634 and operation data 635 from the operation queue. Based on operation data 634 and operation data 635, the browser modifies the values ​​of resources in the dependency list, resulting in dependency list 613. The browser then removes operation data 634 and operation data 635 from the operation queue, resulting in operation queue 623. All operation data in operation queue 623 has been merged into dependency list 614, and operation queue 623 is now empty. The browser then deletes operation queue 623.

[0304] In one possible implementation of synchronizing the dependency relationship in the operation data to the dependency list, the operation type, the identifier of the resource to which the operation is directed, and the dependency relationship of the resource are obtained from the operation data; the second dependency list is updated based on the operation type, the identifier of the resource to which the operation is directed, and the dependency relationship of the resource, to obtain a third dependency list. For example, the process of updating the second dependency list includes steps a to c as follows.

[0305] Step a: in response to the operation type being addition, a dependency relationship is added to the second dependency list based on the identifier of the resource to which the addition operation is directed, to obtain a third dependency list.

[0306] For example, in response to the first Kubernetes resource to which the addition operation is directed being a child resource, an entry is added in the second dependency list. The identifier of the first Kubernetes resource is added to a key field of the new entry, and the identifier of the parent resource of the first Kubernetes resource is added to a value field corresponding to the key field in the new entry.

[0307] Illustratively, the added resource is pod3, the first dependency list is obtained by inverting the resource list and reversing the dependency, and the parent resource of pod3 is found to be deployment 3 based on the first dependency list. The operation data includes the addition type, pod3, and deployment 3. The second dependency list in the cache is as shown in Table 2 below. Based on the type of pod3 being a child resource, an entry is added to Table 2, pod3 is added to the key field of the entry, and deployment 3 is added to the value field corresponding to the key field in the entry, to obtain the third dependency list as shown in Table 3 below.

[0308] Table 2

[0309] key value pod1 deployment 1 pod2 deployment 2

[0310] Table 3

[0311] key value pod1 deployment 1 pod2 deployment 2 pod3 deployment 3

[0312] For another example, in response to the first Kubernetes resource to which the addition operation is directed being a parent resource, the identifier of the second Kubernetes resource that is a child resource of the first Kubernetes resource is used as an index to determine an entry to be updated in the second dependency list, the key field of the entry including the identifier of the second Kubernetes resource; and the identifier of the first Kubernetes resource is added to the value field of the entry.

[0313] Exemplarily, the added resource is deployment 3, the first dependency list is obtained by inverting indexing the resource list, the child resource of deployment 3 is queried to be pod1 based on the first dependency list, the operation data is obtained, and the operation data includes the adding type, pod1 and deployment 3. The second dependency list shown in Table 4 is included in the cache. The pod1 is taken as an index to search in Table 4. In response to that pod1 matches the key field of the first entry in Table 4, deployment 3 is added to the value field of the first entry in Table 4, to obtain the third dependency list shown in Table 5.

[0314] Table 4

[0315] key value pod1 deployment 1 pod2 deployment 2

[0316] Table 5

[0317]

[0318]

[0319] In step b, in response to that the operation type is deletion, the dependency relationship is deleted from the second dependency list based on the identification of the resource to which the deletion operation is directed.

[0320] For example, in response to that the first Kubernetes resource to which the deletion operation is directed is a child resource, the entry to be deleted is determined in the second dependency list with the identification of the first Kubernetes resource as an index, and the key field of the entry includes the identification of the first Kubernetes resource; the entry is deleted from the second dependency list.

[0321] Exemplarily, the deleted resource is pod3. The second dependency list shown in Table 6 is included in the cache. Based on that the type of pod3 is a child resource, pod3 is taken as an index to search in Table 6. In response to that pod3 matches the key field of the third entry in Table 6, the third entry in Table 6 is deleted, to obtain the third dependency list shown in Table 7.

[0322] Table 6

[0323] key value pod1 deployment 1 pod2 deployment 2 pod3 deployment 3

[0324] Table 7

[0325] key value pod1 deployment 1 pod2 deployment 2

[0326] For example, in response to the first Kubernetes resource to which the delete operation is directed being a parent resource, taking the identity of a second Kubernetes resource that is a child resource of the first Kubernetes resource as an index, an entry to be modified is determined in the second dependency list, a key field of the entry including the identity of the second Kubernetes resource; and the identity of the first Kubernetes resource is deleted from a value field of the entry.

[0327] Exemplarily, the deleted resource is deployment 3. The second dependency list included in the cache is shown in Table 8 as follows. Based on the type of deployment 3 being a child resource, and the child resource of deployment 3 being podl, podl is taken as an index to search in Table 8. In response to podl matching the key field of the first entry in Table 8, deployment 3 is deleted from the value field of the first entry, obtaining a third dependency list shown in Table 9.

[0328] Table 8

[0329] key value pod1 {deployment 1, deployment 3} pod2 deployment 2

[0330] Table 9

[0331] key value pod1 deployment 1 pod2 deployment 2

[0332] Step c, in response to the operation type being modification, modifying the dependency relationship in the second dependency list based on the resource to which the modification operation is directed.

[0333] For example, in response to the first Kubernetes resource to which the delete operation is directed being a parent resource, taking the identity of a second Kubernetes resource that is a child resource of the first Kubernetes resource as an index, an entry to be modified is determined in the second dependency list, a key field of the entry including the identity of the second Kubernetes resource; and the identity of the first Kubernetes resource is deleted from a value field of the entry. Taking the identity of a third resource as an index, a second entry to be modified is determined in the second dependency list, a key field of the second entry including the identity of the third resource; and the identity of the first Kubernetes resource is added to a value field of the second entry.

[0334] For example, the first Kubernetes resource is deployment 3, the second Kubernetes resource is pod1, the third resource is pod2, the modification operation is to modify the child resource of deployment 3 from pod1 to pod2, and pod1 is indexed to find in the second dependency list shown in Table 10; in response to pod1 matching the key pod1 of the first entry, deployment 3 is deleted from the value field {deployment 1, deployment 3} of the first entry. In addition, pod2 is indexed to find in the second dependency list shown in Table 10; in response to pod2 matching the key pod2 of the second entry, deployment 3 is added to the value field deployment 2 of the first entry, thereby obtaining the third dependency list shown in Table 11.

[0335] Table 10

[0336] key value pod1 {deployment 1, deployment 3} pod2 deployment 2

[0337] Table 11

[0338] key value pod1 deployment 1 pod2 {deployment 2, deployment 3}

[0339] The software architecture provided by the present embodiment is described below.

[0340] Please refer to Figure 7 , Figure 7 is a structural diagram of a dependency query device 600 provided by the present embodiment, which includes an inverted index module 601, a modification comparison module 602, and a data update module 603.

[0341] The inverted index module 601 is configured to perform inverted indexing and dependency inversion on the resource list received by the interface, to obtain a dependency list. Since the redundant information is removed, the retrieval speed is greatly improved.

[0342] The modification comparison module 602 is configured to obtain the dependency list of the previous version and the dependency list of the current version from the resource list based on the keyword and the inverted index table for the resource list of the modification type. The modification comparison module 602 compares the dependency list of the previous version and the dependency list of the current version. If the dependency list of the previous version and the dependency list of the current version are the same, it is determined that the resource to which the modification operation is directed has no effect on determining the dependency list, and the step of updating the saved dependency list of the previous version based on the dependency list of the current version is cancelled. If the dependency list of the previous version and the dependency list of the current version are different, it is determined that the resource related to the dependency list is modified, and the dependency list of the previous version and the dependency list of the current version are compared to determine the modified resource, and the operation data is obtained based on the modified resource.

[0343] In the case of the operation type being modification, the modification comparison module 602 does not need to save all the historical versions of the dependency list, but only needs to save the dependency list of the previous version and the dependency list of the current version, thereby greatly reducing the occupied cache space.

[0344] In the case of the operation type being addition or deletion, the modification comparison module 602 does not need to save all the historical versions of the dependency list, but only needs to save the dependency list of the current version, thereby greatly reducing the occupied cache space. The specific process of the modification comparison module 602 is shown as S302 in FIG. 3. Figure 3

[0345] The data update module 603 is configured to save the dependency list and the FIFO operation queue. The data update module 603 does not perform real-time update on the dependency list, but only synchronizes the dependency list according to the operation queue execution order when the operation is executed, thereby greatly improving the data performance optimization and accuracy.

[0346] The following is an example of a simplified front-end project.

[0347] For example, the directory structure of the front-end project is as follows.

[0348] demo /

[0349] ├──public /

[0350] │└──index.html

[0351] ├──src /

[0352] │├──api /

[0353] ││└──index.js

[0354] │├──service /

[0355] ​││└──index.js

[0356] │├──App.js

[0357] │├──index.js

[0358] │└──...

[0359] ├──package.json

[0360] └── ...

[0362] The above directory structure contains the following files and folders:

[0363] public / is the public directory, which is used to store static files such as the application's index.html and other public resources.

[0364] src / is the source code directory, which is used to store the application's source code, such as source code for calling APIs and services.

[0365] api / is the API request directory, which is used to store API request functions for communication with the backend.

[0366] service / is the service directory, which is used to store service functions related to business logic.

[0367] App.js is the main file of the application, which contains the code that implements the main logic of the application.

[0368] index.js is the entry file of the application, which is used to render the content in App.js to the page. In addition, index.js can also be used to manage the dependency list of the application.

[0369] package.json is the configuration file of the application, which contains the dependency, script and version information of the application.

[0370] In summary, the above embodiments implement a resource protection mechanism based on browser Kubernetes, which uses browser caching and retrieval algorithms and data update algorithms to achieve high-performance dependency queries. The effects achieved include but are not limited to the following aspects.

[0371] First, improve the retrieval speed: use inverted index to convert the resource list to dependency list, combine with operation type, lay the foundation for subsequent update;

[0372] Second, improve data update and maintenance performance: combine real data and auxiliary data FIFO queue, save the dependency relationship obtained in a period of time to the operation queue, delay updating the data operation, and alleviate the performance problem caused by frequent data operation.

[0373] Third, improve data comparison efficiency: improve data comparison under modification type based on inverted index, greatly improve the accuracy of data comparison.

[0374] Optionally, the embodiment further realizes the establishment of a visual association relationship tree diagram to establish a relationship network of Kubernetes resources, facilitating resource maintenance by development and operation personnel. For example, each node in the tree diagram represents a resource, the edge between the nodes represents the dependency relationship between the resources, and the position of the node in the tree diagram represents the level of the node. For example, the tree diagram includes a first node and a second node, the first node represents a first Kubernetes resource, and the second node represents a second Kubernetes resource, the first Kubernetes resource is a parent resource of the second Kubernetes resource, and the first node is a parent node of the second node. Illustratively, a stateless application is represented as a root node in the tree diagram, a container group is represented as a first-level node connected to the root node in the tree diagram, and a container is represented as a second-level node connected to the first-level node in the tree diagram.

[0375] Figure 8A is a structure diagram of a dependency list acquisition device provided by the embodiment of the application, applied to a browser, and the device includes:

[0376] The first obtaining module 801 is configured to obtain an inverted index table based on a resource list, the resource list including data of at least one Kubernetes resource, and the inverted index table including a word in the resource list and an index corresponding to the word;

[0377] The second obtaining module 802 is configured to obtain an identification of a first Kubernetes resource and an identification of a second Kubernetes resource from the resource list based on the word and the index, the second Kubernetes resource having a dependency relationship with the first Kubernetes resource;

[0378] The third obtaining module 803 is configured to obtain a first dependency list based on the identification of the first Kubernetes resource and the identification of the second Kubernetes resource, the first dependency list being used to protect at least one of the first Kubernetes resource or the second Kubernetes resource, and the first dependency list including the identification of the first Kubernetes resource and the identification of the second Kubernetes resource.

[0379] In a possible implementation, the second obtaining module 802 is configured to: determine the data of the first Kubernetes resource from the resource list based on an index, the index being used to identify a position of the data of the first Kubernetes resource in the resource list; and obtain the identifier of the first Kubernetes resource and the identifier of the second Kubernetes resource from the data of the first Kubernetes resource based on a word, the data of the first Kubernetes resource including a key-value pair, the key in the key-value pair including the word, and the value in the key-value pair including the identifier of the second Kubernetes resource.

[0380] In a possible implementation, the third obtaining module 803 is configured to: in response to determining that the first Kubernetes resource is a parent resource of the second Kubernetes resource, write the identifier of the first Kubernetes resource into a value field of the first dependency list and write the identifier of the second Kubernetes resource into a key field of the first dependency list; or in response to determining that the first Kubernetes resource is a child resource of the second Kubernetes resource, write the identifier of the first Kubernetes resource into the key field of the first dependency list and write the identifier of the second Kubernetes resource into the value field of the first dependency list.

[0381] In a possible implementation, the first dependency list includes a first version of a dependency list and a second version of the dependency list, and the resource list includes a first version of a resource list and a second version of the resource list, the first version of the dependency list being obtained based on the first version of the resource list, and the second version of the dependency list being obtained based on the second version of the resource list, and the apparatus further includes:

[0382] The comparison module is configured to, in response to the operation type corresponding to the first version of the resource list being modification, compare the first version of the dependency list and the second version of the dependency list to obtain a first dependency relationship, the first dependency relationship being a dependency relationship that is modified in comparison between the first version of the dependency list and the second version of the dependency list.

[0383] The saving module is configured to save the first dependency relationship to a queue.

[0384] In a possible implementation, the second dependency list is saved in a cache of the computing device, and the apparatus further includes:

[0385] The fourth obtaining module is configured to, in response to an operation instruction, obtain the first dependency relationship from the queue, the operation instruction indicating deletion or modification of the first Kubernetes resource.

[0386] The updating module is configured to synchronize the first dependency relationship to the second dependency list to obtain a third dependency list.

[0387] In a possible implementation, the queue is a first-in first-out queue, and the saving module is configured to add the first dependency relationship to a tail end of the first-in first-out queue;

[0388] The fourth obtaining module is configured to obtain the first dependency relationship from a head end of the first-in first-out queue.

[0389] In a possible implementation, the apparatus further includes:

[0390] The comparison module is configured to compare the number of identities of the Kubernetes resources and the occurrence times.

[0391] The determination module is configured to determine that the number of identities of the Kubernetes resources is the same as the occurrence times.

[0392] In a possible implementation, the apparatus further includes:

[0393] The display module is configured to display first prompt information in response to a determination that the number of identities of the Kubernetes resources is different from the occurrence times.

[0394] In a possible implementation, the apparatus further includes:

[0395] The fifth obtaining module is configured to obtain an identity of a second Kubernetes resource based on the identity of the first Kubernetes resource and the third dependency list.

[0396] The display module is configured to display second prompt information based on the identity of the second Kubernetes resource, the second prompt information being used to prompt a risk caused by the first Kubernetes resource to the second Kubernetes resource.

[0397] Figure 8A The described apparatus embodiments are merely illustrative. For example, the division of the above modules is merely a logical function division, and another division manner can be used in actual implementation, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. The function modules in each embodiment of the present application can be integrated in one processing module, or each module can be physically present separately, or two or more modules can be integrated in one module.

[0398] Figure 8A Each module in the described apparatus is realized by software, hardware, firmware, or any combination thereof, in whole or in part.

[0399] The following describes the use of hardware or software to realize the apparatus Figure 8ASome possible implementations of the various functional modules in the described apparatus.

[0400] In the case of implementation in software, for example, the first obtaining module 801 and the second obtaining module 802 described above are implemented by the processor 901 in the terminal 100 reading program code stored in the memory 902. Figure 9 In the case of implementation in software, for example, the first obtaining module 801 and the second obtaining module 802 described above are implemented by the processor 901 in the terminal 100 reading program code stored in the memory 902.

[0401] In the case of implementation in hardware, for example, Figure 8A In the case of implementation in hardware, for example, Figure 9 In the case of implementation in hardware, for example, Figure 9 In the case of implementation in hardware, for example,

[0402] Figure 8B is a structural schematic diagram of a Kubernetes resource protection apparatus provided by an embodiment of the present application, applied to a browser, and the apparatus comprises:

[0403] The obtaining module 810 is configured to, in response to a modification operation or a deletion operation triggered for a first Kubernetes resource, obtain an identifier of a second Kubernetes resource based on an identifier of the first Kubernetes resource and a dependency list, the dependency list being obtained based on the method in the first aspect or any of the optional manners of the first aspect.

[0404] The display module 820 is configured to display second prompt information in an interface of the browser based on the identifier of the second Kubernetes resource, the second prompt information being used to prompt a risk caused by deletion or modification of the first Kubernetes resource on the second Kubernetes resource.

[0405] Figure 8B The apparatus embodiment described is merely illustrative, for example, the division of the above-described modules is merely a logical functional division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. The functional modules in each embodiment of the present application can be integrated in one processing module, or can be physically present separately, or two or more modules can be integrated in one module.

[0406] Figure 8B Each module in the described apparatus is implemented, in whole or in part, by software, hardware, firmware, or any combination thereof.

[0407] The following describes some possible implementation manners of each functional module in the described apparatus. Figure 8B The following describes some possible implementation manners of each functional module in the described apparatus.

[0408] In the case of implementation in software, for example, the above-mentioned obtaining module 810 is implemented by a software module stored in the memory 902 and read by the at least one processor 901 in the terminal 900. Figure 9 In the case of implementation in software, for example, the above-mentioned obtaining module 810 is implemented by a software module stored in the memory 902 and read by the at least one processor 901 in the terminal 900.

[0409] In the case of implementation in hardware, for example, Figure 8B In the case of implementation in hardware, for example, Figure 9 In the case of implementation in hardware, for example, Figure 9 In the case of implementation in hardware, for example,

[0410] The following describes some possible implementation manners of each functional module in the described apparatus. Figure 9 FIG. 9 is a structural schematic diagram of a terminal 900 provided by an embodiment of the present application.

[0411] The terminal 900 includes a processor 901, a memory 902, a display 905, and a network interface 903.

[0412] The processor 901 is, for example, a general central processing unit (CPU), a network processor (NP), a graphics processing unit (GPU), a neural-network processing units (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits used to implement the schemes of the present application. For example, the processor 901 includes an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. The processor 901 is, for example, a single-CPU, and is also, for example, a multi-CPU. The processor 901 optionally refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0413] The memory 902 is, for example, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, a electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, a magnetic disk storage or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to this. Optionally, the memory 902 exists independently and is connected to the processor 901 through the internal connection 904. Alternatively, the memory 902 and the processor 901 are integrated together.

[0414] The display 905 is configured to display an interface of the browser.

[0415] The network interface 903 is configured to communicate with other devices or communication networks using any transceiver-like mechanism, for example, to receive a list of resources from a server. The network interface 903 includes at least one of a wired network interface or a wireless network interface, for example. The wired network interface is an Ethernet interface, for example. The Ethernet interface is an optical interface, an electrical interface, or a combination thereof, for example. The wireless network interface is a wireless local area networks (WLAN) interface, a cellular network interface, or a combination thereof, for example.

[0416] In some embodiments, the terminal 900 optionally includes a plurality of processors, such as the processor 901 and the processor 905 as shown in FIG. 9B. Figure 9

[0417] In some embodiments, the terminal 900 further includes an internal connection 904. The processor 901, the memory 902, and the at least one network interface 903 are connected through the internal connection 904. The internal connection 904 includes a path for transmitting information between the above-mentioned components. Optionally, the internal connection 904 is a single board or a bus. Optionally, the internal connection 904 is divided into an address bus, a data bus, a control bus, and the like.

[0418] Optionally, the processor 901 implements the method in the above embodiments by reading program codes stored in the memory 902, or the processor 901 implements the method in the above embodiments by reading program codes stored in the internal storage. In the case where the processor 901 implements the method provided in the embodiments of the present application by reading program codes stored in the memory 902, the memory 902 stores program codes and data for implementing the method provided in the embodiments of the present application, such as computer program instructions and data of the browser.

[0419] Dependency list

[0420] For more details of the processor 901 implementing the above functions, please refer to the description in the foregoing method embodiments, which will not be repeated here.

[0421] Each of the embodiments in the specification is described in a progressive manner, and the same or similar parts between each of the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments.

[0422] A refers to B, which means that A is the same as B or a simple transformation of B.

[0423] ​The terms "first" and "second" and the like in the description and claims of the present application are used to distinguish different objects, and are not used to describe a specific order or sequence, nor are they used to indicate or imply relative importance of the objects. For example, the first Kubernetes resource and the second Kubernetes resource are used to distinguish different resources, and are not used to describe a specific order or sequence, nor are they used to indicate or imply that the first Kubernetes resource is more important than the second Kubernetes resource.

[0424] In the embodiments of the present application, unless otherwise specified, "at least one" means one or more, and "a plurality of" means two or more.

[0425] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, the computer program instructions produce the processes or functions described in the embodiments of the present application in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another, for example, the computer instructions can be transferred from one website, computer, server or data center to another via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available media can be magnetic media (such as floppy disks, hard disks, magnetic tapes), optical media (such as DVDs), or semiconductor media (such as solid state disks (SSD)), etc.

[0426] The above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method of acquiring a dependency list, characterized by, The method comprises: obtaining an inverted index table based on a resource list, the resource list comprising data of at least one Kubernetes resource, the inverted index table comprising a word in the resource list and an index corresponding to the word; determining data of a first Kubernetes resource from the resource list based on the index, the index being used to identify a position of the data of the first Kubernetes resource in the resource list; obtaining an identification of the first Kubernetes resource and an identification of a second Kubernetes resource from the data of the first Kubernetes resource based on the word, the second Kubernetes resource having a dependency relationship with the first Kubernetes resource; obtaining a first dependency list based on the identification of the first Kubernetes resource and the identification of the second Kubernetes resource, the first dependency list being used to protect at least one of the first Kubernetes resource or the second Kubernetes resource, the first dependency list comprising a key-value pair, a key in the key-value pair comprising the identification of the first Kubernetes resource and an identification of a child resource of the second Kubernetes resource, and a value in the key-value pair comprising the identification of the first Kubernetes resource and an identification of a parent resource of the second Kubernetes resource.

2. The method of claim 1, wherein, The obtaining of the first dependency list based on the identification of the first Kubernetes resource and the identification of the second Kubernetes resource comprises: in response to determining that the first Kubernetes resource is a parent resource of the second Kubernetes resource, writing the identification of the first Kubernetes resource into a value field of the first dependency list and writing the identification of the second Kubernetes resource into a key field of the first dependency list; or in response to determining that the first Kubernetes resource is a child resource of the second Kubernetes resource, writing the identification of the first Kubernetes resource into the key field of the first dependency list and writing the identification of the second Kubernetes resource into the value field of the first dependency list.

3. The method of claim 1, wherein, The first dependency list comprises a first version of a dependency list and a second version of a dependency list, the resource list comprises a first version of a resource list and a second version of a resource list, the first version of the dependency list being obtained based on the first version of the resource list, the second version of the dependency list being obtained based on the second version of the resource list, and after the obtaining of the first dependency list based on the identification of the first Kubernetes resource and the identification of the second Kubernetes resource, the method further comprises: In response to the operation type corresponding to the first version of the resource list being modification, the first version of the dependency list and the second version of the dependency list are compared to obtain a first dependency relationship, the first dependency relationship being a dependency relationship that is modified compared to the second version of the dependency list; The first dependency relationship is saved to a queue.

4. The method of claim 3, wherein, The second dependency list is saved in a cache of a computing device, and after the first dependency relationship is saved to the queue, the method further includes: In response to an operation instruction, the first dependency relationship is obtained from the queue, the operation instruction indicating deleting or modifying the first Kubernetes resource; The first dependency relationship is synchronized to the second dependency list to obtain a third dependency list.

5. The method of claim 3, wherein, The queue is a first-in-first-out queue, and the first dependency relationship is saved to the queue includes: The first dependency relationship is added to a tail end of the first-in-first-out queue; The first dependency relationship is obtained from the queue includes: The first dependency relationship is obtained from a head end of the first-in-first-out queue.

6. The method of claim 3, wherein, The inverted index table further includes a number of occurrences of the word in the resource list, and before the first version of the dependency list and the second version of the dependency list are compared, the method further includes: The number of occurrences of the word in the resource list is compared with the number of occurrences of the word in the resource list; It is determined that the number of occurrences of the word in the resource list is the same as the number of occurrences of the word in the resource list.

7. The method of claim 6, wherein, After the number of occurrences of the word in the resource list is compared with the number of occurrences of the word in the resource list, the method further includes: In response to determining that the number of occurrences of the word in the resource list is different from the number of occurrences of the word in the resource list, a first prompt information is displayed.

8. The method of claim 4, wherein, After the first dependency relationship is synchronized to the second dependency list to obtain a third dependency list, the method further includes: Based on the identifier of the first Kubernetes resource and the third dependency list, the identifier of the second Kubernetes resource is obtained; Based on the identifier of the second Kubernetes resource, a second prompt information is displayed, the second prompt information being used to prompt a risk caused by deleting or modifying the first Kubernetes resource on the second Kubernetes resource. 9.A method for protecting a Kubernetes resource, the method comprising: The method includes: In response to detecting a modification operation or a deletion operation triggered for a first Kubernetes resource, an identifier of a second Kubernetes resource dependent on the first Kubernetes resource is obtained based on an identifier of the first Kubernetes resource and a dependency list, the dependency list being obtained based on the method in any one of claims 1 to 8; Display second prompt information in the interface based on the identification of the second Kubernetes resource, the second prompt information including the identification of the second Kubernetes resource, the second prompt information being used to prompt to delete or modify the risk caused by the first Kubernetes resource to the second Kubernetes resource.

10. A terminal, characterized by comprising: The terminal comprises a display, a processor and a memory. The display is used to display an interface. The processor executes computer program instructions stored in the memory, so that the terminal executes the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Component version modification method, system and device, electronic equipment and medium

    CN115840585A

  • Protecting integration between resources of different services using service-generated dependency tags

    US11356382B1