A method and device for implementing container expulsion

By detecting the current status and operating status information of the container unit, it is determined that the reason why the container has not been successfully run is that the physical machine cannot provide the operating environment, and the instructions to expel the container unit are generated, which solves the problem that the cause of the failure of the container operation in the prior art cannot be accurately judged. , improves the accuracy and operating efficiency of container eviction.

CN111767113BActive Publication Date: 2025-02-21BEIJING WODONG TIANJUN INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910256820.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-01
Publication Date
2025-02-21
Estimated Expiration
2039-04-01

Smart Images

  • Figure CN111767113B_ABST
    Figure CN111767113B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for implementing container expulsion, and relates to the field of computer technology. A specific implementation of the method includes: determining that the container unit has not run successfully based on the running status information of the container unit; detecting the current status of the container included in the container unit, and determining the reason why the container unit has not run successfully based on the current status; and generating an instruction to expel the container unit when it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide an operating environment. The method detects the container unit that cannot run successfully due to the physical machine being unable to provide an operating environment, and does not perform multiple restart operations for the container unit that cannot run successfully due to the physical machine being unable to provide an operating environment, thereby improving the operating efficiency. The accuracy of container expulsion is improved, and the container expulsion strategy is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for realizing container expulsion. Background Art

[0002] In the prior art, to implement container eviction, a container is generally evicted when it is in an "abnormal operation" state for a long time (reaching a time threshold). Kubernetes is a distributed system for container cluster orchestration and management, which schedules and runs containers on multiple nodes in the cluster. When a container unit pod cannot run normally due to some reasons (the physical machine cannot provide an operating environment or there is a problem with the program inside the container), kubernetes will repeatedly restart the container until the container can run normally, or it will be evicted when the restart time reaches a certain time threshold.

[0003] In the above processing, if the container cannot run due to problems with the physical machine itself, and the external environment on which the container depends for restarting and running does not change, repeatedly restarting the container on the same node will be useless. The existing technology is to evict containers that are repeatedly restarted, so that the containers are rescheduled to other nodes. However, this method cannot determine whether the reason for the failure of the container to run is caused by external environmental problems or by problems with the application itself. If the reason is the former, then even if the container is rescheduled, it will still not run. If the container is restarted continuously, the operating efficiency will be reduced. In addition, if the container is expelled without being sure whether it is caused by external environmental problems, the accuracy of the expulsion will also be reduced. Summary of the invention

[0004] In view of this, the embodiment of the present invention provides a method and device for implementing container expulsion, which can detect container units that cannot run successfully due to the inability of the physical machine to provide an operating environment, and no longer perform multiple restart operations for the container units that cannot run successfully due to the inability of the physical machine to provide an operating environment, thereby improving operating efficiency. And the expelled container units are those that cannot run normally no matter how many times they are restarted, so the accuracy of container expulsion is improved and the container expulsion strategy is optimized.

[0005] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for implementing container expulsion is provided.

[0006] The method for implementing container expulsion in an embodiment of the present invention includes: determining, based on running status information of the container unit, that the container unit has not run successfully; detecting a current status of a container included in the container unit, and determining a reason why the container unit has not run successfully based on the current status; and generating an instruction to expel the container unit when it is determined that the reason why the container unit has not run successfully is that a physical machine on which the container unit runs cannot provide a running environment.

[0007] Optionally, the step of detecting the current state of the container included in the container unit includes: acquiring a state field of the container included in the container unit; and determining the current state of the container included in the container unit according to the state field.

[0008] Optionally, the step of determining that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide the operating environment includes: determining that the current state of the container included in the container unit belongs to a predefined set of states to be evicted; and when the duration of the current state exceeds a preset threshold, determining that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide the operating environment.

[0009] Optionally, the set of states to be evicted includes: a sandbox container cannot run, an initialization container is being created, and a common container is being created; wherein,

[0010] The field information that the sandbox container cannot run is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is PodInitializing;

[0011] The field information of the initialization container being created is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is ContainerCreating;

[0012] The field information of the common container being created is: PodScheduled = true, Initialized = true, and the Waiting of the common container is ContainerCreating.

[0013] Optionally, after generating the instruction to evict the container unit, the method further includes: creating a replacement copy of the container unit; scheduling the replacement copy, and binding the replacement copy to a node, so that the replacement copy starts running on the node.

