Disclosure of Invention
The embodiment of the specification provides a method, a device and a medium for upgrading an application program based on a container, and is used for solving the following technical problems in the prior art: the workload of manually upgrading the application program by operation and maintenance personnel is large, and if the upgrading fails, long rollback time is needed, so that the normal use of the application program is influenced, and the user experience is reduced.
The embodiment of the specification adopts the following technical scheme:
a method for upgrading an application program based on a container comprises the following steps:
receiving an application program upgrading request sent by an operation and maintenance terminal, wherein the application program upgrading request comprises current application program information and target application program information;
determining a plurality of corresponding pre-constructed test containers based on the current application information; the test application program running in the test container is matched with the current application program information;
constructing a first temporary container of each test container, and upgrading each first temporary container according to the target application program information;
exchanging the upgraded first temporary container with the corresponding test container to obtain an upgraded test container; wherein the upgraded test container is used as a target test container;
and under the condition that the application programs in the target test containers run normally, upgrading the application containers corresponding to the test containers.
Optionally, before constructing the first temporary container of the test containers, the method further comprises: each of the test receptacles is suspended for service.
Optionally, the method further comprises:
performing data backup on a database corresponding to the test container;
after upgrading the first temporary container according to the target application information, the method further comprises:
and upgrading the database corresponding to the first temporary container.
Optionally, in a case that the application program in the target test container cannot run normally, the method further includes:
constructing a second temporary container of the target test container;
determining the application version of the application program operated by the test container corresponding to the target test container according to a pre-stored upgrade log;
updating the second temporary container according to the application version of the application program operated by the test container corresponding to the target test container; and the application program running in the updated second temporary container is consistent with the application program running in the test container.
And exchanging the second temporary container with the target test container to obtain a test container corresponding to the target test container.
Optionally, the upgraded first temporary container is exchanged with a corresponding test container to obtain the upgraded test container, and the method specifically includes:
building a temporary storage area corresponding to each test container, and sending the application programs in the test containers to the temporary storage area for storage;
and assigning the application program operated in the upgraded first temporary container to the test container to obtain the upgraded test container.
Optionally, after obtaining the upgraded test container, the method further includes: closing and deleting the first temporary container.
Optionally, the method further comprises:
acquiring container information of the test container and the application container, and displaying the container information to operation and maintenance personnel;
wherein the container information at least includes any one of: application identification, application version information, state information.
Optionally, when the application program in each target test container runs normally, upgrading the application container corresponding to the test container is performed asynchronously.
A container-based application upgrade apparatus, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
receiving an application program upgrading request sent by an operation and maintenance terminal, wherein the application program upgrading request comprises current application program information and target application program information;
determining a plurality of corresponding pre-constructed test containers based on the current application information; the test application program running in the test container is matched with the current application program information;
constructing a first temporary container of each test container, and upgrading each first temporary container according to the target application program information;
exchanging the upgraded first temporary container with the corresponding test container to obtain an upgraded test container; wherein the upgraded test container is used as a target test container;
and under the condition that the application programs in the target test containers run normally, upgrading the application containers corresponding to the test containers.
A non-transitory computer storage medium for container-based application upgrades, storing computer-executable instructions configured to:
receiving an application program upgrading request sent by an operation and maintenance terminal, wherein the application program upgrading request comprises current application program information and target application program information;
determining a plurality of corresponding pre-constructed test containers based on the current application information; the test application program running in the test container is matched with the current application program information;
constructing a first temporary container of each test container, and upgrading each first temporary container according to the target application program information;
exchanging the upgraded first temporary container with the corresponding test container to obtain an upgraded test container; wherein the upgraded test container is used as a target test container;
and under the condition that the application programs in the target test containers run normally, upgrading the application containers corresponding to the test containers.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects: the corresponding test container can be determined according to the application program upgrading request sent by the operation and maintenance terminal, the first temporary container is constructed for the test container to realize the upgrading of the test container, and after the test container is upgraded successfully, the application container corresponding to the test container is upgraded, so that the upgrading of the application container corresponding to the application program upgrading request is completed. That is to say, the application program upgrading method based on the container provided by the embodiment of the application program upgrading method firstly upgrades the test container, can find problems and adjust problems in time, and then upgrades the application container on the basis of successful upgrading of the test container, so as to ensure the success rate of upgrading the application container, reduce the rollback time, enable the application container to be smoothly transited and gradually upgraded, and ensure the stability of the whole system. Meanwhile, the manual operation of operation and maintenance personnel can be reduced, and the labor cost and the error rate are reduced.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more apparent, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art without making any inventive step based on the embodiments in the description belong to the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for upgrading an application based on a container according to an embodiment of the present disclosure. As shown in fig. 1, the method for upgrading an application based on a container according to an embodiment of the present application may include the following steps:
s101, receiving an application program upgrading request sent by an operation and maintenance terminal.
The application program upgrading request comprises current application program information and target application program information. The current application information refers to the relevant information of the application program currently operated by the container, and the target application information refers to the relevant information of the application program operated after the container is upgraded.
In particular, the current application information may include a current application identification, current application identification version information. The target application information may include a target application identification, target application identification version information.
The operation and maintenance terminal may refer to a terminal device corresponding to an operation and maintenance worker, where the terminal device may be a PC terminal or a mobile terminal (e.g., a mobile phone, a tablet computer, etc.).
S102, determining a corresponding test container based on the current application program information.
Wherein the test application running in the test container matches the current application information.
It should be noted that, the matching between the test application running in the test container and the current application information mentioned herein may mean that the application identifier of the test application is consistent with the current application identifier in the current application information, and the application version information of the test application is consistent with the current application version information in the current application information.
For example, if the current application id of the current application information is 001 and the current application id version information is V1.0.0, the application id of the matching test application is also 001 and the application id version information is also V1.0.0.
In some embodiments of the present application, several containers may be pre-constructed, which may not be open to the user, and exist only as a test, i.e., the test container described above. Or, selecting several application containers from the application containers to be upgraded according to a preset rule as test containers, where the application rule may be that a container with a smaller user access amount is selected as a test container according to the user access amount.
S103, constructing first temporary containers of the test containers, and upgrading the first temporary containers according to the target application program information.
Specifically, the corresponding update application code is searched according to the target application program identifier and the target application program version information in the target application program information. And upgrading each first temporary container according to the updated application code.
In some embodiments of the present application, before constructing the first temporary container of each test container, further comprising: each test container is suspended from service. And carrying out data backup on the database corresponding to the test container.
The test container is suspended for service, so that related users can not access the service of the container through the url address, new data can not be generated in the process, data abnormity in the upgrading or rollback process is prevented, and the successful probability of container upgrading is improved.
And performing data backup on the database corresponding to the test container, and rolling back the backup data to the original test container by taking the backup data as a basis for data recovery when rolling back the container.
It should be noted that, after the first temporary container of each test container is constructed, the address of the first temporary container may be calculated and stored for subsequent verification.
In some embodiments of the present application, it is also necessary to build a temporary database of corresponding first temporary containers from the database of test containers.
In some embodiments of the present application, after upgrading the first temporary container according to the target application information, the method further comprises: and upgrading the temporary database corresponding to the first temporary container.
And S104, exchanging the upgraded first temporary container with the corresponding test container to obtain the upgraded test container, and taking the upgraded test container as a target test container.
Specifically, a temporary storage area corresponding to each test container may be first constructed, and the application programs in the test containers are sent to the temporary storage area for storage. And assigning the application program in the upgraded first temporary container to the test container to obtain the upgraded test container, namely the target test container.
For example, the test container a and the upgraded first temporary container B corresponding to the temporary container a may first construct the temporary storage area C corresponding to the test container a, and assign the application program in the upgraded first temporary container B to the test container a, so as to obtain the target test container D.
Through the mode, the accuracy of upgrading the container can be effectively improved.
In some embodiments of the present application, in addition to exchanging the upgraded first temporary container with its corresponding test container, the upgraded temporary database needs to be exchanged with its corresponding test container database, specifically, the database a corresponding to the upgraded first temporary container is renamed to C according to a rule, then the database name B of the test container is changed to a, then C is changed to B, and then the database owner and the corresponding authority are reassigned according to the original database (i.e. the assignment of a to B, and the assignment of B to a) are performed. After the application program in the container is upgraded, the data in the corresponding database is no longer suitable for the upgraded application program, and the database needs to be upgraded to ensure the normal use of the upgraded container.
In some embodiments of the present application, after upgrading the first temporary container according to the target application information, the method may further include: and closing and deleting the first temporary container, thereby releasing the storage space and reducing the occupied storage resources.
And S105, under the condition that the application program in each target test container runs normally, upgrading the application container corresponding to the test container.
And under the condition that the application program in each target test container runs normally, the success of the upgrading of the application program can be demonstrated. Thus, the application container corresponding to the test container can be upgraded.
Reference herein to an application container corresponding to a test container may refer to agreement between the application identification and the application version information. The normal operation of the application program in each target test container can be known to mean that the data structure of the application program has no error, the code has no error and the like.
In some embodiments of the present application, upgrading an application container corresponding to a test container may include: and constructing an application temporary container corresponding to each application program, and upgrading each application temporary container according to the target application program information. Exchanging the upgraded application temporary container with the corresponding application container to obtain an upgraded application container; and taking the upgraded application container as a target application container to finish upgrading the application container. The specific implementation manner is the same as or similar to the above steps S101-S105, as shown in fig. 2, and is not described herein again.
In some embodiments of the present application, in a case that an application program in a target test container cannot normally run, the target test container may also be rolled back, and the target test container is rolled back to the test container, which may specifically be implemented in the following manner:
constructing a second temporary container of the target test container;
determining the application version of the application program operated by the test container corresponding to the target test container according to the pre-stored upgrade log;
updating the second temporary container according to the application version of the application program operated by the test container corresponding to the target test container; and the application program running in the updated second temporary container is consistent with the application program running in the test container.
And exchanging the second temporary container with the target test container to obtain a test container corresponding to the target test container.
In the application program upgrading method based on the container provided by the embodiment of the application program upgrading method, a corresponding test container is determined according to an application program upgrading request sent by an operation and maintenance terminal, a first temporary container is constructed for the test container to realize upgrading of the test container, and after the test container is upgraded successfully, the application container corresponding to the test container is upgraded, so that upgrading of the application container corresponding to the application program upgrading request is completed. That is to say, the application program upgrading method based on the container provided by the embodiment of the application program upgrading method firstly upgrades the test container, can find problems and adjust problems in time, and then upgrades the application container on the basis of successful upgrading of the test container, so as to ensure the success rate of upgrading the application container, reduce the rollback time, enable the application container to be smoothly transited and gradually upgraded, and ensure the stability of the whole system. Meanwhile, the manual operation of operation and maintenance personnel can be reduced, and the labor cost and the error rate are reduced.
In some embodiments of the application, container information of the test container and the application container may also be obtained, and the container information is displayed to operation and maintenance personnel, so that the operation and maintenance personnel can know relevant information of each container in real time.
Wherein, the container information at least comprises any one of the following: application identification, application version information, state information. The state information may include: running, in an application upgrade, in a database upgrade, in a data backup, an abnormal state, etc.
In some embodiments of the present application, when an application program in each target test container runs normally, upgrading the application container corresponding to the test container is performed asynchronously.
It should be noted that, in the embodiment of the present application, asynchronous execution may be adopted for upgrading or rolling back of an application program, as shown in fig. 3. The result of task creation can be returned without waiting for the task to be finished, the task continues to run in the background, and the task state is continuously returned and updated with information until the task is finished. The task creator creates a task and sends the task to a corresponding task executor, and the task executors can execute the task concurrently and update the task state continuously. If the task list is less than or equal to the number of task performers, all tasks are performed simultaneously. If the task list is larger than the number of task executors, the excess part of tasks need to wait.
In addition, in the embodiment of the application, the log can be generated according to the record of the upgrading and/or rollback process of the application program, so as to facilitate the subsequent check. For example: can be divided into an upgrade log and a rollback log.
Based on the same idea, some embodiments of the present application further provide a device and a non-volatile computer storage medium corresponding to the above method.
Fig. 4 is a schematic structural diagram of a container-based application upgrading apparatus corresponding to fig. 1 for carrying the above container-based application upgrading method according to an embodiment of the present application, where the quality chain apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
receiving an application program upgrading request sent by an operation and maintenance terminal, wherein the application program upgrading request comprises current application program information and target application program information;
determining a plurality of corresponding pre-constructed test containers based on the current application information; the test application program running in the test container is matched with the current application program information;
constructing a first temporary container of each test container, and upgrading each first temporary container according to the target application program information;
exchanging the upgraded first temporary container with the corresponding test container to obtain an upgraded test container; wherein the upgraded test container is used as a target test container;
and under the condition that the application programs in the target test containers run normally, upgrading the application containers corresponding to the test containers.
Some embodiments of the present application provide a non-transitory computer storage medium corresponding to a container-based application upgrade of fig. 1, storing computer-executable instructions configured to:
receiving an application program upgrading request sent by an operation and maintenance terminal, wherein the application program upgrading request comprises current application program information and target application program information;
determining a plurality of corresponding pre-constructed test containers based on the current application information; the test application program running in the test container is matched with the current application program information;
constructing a first temporary container of each test container, and upgrading each first temporary container according to the target application program information;
exchanging the upgraded first temporary container with the corresponding test container to obtain an upgraded test container; wherein the upgraded test container is used as a target test container;
and under the condition that the application programs in the target test containers run normally, upgrading the application containers corresponding to the test containers.
The embodiments in the present application are described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device and media embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference may be made to some descriptions of the method embodiments for relevant points.
The device and the medium provided by the embodiment of the application correspond to the method one to one, so the device and the medium also have the similar beneficial technical effects as the corresponding method, and the beneficial technical effects of the method are explained in detail above, so the beneficial technical effects of the device and the medium are not repeated herein.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely application embodiment, or an embodiment combining application and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.