Container startup method, device, storage medium and computer equipment
By first starting the proxy container in kubernetes and then starting the business container after it is started, the problem that the proxy container is not successfully started during the container node startup time has been solved, resulting in the business container being unable to access externally, and the stable startup of the container node is achieved.
Patent Information
- Application Number
- CN202011113862.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-18
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2040-10-18
AI Technical Summary
In kubernetes, when the container node starts, the proxy container and the business container are started at the same time, resulting in the business container being unable to access externally if the proxy container is not successfully started, resulting in the startup failure.
When the container node is started, the proxy container is first started and the service container is controlled to send service requests to the outside. Based on the feedback information of the service request, determine whether the proxy container is successfully started. If successful, start the service container. If the proxy container starts fail, wait for the preset time and try again until it is confirmed that the proxy container starts successfully.
Ensure that the service container is started after the proxy container is successfully started, so as to ensure that the service container can access the externally normally and ensure that the container node is started successfully.
Smart Images

Figure HDA0002729570240000011 
Figure HDA0002729570240000021 
Figure HDA0002729570240000022
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a container startup method, device, storage medium and computer equipment. Background Art
[0002] A container node Pod is the smallest unit that can be deployed and managed by Kubernetes. A container node can usually accommodate multiple containers, such as business containers and proxy containers.
[0003] Currently, when a container node in kubernets is started, multiple containers in the container node are started at the same time, that is, the proxy container and the business container are started at the same time. However, since the business container will be registered through external access when it is started to complete the startup of the business container, and the proxy container is required to achieve external access when it is accessed externally, if the proxy container is not started successfully, the business container will not be able to access the outside world, resulting in the failure of the business container startup. Summary of the invention
[0004] In view of this, the present invention provides a container startup method, device, storage medium and computer equipment, the main purpose of which is to ensure that when the container node is started, the proxy container is started successfully before starting the business container, so that the business container can be accessed externally and ensure that the business container is started successfully.
[0005] According to one aspect of the present invention, a container startup method is provided, comprising:
[0006] In response to receiving a start instruction of a container node, start a proxy container in the container node, and control a business container in the container node to send a service request externally;
[0007] receiving feedback information corresponding to the service request, and determining, according to the feedback information, whether the proxy container is successfully started before the business container is started;
[0008] If the proxy container is started successfully, the service container is started.
[0009] Optionally, after determining, according to the feedback information, whether the proxy container is successfully started before the business container is started, the method further includes:
[0010] If the proxy container fails to start, after waiting for a first preset time, the business container is controlled to re-send a service request to the outside and receive feedback information corresponding to the service request, until it is determined that the proxy container is started successfully according to the feedback information corresponding to the service request, and the business container is started.
[0011] Optionally, the step of determining, according to feedback information corresponding to the service request, that the proxy container is successfully started and starting the business container includes:
[0012] If the number of retries for controlling the business container to resend the service request to the outside exceeds the preset number of retries, it is determined that the proxy container fails to start, and an alarm message is sent to the business personnel terminal;
[0013] If the number of retries of controlling the business container to resend the service request externally does not exceed the preset number of retries, and it is determined according to the feedback information corresponding to the service request that the proxy container is started successfully, the business container is started.
[0014] Optionally, the controlling the business container in the container node to send a service request externally includes:
[0015] The business container is controlled to send a service request externally, and the service request is intercepted by using a preset flow control tool, and the service request is forwarded to the proxy container so that the proxy container forwards the service request.
[0016] Optionally, judging, according to the feedback information, whether the proxy container is successfully started before the business container is started includes:
[0017] If the feedback information indicates that the service request is successful, it is determined that the proxy container is successfully started before the business container is started;
[0018] If the feedback information indicates that the service request fails, it is determined that the proxy container fails to start before the business container starts.
[0019] Optionally, the method further comprises:
[0020] In response to receiving a destruction instruction of a container node, destroying a service container in the container node, and using a process detection function pre-set by a proxy container in the container node to detect whether there is still a service process in the service container;
[0021] If the service process does not exist in the service container, the proxy container is destroyed.
[0022] Optionally, after using the process detection function pre-set by the proxy container in the container node to detect whether there is still a service process in the service container, the method further includes:
[0023] If there is a business process in the business container, after waiting for a second preset time, the process detection function preset by the proxy container is used to re-detect whether there is still a business process in the business container, until there is no business process in the business container, and then the proxy container is destroyed.
[0024] Optionally, the detecting whether there is still a service process in the service container by using a process detection function pre-set in the proxy container in the container node includes:
[0025] Using the process detection function pre-set by the proxy container to detect whether there is a service registration and destruction process in the business container;
[0026] If the service registration destruction process does not exist, using the process detection function pre-set by the proxy container to detect whether there is a message queue destruction process in the business container;
[0027] If the business process does not exist in the business container, destroying the proxy container includes:
[0028] If the message queue destruction process does not exist in the business container, the proxy container is destroyed.
[0029] According to a second aspect of the present invention, there is provided a container starting device, comprising:
[0030] A first starting unit, configured to start a proxy container in the container node in response to receiving a starting instruction of the container node, and control the business container in the container node to send a service request externally;
[0031] A judging unit, configured to receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information;
[0032] The second starting unit is configured to start the service container if the proxy container is started successfully.
[0033] Optionally, the second starting unit is further used to control the business container to re-send a service request to the outside after waiting for a first preset time period if the proxy container fails to start, and receive feedback information corresponding to the service request, until it is determined that the proxy container is started successfully according to the feedback information corresponding to the service request, and the business container is started.
[0034] Optionally, the second starting unit includes: a sending module and a starting module,
[0035] The sending module may be used to determine that the proxy container fails to start if the number of retries for controlling the business container to resend the service request to the outside exceeds a preset number of retries, and send an alarm message to the business personnel terminal;
[0036] The startup module may be configured to start the business container if the number of retries for controlling the business container to resend the service request does not exceed a preset number of retries and, based on feedback information corresponding to the service request, it is determined that the proxy container is successfully started.
[0037] Optionally, the first starting unit is specifically configured to control the business container to send a service request externally, intercept the service request using a preset traffic control tool, and forward the service request to the proxy container so that the proxy container forwards the service request.
[0038] Optionally, the judging unit includes: a first determining module and a second determining module.
[0039] The first determination module is configured to determine that the proxy container is successfully started before the business container is started if the feedback information indicates that the service request is successful;
[0040] The second determining module is configured to determine that the proxy container fails to start before the business container starts if the feedback information indicates that the service request fails.
[0041] Optionally, the device further comprises: a first destruction unit and a second destruction unit,
[0042] The first destroying unit is configured to, in response to receiving a destroy instruction from a container node, destroy the service container in the container node, and detect whether there is still a service process in the service container by using a process detection function pre-set by a proxy container in the container node;
[0043] The second destroying unit is configured to destroy the proxy container if the service process does not exist in the service container.
[0044] Optionally, if there is a business process in the business container, the second destruction unit is further used to wait for a second preset time period, and then use the process detection function pre-set by the proxy container to re-detect whether there is still a business process in the business container, until there is no business process in the business container, and then destroy the proxy container.
[0045] Optionally, the first destruction unit includes: a first detection module and a second detection module.
[0046] The first detection module is used to detect whether there is a service registration and destruction process in the business container by using a process detection function preset by the proxy container;
[0047] The second detection module is used to detect whether there is a message queue destruction process in the business container by using the process detection function preset by the proxy container if the service registration destruction process does not exist;
[0048] The second destroying unit is specifically configured to destroy the proxy container if the message queue destroying process does not exist in the business container.
[0049] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:
[0050] In response to receiving a start instruction of a container node, start a proxy container in the container node, and control a business container in the container node to send a service request externally;
[0051] receiving feedback information corresponding to the service request, and determining, according to the feedback information, whether the proxy container is successfully started before the business container is started;
[0052] If the proxy container is started successfully, the service container is started.
[0053] According to a fourth aspect of the present invention, there is provided a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the following steps are implemented:
[0054] In response to receiving a start instruction of a container node, start a proxy container in the container node, and control a business container in the container node to send a service request externally;
[0055] receiving feedback information corresponding to the service request, and determining, according to the feedback information, whether the proxy container is successfully started before the business container is started;
[0056] If the proxy container is started successfully, the service container is started.
[0057] The present invention provides a container startup method, device, storage medium and computer equipment. Compared with the current method of starting a proxy container and a business container at the same time when a container node is started, the present invention can start the proxy container in the container node in response to receiving a startup instruction of the container node, and control the business container in the container node to send a service request to the outside; at the same time, receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information; if the proxy container is successfully started, start the business container, so that when the proxy container is started, the business container can be controlled to send a service request to the outside, and judge whether the proxy container is successfully started according to the feedback information corresponding to the service request. If the proxy container is successfully started, start the business container, thereby ensuring that the business container is started after the proxy container is successfully started, so that the business container can use the proxy container to access the outside, ensuring that the business container is successfully started.
[0058] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present invention and, together with the description, serve to explain the principles of the present invention.
[0060] The present invention may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0061] Figure 1 A flow chart of a container startup method provided by an embodiment of the present invention is shown;
[0062] Figure 2 A flow chart of a container destruction method provided by an embodiment of the present invention is shown;
[0063] Figure 3 A schematic structural diagram of a container starting device provided by an embodiment of the present invention is shown;
[0064] Figure 4 A schematic structural diagram of another container starting device provided by an embodiment of the present invention is shown;
[0065] Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0066] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0067] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0068] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0069] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0070] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0071] Embodiments of the present invention may be applied to computer systems / servers that may operate with numerous other general or special computing system environments or configurations. Examples of well-known computing systems, environments, and / or configurations suitable for use with computer systems / servers include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, networked personal computers, minicomputer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the above systems, and the like.
[0072] Computer systems / servers may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. In general, program modules may include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers may be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules may be located on local or remote computing system storage media including storage devices.
[0073] The embodiment of the present invention provides an information recommendation method, such as Figure 1 As shown, the method includes:
[0074] 101. In response to receiving a start instruction from a container node, start a proxy container in the container node, and control a business container in the container node to send a service request externally.
[0075] Among them, the container node is a pod container node based on the sidercar mode under the Kubernetes framework. The pod container node usually includes multiple containers, such as a business container and a proxy container. In order to protect the business container, the business container is usually not directly accessed externally, but the proxy container is used as an intermediate layer to realize external access of the business container through the proxy container. In order to overcome the defect of simultaneously starting the business container and the proxy container in the pod container node in the prior art, the embodiment of the present invention can make the business container and the proxy container in the container node start in the desired order. Specifically, when starting the pod container node, the proxy container is directly started, and before starting the business container, the business container is controlled to access externally, and whether the proxy container is successfully started is judged according to the feedback information. If the proxy container is successfully started, the business container is started again, thereby ensuring that the business container is started after the proxy container is successfully started, so that the subsequent business container can use the proxy container to realize external access, and then successfully start the business container through external access. The embodiments of the present invention are mainly applicable to the sequential startup of the service container and the proxy container in the container node. The execution subject of the present invention is a device or equipment that can control the sequential startup of the service container and the proxy container, which can be specifically set on the server or client side.
[0076] Specifically, after the software is released or the code is updated, the container node pod of the service will be restarted. When the startup instruction of the container node pod is received, in order to ensure that the proxy container is started as soon as possible, the startup command in the proxy container startup script is directly called to start the proxy container. For the business container, the startup command in the business container startup script is not directly executed, but the business container is controlled to access the outside world first. Specifically, the business container can be controlled to send service requests to the outside world by calling the kubernetes service. When the business container accesses the outside world, it will use the successfully started proxy container. If the business container accesses the outside world successfully, it means that the proxy container has been successfully started; if the business container does not access the outside world successfully, it means that the proxy container may fail to start. Therefore, based on the feedback result of the service request sent by the proxy container, it can be determined whether the proxy container is successfully started.
[0077] Further, for the specific process of the business container calling the kubernetes service to send a service request externally, the control of the business container in the container node to send a service request externally includes: controlling the business container to send a service request externally, intercepting the service request by using a preset flow control tool, and forwarding the service request to the proxy container so that the proxy container forwards the service request. Specifically, when receiving the startup instruction of the container node, the business container can be controlled to request an arbitrary service externally, for example, the business container is controlled to request a certain service curlhttp: / / micrometer-hostname-allocator.devops / hostname externally, and then the flow control tool iptable intercepts the service request, and forwards the service request to the proxy container corresponding to the business container according to the routing rules in iptable, and the proxy container requests the service externally. If the service request is successful, 200 will be fed back, indicating that the proxy container has been successfully started at this time, otherwise feedback information of the service request timeout will be fed back, that is, the service request fails, indicating that the proxy container is likely to fail to start at this time.
[0078] 102. Receive feedback information corresponding to the service request, and determine, according to the feedback information, whether the proxy container is successfully started before the business container is started.
[0079] For the embodiment of the present invention, after the business container sends a service request to the outside, if the feedback information corresponding to the service request is 200, it means that the business container has successfully accessed the outside; if the feedback information corresponding to the service request is that the service request has timed out, it means that the business container has failed to access the outside. In addition, in order to verify whether the proxy container has been successfully started before the business container is started according to the feedback information corresponding to the service request, step 102 specifically includes: if the feedback information is that the service request is successful, it is determined that the proxy container is successfully started before the business container is started; if the feedback information is that the service request fails, it is determined that the proxy container fails to start before the business container is started. Further, if it is determined that the proxy container is successfully started, the business container is started; if it is determined that the proxy container fails to start, it means that the business container cannot achieve external access, and thus cannot be started, and at this time it is necessary to send an alarm message to the terminal of the relevant responsible person.
[0080] Furthermore, if the service request of the business container fails, it may be because the proxy container fails to start, or it may be because of the service network problem. Therefore, you can try to start the business container. When the business container starts, it will also call the kubernetes service and use the proxy container to realize the external service registration and message queue registration. If the business container starts successfully, it means that the previous service request failed due to the service network problem, and the proxy container has been started successfully; if the business container cannot be started successfully, it means that the proxy container fails to start. At this time, an alarm message is sent to the terminal of the relevant responsible person, and the relevant responsible person handles it. Therefore, when the business container fails to make an external request, you can further determine whether the proxy container is started successfully by trying to start the business container.
[0081] 103. If the proxy container is started successfully, start the business container.
[0082] For the embodiment of the present invention, if the proxy container is successfully started, the startup command in the business container startup script can be directly executed to start the business container; if the proxy container fails to start, after waiting for the first preset time, the business container is controlled to re-send the service request to the outside, and the feedback information corresponding to the service request is received, until the proxy container is determined to be successfully started according to the feedback information corresponding to the service request, and the business container is started. Further, if the number of retries of controlling the business container to re-send the service request to the outside exceeds the preset number of retries, it is determined that the proxy container has failed to start, and an alarm message is sent to the business personnel terminal; if the number of retries of controlling the business container to re-send the service request to the outside does not exceed the preset number of retries, and according to the feedback information corresponding to the service request, it is determined that the proxy container is successfully started, then the business container is started. Among them, the first preset time and the preset number of retries can be set according to business needs, for example, the first preset time is set to 6s, and the preset number of retries is set to 12 times.
[0083] Specifically, when it is determined according to the feedback information corresponding to the service request that the proxy container fails to start, it may be because the proxy container has not yet completed the startup. Therefore, it can sleep for a first preset period of time, that is, after waiting for the first preset period of time, re-control the business container to send a service request to the outside, and judge whether the proxy container has completed the startup after sleeping for the first preset period of time according to the feedback information corresponding to this service request, that is, judge whether the proxy container has started successfully; if it is determined according to the feedback information corresponding to this service request that the service request is successful, it means that the proxy container has completed the startup and the startup is successful, and the proxy container can be started at this time; if it is determined according to the feedback information corresponding to this service request that the service request fails, it means that the proxy container has not yet completed the startup, or the startup fails. If the service container fails, it can continue to sleep for the first preset time, and then re-control the business container to send service requests to the outside, until it is determined that the proxy container is successfully started according to the feedback information corresponding to the service request. At the same time, in order to prevent indefinite waiting for the proxy container to complete the startup, the number of retries can be set, for example, 12 times. As long as the number of retries of the business container sending service requests to the outside is within 12 times, and it can be determined that the proxy container is successfully started according to the feedback information corresponding to the service request, the startup command in the business container startup script is called to start the business container. If the number of retries exceeds 12 times, and it is not possible to determine that the proxy container is successfully started according to the feedback information corresponding to the service request, an alarm message can be sent to the relevant personnel terminal at this time, and the relevant responsible personnel will handle it. In this way, by setting the preset time and the preset number of retries, it is possible to avoid indefinite waiting for the proxy container to start.
[0084] Furthermore, if the number of retries when the business container sends a service request to the outside exceeds the preset number of retries, and the feedback information corresponding to the service request is still a service request timeout, it is possible that the proxy container failed to start, or the proxy container started successfully, but there was a problem with the service network, which led to access failure. In order to further verify whether the proxy container was successfully started, you can try to start the business container after the number of retries exceeds the preset number. The business container implements external service registration and message queue registration through the proxy container, and then completes the startup. If the business container can be started successfully at this time, it means that the proxy container has been started successfully; if the business container cannot be started successfully, it means that the proxy container has failed to start, and an alarm message is sent to the terminal of the relevant responsible personnel to notify them that the online release has failed. Therefore, the above method can usually further determine whether the proxy container is started successfully and eliminate the impact of network failures.
[0085] A container startup method provided by an embodiment of the present invention, compared with the current method of starting a proxy container and a business container simultaneously when a container node is started, the present invention can start the proxy container in the container node in response to receiving a startup instruction of the container node, and control the business container in the container node to send a service request externally; at the same time, receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information; if the proxy container is successfully started, start the business container, so that when the proxy container is started, the business container can be controlled to send a service request externally, and according to the feedback information corresponding to the service request, it is judged whether the proxy container is successfully started; if the proxy container is successfully started, the business container is started, thereby ensuring that the business container is started after the proxy container is successfully started, so that the business container can use the proxy container to access externally, ensuring that the business container is successfully started.
[0086] Furthermore, an embodiment of the present invention also provides a container destruction method, such as Figure 2 As shown, the method includes:
[0087] 201. In response to receiving a destroy instruction from a container node, destroy a service container in the container node, and use a process detection function pre-set in a proxy container in the container node to detect whether there is still a service process in the service container.
[0088] In the prior art, when a container node is destroyed, the business container and the proxy container in the container node are also destroyed at the same time. When the business container is destroyed, the proxy container is used to request external services to destroy relevant information of the business container, such as relevant information of the destruction service registration center and relevant information in the destruction message list. Therefore, if the business container and the proxy container are destroyed at the same time, the proxy container is likely to have been destroyed before the destruction of the business container is completed. At this time, the relevant information of the business container is not completely destroyed, and residual information of the business container remains. In order to overcome the above-mentioned defects of the prior art, an embodiment of the present invention enables the business container and the proxy container in the container node to be destroyed in the desired order. Specifically, when destroying the pod container node, the business container is directly destroyed, and the process detection mechanism in the proxy container is used to detect whether there is still a business process in the business container. If there is no business process in the business container, the proxy container is destroyed. This ensures that the proxy container is destroyed after the business container is successfully destroyed, ensuring that the relevant information of the business container is destroyed cleanly without residual information.
[0089] Specifically, when the version code is updated, the original version of the code needs to be shielded. The shielding process is the destruction process. When the destruction instruction of the container node of the corresponding service is received, in order to ensure that the business container is destroyed as soon as possible, the destruction instruction in the business container destruction script is directly called to destroy the business container. When the business container is destroyed, the relevant information of the business container is destroyed by requesting services externally. Specifically, the curl instruction is used to request services externally, and the relevant information in the registration center and the message queue is destroyed. When requesting services externally to cancel the relevant information of the business container, the service request is sent externally through the proxy container. For the proxy container, before executing the destruction instruction in the proxy container destruction script, it is necessary to use the process detection mechanism pre-set by the proxy container to detect whether there is still a business process in the business container. Specifically, the process detection mechanism of the proxy container can be pre-configured, that is, the life cycle hook prestop is set in the proxy container. Before the proxy container executes the destruction command, the command exce command (netstat-plunt / grep tcp / grep-v envoy / wc- / ) detects the number of business processes in the business container. If the number of business processes is 0, it is determined that the business process in the business container has ended. At this time, the proxy container can be destroyed, that is, the destruction instruction in the proxy container destruction script is executed; if the number of business processes is not 0, it is determined that the business process in the business container has not ended. At this time, the proxy container cannot be destroyed. It is necessary to wait until the business process in the business container is completely ended before destroying the proxy container. In this way, the proxy container can be destroyed after the business container is destroyed, ensuring that the relevant information of the business container is destroyed cleanly without residual information.
[0090] Furthermore, the process detection function pre-set by the proxy container in the container node is used to detect whether there is still a business process in the business container, including: using the process detection function pre-set by the proxy container to detect whether there is a service registration and destruction process in the business container; if the service registration and destruction process does not exist, then using the process detection function pre-set by the proxy container to detect whether there is a message queue destruction process in the business container.
[0091] Specifically, when the container node is started, the business container will register relevant information in the service registration center and in the message queue. Therefore, when the container node is deregistered, the business container also needs to deregister the information related to the business container through external access, thereby finally completing the destruction of the business container. Therefore, the business container will use the proxy container when requesting external service deregistration. Therefore, the proxy container must be destroyed after the business container is successfully destroyed. Therefore, before the proxy container executes the destruction command, it will continue to check whether there is still a service registration and destruction process in the business container; if there is no service registration and destruction process, it will continue to check whether there is still a message queue deregistration process in the business container until the above deregistration process is completely completed, and it is determined that the number of processes in the business container is 0, and the destruction command in the proxy container destruction script is executed.
[0092] 202. If the service process does not exist in the service container, destroy the proxy container.
[0093] For the embodiment of the present invention, if there is no business process in the business container, that is, the number of business processes is 0, the proxy container is destroyed; if there is a business process in the business container, after waiting for a second preset time, the process detection function pre-set by the proxy container is used to re-detect whether there is still a business process in the business container, until there is no business process in the business container, and then the proxy container is destroyed. The second preset time can be set according to business needs, such as setting the second preset time to 5s, that is, re-detecting whether there is still a business process in the business container every 5s.
[0094] Specifically, if it is detected that there are still business processes in the business container, it means that the business container has not yet been destroyed. You can wait for the second preset time and re-detect whether there are still business processes in the business container. If there are still business processes in the business container, continue to wait for the second preset time and repeat the above process until the business processes such as registration center service deregistration and message queue deregistration in the business container are completely completed. Then, execute the destruction command in the proxy container destruction script to destroy the proxy container. This ensures that the proxy container and the business container are destroyed in the expected destruction order, thereby ensuring that the proxy container is destroyed after the business container is successfully destroyed, ensuring that the relevant information with the business container can be destroyed cleanly without residual information.
[0095] A container destruction method provided by an embodiment of the present invention, compared with the current method of simultaneously destroying a proxy container and a business container when a container node is destroyed, the present invention can, in response to receiving a destruction instruction of a container node, destroy the business container in the container node, and use the process detection function pre-set in the proxy container in the container node to detect whether there is still a business process in the business container; if the business process does not exist in the business container, the proxy container is destroyed, thereby being able to detect whether there is a business process in the business container before the proxy container is destroyed, and destroying the proxy container when it is determined that there is no business process in the business container, thereby ensuring that the proxy container is destroyed after the business container is successfully destroyed, ensuring that the relevant information of the business container is destroyed cleanly without residual information.
[0096] Furthermore, as a response to the above Figure 1 To implement the method shown in the figure, an embodiment of the present invention provides a container starting device, such as Figure 3 As shown, the device includes: a first starting unit 31, a judging unit 32 and a second starting unit 33.
[0097] The first starting unit 31 can be used to start the proxy container in the container node in response to receiving the start instruction of the container node, and control the business container in the container node to send a service request to the outside. The first starting unit 31 is a main functional module in the device that starts the proxy container in the container node in response to receiving the start instruction of the container node, and controls the business container in the container node to send a service request to the outside.
[0098] The judgment unit 32 may be used to receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information. The judgment unit 32 is a main functional module in the device that receives feedback information corresponding to the service request, and judges whether the proxy container is successfully started before the business container is started according to the feedback information, and is also a core module.
[0099] The second starting unit 33 can be used to start the service container if the proxy container is successfully started. The second starting unit 33 is a main functional module and also a core module in the device for starting the service container if the proxy container is successfully started.
[0100] Furthermore, the second starting unit 33 can also be used to control the business container to re-send the service request to the outside after waiting for a first preset period of time if the proxy container fails to start, and receive feedback information corresponding to the service request, until it is determined that the proxy container is started successfully based on the feedback information corresponding to the service request, and the business container is started.
[0101] Furthermore, in order to control the service container to resend the service request to the outside, the second starting unit 33, such as Figure 4 As shown, it includes: a sending module 331 and a starting module 332.
[0102] The sending module 331 may be used to determine that the proxy container fails to start and send an alarm message to the business personnel terminal if the number of retries for controlling the business container to resend the service request to the outside exceeds a preset number of retries.
[0103] The startup module 332 may be configured to start the business container if the number of retries for controlling the business container to resend the service request does not exceed a preset number of retries and if it is determined based on feedback information corresponding to the service request that the proxy container is successfully started, then the business container is started.
[0104] Furthermore, in order to control the business container to send service requests externally, the first startup unit 31 can be specifically used to control the business container to send service requests externally, and use a preset traffic control tool to intercept the service requests, and forward the service requests to the proxy container so that the proxy container forwards the service requests.
[0105] Furthermore, in order to determine whether the proxy container is started successfully, the determination unit 32 includes: a first determination module 321 and a second determination module 322 .
[0106] The first determination module 321 may be configured to determine that the proxy container is successfully started before the business container is started if the feedback information indicates that the service request is successful.
[0107] The second determining module 322 may be configured to determine that the proxy container fails to start before the business container starts if the feedback information indicates that the service request fails.
[0108] Furthermore, in order to destroy the proxy container and the service container in a desired order, the device further includes: a first destroying unit 34 and a second destroying unit 35,
[0109] The first destruction unit 34 can be used to destroy the business container in the container node in response to receiving a destruction instruction of the container node, and use the process detection function pre-set by the proxy container in the container node to detect whether there is still a business process in the business container.
[0110] The second destroying unit 35 may be configured to destroy the proxy container if the service process does not exist in the service container.
[0111] Furthermore, in order to re-detect whether there is still a business process in the business container, the second destruction unit 35 can also be used to, if there is a business process in the business container, wait for a second preset time period, and then use the process detection function pre-set by the proxy container to re-detect whether there is still a business process in the business container, until there is no business process in the business container, and then destroy the proxy container.
[0112] Furthermore, the first destruction unit 34 includes: a first detection module 341 and a second detection module 342 .
[0113] The first detection module 341 may be configured to detect whether there is a service registration and destruction process in the business container by using a process detection function preset by the proxy container.
[0114] The second detection module 342 may be configured to detect whether there is a message queue destruction process in the business container by using a process detection function preset by the proxy container if the service registration destruction process does not exist.
[0115] The second destroying unit 35 may be specifically configured to destroy the proxy container if the message queue destroying process does not exist in the business container.
[0116] Based on the above Figure 1 and Figure 2 The method shown in the embodiment of the present invention accordingly provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the following is implemented Figure 1 to Figure 2 The method shown.
[0117] Based on the above Figure 1 The method shown and Figure 3 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43 and when the processor 41 executes the program, the following is realized: Figure 1 to Figure 2 The method shown.
[0118] Through the technical solution of the present invention, the present invention can start the proxy container in the container node in response to receiving the startup instruction of the container node, and control the business container in the container node to send a service request to the outside; at the same time, receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information; if the proxy container is successfully started, start the business container, so that when starting the proxy container, the business container can be controlled to send a service request to the outside, and according to the feedback information corresponding to the service request, it is judged whether the proxy container is successfully started; if the proxy container is successfully started, the business container is started, thereby ensuring that the business container is started after the proxy container is successfully started, so that the business container can use the proxy container to access the outside, ensuring that the business container is successfully started.
[0119] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0120] The method and system of the present invention may be implemented in many ways. For example, the method and system of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware, firmware. The above order of steps for the method is only for illustration, and the steps of the method of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present invention may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
[0121] The description of the present invention is given for the purpose of illustration and description, and is not intended to be exhaustive or to limit the invention to the disclosed form. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present invention and to enable those of ordinary skill in the art to understand the present invention and thereby design various embodiments with various modifications suitable for particular uses.
Claims
1. A container starting device, characterized in that: include: A first starting unit, configured to start a proxy container in the container node in response to receiving a starting instruction of the container node, and control the business container in the container node to send a service request externally; A judging unit, configured to receive feedback information corresponding to the service request, and judge whether the proxy container is successfully started before the business container is started according to the feedback information; A second starting unit, configured to start the service container if the proxy container is started successfully; The second starting unit is further configured to, if the proxy container fails to start, control the business container to resend a service request to the outside after waiting for a first preset time period, and receive feedback information corresponding to the service request, until it is determined that the proxy container is started successfully according to the feedback information corresponding to the service request, and start the business container; The container starting device further comprises: a first destruction unit and a second destruction unit, The first destroying unit is configured to, in response to receiving a destroy instruction from a container node, destroy the service container in the container node, and detect whether there is still a service process in the service container by using a process detection function pre-set by a proxy container in the container node; The second destroying unit is configured to destroy the proxy container if the service process does not exist in the service container. The second destroying unit is further configured to, if there is a service process in the service container, wait for a second preset time period, and then use the process detection function preset by the proxy container to re-detect whether there is still a service process in the service container, until there is no service process in the service container, and then destroy the proxy container; The first destruction unit includes: a first detection module and a second detection module, The first detection module is used to detect whether there is a service registration and destruction process in the business container by using a process detection function preset by the proxy container; The second detection module is used to detect whether there is a message queue destruction process in the business container by using a process detection function preset by the proxy container if the service registration destruction process does not exist in the business container; The second destroying unit is specifically configured to destroy the proxy container if the message queue destroying process does not exist in the business container.
2. The device according to claim 1, characterized in that The second starting unit includes: a sending module and a starting module, The sending module is used to determine that the proxy container fails to start if the number of retries of controlling the business container to resend the service request to the outside exceeds a preset number of retries, and send an alarm message to the business personnel terminal; The startup module is used to start the business container if the number of retries for controlling the business container to resend the service request externally does not exceed a preset number of retries and it is determined based on feedback information corresponding to the service request that the proxy container is successfully started.
3. The device according to claim 1, characterized in that The first startup unit is specifically configured to control the business container to send a service request externally, intercept the service request using a preset flow control tool, and forward the service request to the proxy container so that the proxy container forwards the service request.
4. The device according to claim 1, characterized in that The judging unit includes: a first determining module and a second determining module. The first determination module is configured to determine that the proxy container is successfully started before the business container is started if the feedback information indicates that the service request is successful; The second determining module is configured to determine that the proxy container fails to start before the business container starts if the feedback information indicates that the service request fails.
5. A container startup method, characterized in that: include: In response to receiving a start instruction of a container node, start a proxy container in the container node, and control a business container in the container node to send a service request externally; receiving feedback information corresponding to the service request, and determining, according to the feedback information, whether the proxy container is successfully started before the business container is started; If the proxy container is started successfully, the business container is started. Wherein, after judging whether the proxy container is successfully started before the business container is started according to the feedback information, the method further includes: If the proxy container fails to start, after waiting for a first preset time, the business container is controlled to resend a service request to the outside, and feedback information corresponding to the service request is received, until it is determined that the proxy container is started successfully according to the feedback information corresponding to the service request, and the business container is started; The process of determining, according to feedback information corresponding to the service request, that the proxy container is successfully started and starting the business container includes: If the number of retries for controlling the business container to resend the service request to the outside exceeds the preset number of retries, it is determined that the proxy container fails to start, and an alarm message is sent to the business personnel terminal; If the number of retries of controlling the business container to resend the service request externally does not exceed the preset number of retries, and it is determined based on the feedback information corresponding to the service request that the proxy container is successfully started, then starting the business container; The controlling the business container in the container node to send a service request externally includes: Control the business container to send a service request externally, intercept the service request by using a preset flow control tool, and forward the service request to the proxy container so that the proxy container forwards the service request; The determining, according to the feedback information, whether the proxy container is successfully started before the business container is started includes: If the feedback information indicates that the service request is successful, it is determined that the proxy container is successfully started before the business container is started; If the feedback information indicates that the service request failed, determining that the proxy container failed to start before the business container started; The method further comprises: In response to receiving a destruction instruction of a container node, destroying a service container in the container node, and using a process detection function pre-set by a proxy container in the container node to detect whether there is still a service process in the service container; If the business process does not exist in the business container, destroying the proxy container; If there is a business process in the business container, after waiting for a second preset time, the process detection function preset by the proxy container is used to re-detect whether there is still a business process in the business container, until there is no business process in the business container, and then the proxy container is destroyed.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 5 are implemented.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 5 are implemented.
Citation Information
Patent Citations
Service orchestration and dependency relationship management method and system based on container cloud technology
CN110333932A