[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for realizing container expulsion is provided.

[0015] The device for implementing container expulsion according to the embodiment of the present invention includes:

[0016] A module for determining that the operation is not successful is used to determine that the container unit is not successfully operated according to the operation status information of the container unit;

[0017] a current state detection module, used to detect the current state of the container included in the container unit, and determine the reason why the container unit fails to operate successfully according to the current state;

[0018] The instruction module is used to generate an instruction to expel the container unit when it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment.

[0019] Optionally, the current state detection module is further configured to obtain a state field of a container included in the container unit; and determine a current state of the container included in the container unit according to the state field.

[0020] Optionally, the current state detection module is further used to determine whether the current state of the container included in the container unit belongs to a predefined set of states to be evicted; when the duration of the current state exceeds a preset threshold, it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide an operating environment.

[0021] Optionally, the device for implementing container eviction in an embodiment of the present invention also includes a substitute copy creation module, which is used to create a substitute copy of the container unit; and schedule the substitute copy and bind the substitute copy to a node so that the substitute copy starts running on the node.

[0022] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0023] An electronic device according to an embodiment of the present invention includes: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above methods for implementing container expulsion.

[0024] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, any of the above methods for implementing container expulsion is implemented.

[0025] One embodiment of the above invention has the following advantages or beneficial effects: after determining that the container unit has not run successfully, the current state of the container included in the container unit is detected, and the reason why the container unit has not run successfully can be determined. When it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide an operating environment, an instruction to evict the container unit is generated. The present invention can detect container units that cannot run successfully due to external environmental problems (the physical machine cannot provide an operating environment), thereby optimizing the container eviction strategy and solving the problem in the prior art of performing many invalid restarts due to the inability to determine whether the failure of the container unit to run is caused by external environmental problems. In addition, it overcomes the problem that the prior art evicts the container unit when it is not determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide an operating environment, thereby reducing the accuracy of the eviction.

[0026] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0028] Figure 1 is a schematic diagram of the main process of a method for implementing container expulsion according to an embodiment of the present invention;

[0029] Figure 2 is a schematic diagram of a method for implementing container expulsion according to an embodiment of the present invention;

[0030] Figure 3 is a schematic diagram of a method for container eviction based on Kubernetes according to an embodiment of the present invention;

[0031] Figure 4 is a schematic diagram of the interaction architecture between Descheduler and Kubernetes according to an embodiment of the present invention;

[0032] Figure 5 is a schematic diagram of main modules of an apparatus for implementing container expulsion according to an embodiment of the present invention;

[0033] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0034] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0036] Figure 1 is a schematic diagram of the main process of a method for implementing container eviction according to an embodiment of the present invention, such as Figure 1 As shown, the method for implementing container expulsion in an embodiment of the present invention mainly includes:

[0037] Step S101: Determine that the container unit has not run successfully based on the running status information of the container unit. The running status information of the container unit refers to the information recorded in the running status list of the container unit. In the embodiment of the present invention, determining that the container unit has not run successfully based on the running status information of the container unit means: it can be determined that the container unit has not run successfully through the records in the running status list of the container unit. For example, if the running status of the container unit is recorded as "has been scheduled but has not run successfully", it can be determined that the container unit has not run successfully based on this information.

[0038] Step S102: Detect the current state of the container included in the container unit, and determine the reason why the container unit did not run successfully based on the current state. The container unit is an abstract representation of a container. It can contain one or more container instances and is the smallest management and scheduling unit of the container management system. In an embodiment of the present invention, the container unit may be a pod, which is the smallest unit of Kubernetes (an open source container cluster orchestration and management system). The container is contained in the pod, and a pod has a pause container and several business containers. The pod manages user business containers that are closely related to multiple businesses. This architecture facilitates the expansion of Kubernetes.

[0039] Step S103: if it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide the running environment, an instruction to evict the container unit is generated. If the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide the running environment, the container unit still cannot run even if it is rescheduled.

[0040] According to an embodiment of the present invention, after determining that the container unit has not run successfully, the current state of the container included in the container unit is detected, and the reason why the container unit has not run successfully can be determined. In the case where it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide the operating environment, an instruction to expel the container unit is generated. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, since it cannot run successfully due to external environmental problems, no matter whether the application itself has problems, it will not run successfully no matter how many times it is restarted. The present invention can detect the container unit that cannot run successfully due to external environmental problems (the physical machine cannot provide the operating environment), and will not perform many invalid restarts on the container, thereby optimizing the container's expulsion strategy and improving the operating efficiency. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, it is possible to run successfully after restarting a few more times if there is no problem with the application itself, which solves the problem in the prior art that all container units are expelled after a fixed time of restart (which may include container units that have not run successfully because there is no problem with the application itself and the physical machine on which it runs cannot provide the operating environment) resulting in reduced expulsion accuracy.

[0041] Figure 2 is a schematic diagram of a method for implementing container expulsion according to an embodiment of the present invention; Figure 2 As shown, the method for implementing container expulsion in an embodiment of the present invention includes:

[0042] Step S201: Determine, based on the running status information of the container unit, that the container unit has not run successfully. In an embodiment of the present invention, the container unit may have been restarted multiple times. If the restart time exceeds a preset time threshold, or the number of restarts exceeds a preset number threshold, the running status information of the container unit is recorded as "failed to run successfully". In another embodiment of the invention, if the container unit is found to have not run successfully after being started once, it will not be restarted, and the running status information of the container unit will be recorded as "failed to run successfully".

[0043] Step S202: Obtain the status field of the container included in the container unit, and determine the current status of the container included in the container unit according to the status field. The method for determining the current status of the container included in the container unit is not limited to the method of using the status field of the container in this embodiment, and the above specific implementation does not constitute a limitation on the protection scope of the present invention.

[0044] Step S203: Determine whether the current state of the container included in the container unit belongs to a predefined set of states to be evicted. The set of states to be evicted includes: a sandbox container cannot run, an initialization container is being created, and a normal container is being created. The sandbox container is a sandbox container, the initialization container is an init container, and the normal container is a regular container.

[0045] The containers in a pod include: sandbox container, init container, and regular container. During the operation of the container unit pod, the sandbox container is created first, which builds the basic operating environment for the init container and the regular container. Then the init container runs, which is responsible for initializing the configuration information and data required by the application. The regular container runs last, which is responsible for executing the business logic of the application.

[0046] For the status in the set of statuses to be evicted, the corresponding field information is as follows:

[0047] The field information that the sandbox container cannot run is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is PodInitializing;

[0048] The field information of the initialization container being created is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is ContainerCreating;

[0049] The field information of the common container being created is: PodScheduled = true, Initialized = true, and the Waiting of the common container is ContainerCreating.

[0050] The specific explanations of the above field information are as follows:

[0051] PodScheduled = true means the pod is scheduled successfully, Initialized = false means the init container has not exited successfully, and the Waiting of the init container is PodInitializing, which means the sandbox is being created;

[0052] PodScheduled = true means the pod is scheduled successfully, Initialized = false means the init container has not exited successfully, and the init container's Waiting is ContainerCreating, which means the init container is being created;

[0053] PodScheduled = true means that the pod is scheduled successfully, Initialized = true means that the init container exits successfully, and the Waiting of the regular container is ContainerCreating, which means that the regular container is being created.

[0054] Step S204: when the duration of the current state exceeds a preset threshold, it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment.

[0055] Step S205: Generate an instruction to evict the container unit. After this step, the container unit may be rescheduled. Specifically, create a replacement copy of the container unit; schedule the replacement copy, and bind the replacement copy to the node so that the replacement copy starts running on the node.

[0056] According to an embodiment of the present invention, after determining that the container unit has not run successfully, the current state of the container included in the container unit is detected, and the reason why the container unit has not run successfully can be determined. In the case where it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide an operating environment, an instruction to evict the container unit is generated. The present invention can detect container units that cannot run successfully due to external environmental problems (the physical machine cannot provide an operating environment), thereby optimizing the container eviction strategy and improving the operating efficiency and accuracy of container eviction.

[0057] Figure 3 is a schematic diagram of a method for container eviction based on Kubernetes according to an embodiment of the present invention. Figure 4 It is a schematic diagram of the interaction architecture between Descheduler and Kubernetes according to an embodiment of the present invention.

[0058] like Figure 3 and Figure 4 As shown, the method for container expulsion based on Kubernetes in an embodiment of the present invention includes:

[0059] Step S301: pod-1 is started on node-1, but fails to run successfully. Kubelet reports its unsuccessful running status to apiserver. Kubelet is used to manage and monitor pods on nodes. Node is a node in the cluster, corresponding to a physical machine.

[0060] Step S302: Confirm that the running status of pod-1 is "has been scheduled but has not run successfully". The descheduler periodically obtains the pod running status list from the apiserver and checks the running status of the pod. When it is found that pod-1 is in the state of "has been scheduled but has not run successfully", it means that pod-1 has not run successfully. The apiserver provides API access to other components of kubernetes, and it directly reads and writes etcd. etcd is a distributed kv database (key-value database) that provides data persistence services for kubernetes.

[0061] Step S303: Detect the status of pod-1 and the current status of the containers included in pod-1.

[0062] The containers in a pod include: sandbox container, init container, and regular container. And the running process of the containers in a pod mainly includes the following steps:

[0063] (1) The sandbox container runs;

[0064] (2) The init container pulls the image;

[0065] (3) init container creation;

[0066] (4) init container starts;

[0067] (5) init container runs;

[0068] (6) The init container exits successfully;

[0069] (7) Pull the image from a regular container;

[0070] (8) Regular container creation;

[0071] (9) Regular container starts;

[0072] (10) Regular container runs.

[0073] When the descheduler determines whether a pod should be evicted, it needs to check the status field of the pod and the status field of the container it includes. The status field of the pod includes the following three (the field value is true or false):

[0074] (1)PodScheduled: If the pod is successfully scheduled, it is set to true; otherwise, it is set to false.

[0075] (2) Initialized: When the init container runs successfully and exits, the regular container is started again. If the init container exits successfully, initialized is set to true.

[0076] (3) Ready: If the regular container runs successfully, it is set to true; if it fails, it is set to false.

[0077] The status fields of the containers included in the Pod include:

[0078] (1) Waiting: The state before the container runs, including pulling images, creating, and starting.

[0079] (2) Running: The container is running.

[0080] (3) Terminated: The container exited successfully.

[0081] For the status of the container in the pod, descheduler only cares about the Waiting status, because this status indicates that the container is not running. Waiting can be divided into the following reasons:

[0082] (1)PodInitializing: For an init container, this reason indicates that the sandbox is being created. For a regular container, this reason indicates that the init container did not exit successfully.

[0083] (2) ImagePullBackOff: indicates that image pulling failed.

[0084] (3)ContainerCreating: Indicates that the container is being created.

[0085] (4) RunContainerError: indicates that the container failed when executing the startup command.

[0086] (5)CrashLoopBackOff: indicates that the container started successfully but failed to run.

[0087] The above operation process and changes in pod status and container status are shown in the following table:

[0088]

[0089] The pod is in the 1st, 3rd, and 8th stages in the above table for a long time. Since these three stages are directly dependent on the software or hardware environment on the physical machine, if these three stages fail, it must be a problem with the physical machine environment. Therefore, the above 1st, 3rd, and 8th stages indicate that the reason why the container cannot run is due to external environment problems. The field information of these three stages is:

[0090] (1) Sandbox cannot run: PodScheduled = true, Initialized = false, and the Waiting of the init container is PodInitializing;

[0091] (2) The init container is being created: PodScheduled = true, Initialized = false, and the Waiting of the init container is ContainerCreating;

[0092] (3) The regular container is being created: PodScheduled = true, Initialized = true, and the Waiting of the regular container is ContainerCreating.

[0093] Step S304: According to the detected status, it is confirmed that the reason why pod-1 failed to run successfully is that the physical machine on which it runs cannot provide the running environment, and an instruction to evict the container unit is generated. Therefore, descheduler only needs to determine the value of the status field in the above three situations: when the pod is in one of the three states (sandbox cannot run, init container is being created, regular container), and the duration exceeds a certain threshold, it can be considered that the reason why the pod cannot run is caused by external environment problems.

[0094] Step S305: Send an evict request (eviction instruction) to the apiserver. Evict: evict, that is, delete the pod from the node.

[0095] Step S306: The kubelet on node-1 receives the evict request, deletes pod-1 from node-1, and synchronizes the deleted status to the apiserver.

[0096] Step S307: When the controller-manager monitors the apiserver, it finds that pod-1 is deleted, so it creates a replacement copy of pod-1, called pod-2, and synchronizes pod-2 to the apiserver. The controller-manager is used to maintain the number of pod copies to match the number expected by the user.

[0097] Step S308: When the scheduler listens to the apiserver, it finds that pod-2 is created but not scheduled, so it executes the scheduling algorithm to select a suitable node (the node may or may not be node-1) to bind to pod-2. The scheduler is used to schedule pods so that the pods are bound to suitable nodes. In this embodiment of the present invention, since node-1 cannot provide an operating environment, in this process, binding with node-1 can be avoided, and another node node-2 can be selected to bind to pod-2. If pod-2 is bound to node-2, the kubelet on node-2 listens to this state change from the apiserver and creates pod-2 on node-2.

[0098] In an embodiment of the present invention, the descheduler periodically obtains information about all pods from the apiserver, and filters out pods that have been scheduled to the node but are not running normally. After determining that the pod should be evicted, it expels it, thereby triggering the scheduler to reschedule the new pod. The newly created pod will be scheduled on other nodes with a certain probability, so that the pod will not be repeatedly restarted on the same node. In addition, after the embodiment of the present invention determines that the pod has not run successfully, the current status of the container included in the pod is detected, and the reason why the pod has not run successfully can be determined. When it is determined that the reason why the pod has not run successfully is that the physical machine on which it runs cannot provide an operating environment, an instruction to evict the pod is generated. The present invention can detect pods that cannot run successfully due to external environmental problems (the physical machine cannot provide an operating environment), thereby optimizing the descheduler's eviction strategy and improving the accuracy of container eviction.

[0099] Figure 5 is a schematic diagram of main modules of an apparatus for implementing container expulsion according to an embodiment of the present invention, such as Figure 5 As shown, the device 300 for implementing container expulsion according to the embodiment of the present invention includes a module 501 for determining that the operation has not been successful, a current state detection module 502 and an instruction module 503 .

[0100] The module 501 for determining that the operation has not been successful is used to determine, based on the operation status information of the container unit, that the container unit has not been successfully operated.

[0101] The current state detection module 502 is used to detect the current state of the container included in the container unit, and determine the reason why the container unit did not run successfully according to the current state. The current state detection module is also used to obtain the state field of the container included in the container unit; and determine the current state of the container included in the container unit according to the state field.

[0102] The current state detection module is also used to determine whether the current state of the container included in the container unit belongs to a predefined set of states to be evicted; if the duration of the current state exceeds a preset threshold, it is determined that the reason why the container unit failed to run successfully is that the physical machine on which it runs cannot provide a running environment. The set of states to be evicted includes: the sandbox container cannot run, the initialization container is being created, and the ordinary container is being created.

[0103] The field information that the sandbox container cannot run is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is PodInitializing;

[0104] The field information of the initialization container being created is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is ContainerCreating;

[0105] The field information of the common container being created is: PodScheduled = true, Initialized = true, and the Waiting of the common container is ContainerCreating.

[0106] The instruction module 503 is used to generate an instruction to evict the container unit when it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment.

[0107] The device for implementing container eviction in an embodiment of the present invention may also include a substitute copy creation module, which is used to create a substitute copy of the container unit after the instruction module generates an instruction to evict the container unit; and schedule the substitute copy and bind the substitute copy to the node so that the substitute copy starts running on the node.

[0108] According to an embodiment of the present invention, after determining that the container unit has not run successfully, the current state of the container included in the container unit is detected, and the reason why the container unit has not run successfully can be determined. In the case where it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide the operating environment, an instruction to expel the container unit is generated. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, since it cannot run successfully due to external environmental problems, no matter whether the application itself has problems, it will not run successfully no matter how many times it is restarted. The present invention can detect the container unit that cannot run successfully due to external environmental problems (the physical machine cannot provide the operating environment), and will not perform many invalid restarts on the container, thereby optimizing the container's expulsion strategy and improving the operating efficiency. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, it is possible to run successfully after restarting a few more times if there is no problem with the application itself, which solves the problem in the prior art that all container units are expelled after a fixed time of restart (which may include container units that have not run successfully because there is no problem with the application itself and the physical machine on which it runs cannot provide the operating environment) resulting in reduced expulsion accuracy.

[0109] Figure 6 An exemplary system architecture 600 is shown in which a method for implementing container eviction or an apparatus for implementing container eviction according to an embodiment of the present invention can be applied.

[0110] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0111] Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0112] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0113] Server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results to the terminal device.

[0114] It should be noted that the method for implementing container expulsion provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for implementing container expulsion is generally disposed in the server 605 .

[0115] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0116] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0117] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0118] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0119] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0120] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0121] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0122] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, may be described as: a processor includes a module for obtaining and determining that the operation has not been successful, a current state detection module, and an instruction module. The names of these modules do not constitute a limitation on the modules themselves in some cases. For example, the module for determining that the operation has not been successful may also be described as "a module for determining that the container unit has not been successfully operated according to the operation state information of the container unit".

[0123] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: determining that the container unit has not run successfully according to the running status information of the container unit; detecting the current state of the container included in the container unit, and determining the reason why the container unit has not run successfully according to the current state; and generating an instruction to evict the container unit when it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide a running environment.

[0124] According to an embodiment of the present invention, after determining that the container unit has not run successfully, the current state of the container included in the container unit is detected, and the reason why the container unit has not run successfully can be determined. In the case where it is determined that the reason why the container unit has not run successfully is that the physical machine on which it runs cannot provide the operating environment, an instruction to expel the container unit is generated. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, since it cannot run successfully due to external environmental problems, no matter whether the application itself has problems, it will not run successfully no matter how many times it is restarted. The present invention can detect the container unit that cannot run successfully due to external environmental problems (the physical machine cannot provide the operating environment), and will not perform many invalid restarts on the container, thereby optimizing the container's expulsion strategy and improving the operating efficiency. For the container unit that has not run successfully because the physical machine on which it runs cannot provide the operating environment, it is possible to run successfully after restarting a few more times if there is no problem with the application itself, which solves the problem in the prior art that all container units are expelled after a fixed time of restart (which may include container units that have not run successfully because there is no problem with the application itself and the physical machine on which it runs cannot provide the operating environment) resulting in reduced expulsion accuracy.

[0125] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for implementing container expulsion, characterized in that: include: Determining, according to the operation status information of the container unit, that the container unit has not been successfully operated; Detecting the current state of the container included in the container unit, determining that the current state of the container included in the container unit belongs to a predefined set of states to be evicted, and if the duration of the current state exceeds a preset threshold, determining that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide an operating environment; When it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment, an instruction to expel the container unit is generated.

2. The method according to claim 1, characterized in that The step of detecting the current state of the container included in the container unit comprises: Obtaining a status field of a container included in the container unit; The current state of the container included in the container unit is determined according to the state field.

3. The method according to claim 1, characterized in that The set of states to be evicted includes: the sandbox container cannot run, the initialization container is being created, and the ordinary container is being created; The field information that the sandbox container cannot run is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is PodInitializing; The field information of the initialization container being created is: PodScheduled = true, Initialized = false, and the Waiting of the initialization container is ContainerCreating; The field information of the common container being created is: PodScheduled = true, Initialized = true, and the Waiting of the common container is ContainerCreating.

4. The method according to claim 1, characterized in that After generating the instruction to evict the container unit, the method further includes: creating a replacement copy of the container unit; The replacement copy is scheduled, and the replacement copy is bound to a node, so that the replacement copy starts running on the node.

5. A device for realizing container expulsion, characterized in that: include: A module for determining that the operation is not successful is used to determine that the container unit is not successfully operated according to the operation status information of the container unit; a current state detection module, configured to detect the current state of the container included in the container unit, determine that the current state of the container included in the container unit belongs to a predefined set of states to be evicted, and, if the duration of the current state exceeds a preset threshold, determine that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment; The instruction module is used to generate an instruction to expel the container unit when it is determined that the reason why the container unit fails to run successfully is that the physical machine on which it runs cannot provide a running environment.

6. The device according to claim 5, characterized in that The current state detection module is further used to obtain a state field of the container included in the container unit; and determine the current state of the container included in the container unit according to the state field.

7. The device according to claim 5, characterized in that It also includes a substitute copy creation module, which is used to create a substitute copy of the container unit; and schedule the substitute copy and bind the substitute copy to a node so that the substitute copy starts running on the node.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Service-configurable comprehensive resource monitoring managing system and method

    CN102420697A

  • Development, operation and maintenance method and device and cloud computing PaaS platform

    CN107220100A