Container image rollback method, device, computer equipment and storage medium

By querying the image name and version number in the local database and updating the container image, and synchronizing data with the callback interface of the mirror warehouse service, the problem that new containers cannot pull the image in container image rollback is solved, ensuring that the container image can be rolled back to the correct version And run normally.

CN112463304BActive Publication Date: 2024-11-05KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011395158.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-03
Publication Date
2024-11-05
Estimated Expiration
2040-12-03

AI Technical Summary

Technical Problem

The existing container image rollback method causes the new container to fail to pull the corresponding version image and cannot start normally, resulting in service interruption.

Method used

By receiving the client's image rollback request, check whether the corresponding image name and version number exist in the local database. If it exists, update the container image. If it does not exist, return an error message and register the callback interface for data synchronization update in the mirror warehouse service service. to ensure the accuracy of the mirrored version.

Benefits of technology

It realizes accurate rollback of container images to a specific version, solving the problem that the new container cannot pull the corresponding version image, so that the new container can run normally and provide services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112463304B_ABST
    Figure CN112463304B_ABST
Patent Text Reader

Abstract

The present application relates to a container image rollback method, device, computer equipment and storage medium. The method comprises: receiving a container image rollback request initiated by a client; the image rollback request carries an image identifier; according to the image identifier, querying in a local database whether the image name and version number corresponding to the image identifier exist; if so, initiating a request to update the image of the container to the container orchestration service, and updating the image version of the container according to the image name and version number; if not, returning an error message. This method can be used to roll back a container image to a specific version, and can identify and feedback which image versions can be rolled back, solving the problem that a new container cannot pull the corresponding version image, so that the new container can pull the specified image version to run normally and provide corresponding services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a container image rollback method, apparatus, computer device, and storage medium. Background Art

[0002] With the development of computer technology and the trend of microservice cloud containerization, cloud service governance has become a difficult point in operation and maintenance management. Continuous integration (CI) and continuous deployment (CD) are indispensable tools in cloud service governance, responsible for managing the process of transforming projects from code to microservices. When CD, i.e. continuous deployment tasks, fail to execute or produce erroneous operations, rolling back the images involved in the microservice to the previous version or a specific historical version is a remedial measure to correct this situation.

[0003] However, the current method of rolling back container images usually uses the rollback function of the container orchestration tool. This may easily result in the new container being unable to pull the corresponding version image even if the container is updated successfully, making it impossible for the new container to start normally, and thus resulting in an inability to provide services. Summary of the invention

[0004] Based on this, it is necessary to provide a rollback method, device, computer equipment and storage medium for the container image that can solve the problem that the new container cannot pull the corresponding version image in order to solve the above technical problems.

[0005] A container image rollback method, the method comprising:

[0006] Receiving a container image rollback request initiated by a client; the image rollback request carries an image identifier;

[0007] According to the image identifier, query in the local database whether the image name and version number corresponding to the image identifier exist;

[0008] If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number;

[0009] If it does not exist, an error message is returned.

[0010] In one of the embodiments, before receiving the image rollback request for the container initiated by the client, the method further includes:

[0011] Register a callback interface with the image repository service, and synchronously update the image table data stored in the local database through the callback interface.

[0012] In one embodiment, registering a callback interface with the image repository service includes:

[0013] Setting configuration parameters corresponding to the callback interface in the configuration file corresponding to the image repository service;

[0014] The configuration parameters include a uniform resource locator system address; the uniform resource locator system address is used to instruct the image repository service to send a callback event request to the uniform resource locator system parameter address.

[0015] In one embodiment, the synchronously updating the mirror table data stored in the local database through the callback interface includes:

[0016] When receiving a callback event request sent by the image repository through the callback interface, the image table data stored in the local database is synchronously updated according to the image identifier carried in the callback event request.

[0017] In one embodiment, the synchronously updating the mirror table data stored in the local database according to the mirror identifier includes:

[0018] When the callback event is a push event, according to the image identifier, query whether there is a record of the corresponding image name and version number in the image table data stored in the local database; the push event is triggered when the user completes uploading the image to the image warehouse;

[0019] If it exists, update the image identifier;

[0020] If it does not exist, insert the image name and version number into the image table data.

[0021] In one embodiment, the synchronously updating the mirror table data stored in the local database according to the mirror identifier includes:

[0022] When the callback event is a deletion event, the record of the corresponding image name and version number is deleted from the image table data stored in the local database; the deletion event is triggered when the user deletes an image from the image warehouse.

[0023] In one embodiment, registering a callback interface with the image repository service includes:

[0024] Configure the callback interface through the docker registry service;

[0025] Alternatively, you can use the image repository management tool to configure the callback interface for some projects or the global callback interface.

[0026] A container image rollback device, the device comprising:

[0027] A receiving module, configured to receive a container image rollback request initiated by a client; the image rollback request carries an image identifier;

[0028] A query module, used to query the local database for the existence of the corresponding image name and version number according to the image identifier;

[0029] An update module, configured to initiate a request to update the image of the container to the container orchestration service if it exists, and update the image version of the container according to the image name and version number;

[0030] Returns the module, which will return an error message if it does not exist.

[0031] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0032] Receiving a container image rollback request initiated by a client; the image rollback request carries an image identifier;

[0033] According to the image identifier, query in the local database whether the image name and version number corresponding to the image identifier exist;

[0034] If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number;

[0035] If it does not exist, an error message is returned.

[0036] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0037] Receiving a container image rollback request initiated by a client; the image rollback request carries an image identifier;

[0038] According to the image identifier, query in the local database whether the image name and version number corresponding to the image identifier exist;

[0039] If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number;

[0040] If it does not exist, an error message is returned.

[0041] The above-mentioned container image rollback method, device, computer equipment and storage medium receive a container image rollback request initiated by a client, and the image rollback request carries an image identifier. According to the image identifier, the local database is queried to see whether the image name and version number corresponding to the image identifier exist. If so, a request to update the container image is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number. If not, an error message is returned. As a result, the container image can be rolled back to a specific version, and which image versions can be rolled back can be identified and fed back, which solves the problem that the new container cannot pull the corresponding version image, so that the new container can pull the specified image version to run normally and provide corresponding services. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 This is an application environment diagram of a container image rollback method in one embodiment;

[0043] Figure 2 It is a flowchart of a method for rolling back a container image in one embodiment;

[0044] Figure 3A This is a schematic diagram of a rollback process of a container image corresponding to a certain server in an embodiment;

[0045] Figure 3B A schematic diagram of a process of rolling back a container image in one embodiment;

[0046] Figure 4 A flowchart of the steps of registering a callback interface with an image repository service in one embodiment;

[0047] Figure 5 A schematic diagram of a process flow of an image repository service callback request in one embodiment;

[0048] Figure 6 A schematic diagram of a process for synchronously updating the mirror table data stored in the local database according to the mirror identifier in one embodiment;

[0049] Figure 7 is a structural block diagram of a container image rollback device in one embodiment;

[0050] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] The container image rollback method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the client 102 communicates with the server 104 through the network. The server 104 receives the image rollback request of the container initiated by the client 102, and the image rollback request carries the image identifier. According to the image identifier, the server 104 queries the local database whether the image name and version number corresponding to the image identifier exist. If it exists, the server 104 initiates a request to update the image of the container to the container orchestration service, and updates the image version of the container according to the image name and version number. If it does not exist, the server 104 returns an error message. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0053] In one embodiment, Figure 2 As shown, a container image rollback method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0054] Step 202: receiving a container image rollback request initiated by a client, wherein the image rollback request carries an image identifier.

[0055] With the trend of microservice cloud containerization, cloud service governance has become a difficult point in operation and maintenance management. Continuous integration (CI) and continuous deployment (CD) are indispensable tools in cloud service governance, responsible for managing the process of transforming projects from code to microservices. When CD, i.e. continuous deployment tasks, fail to execute or produce erroneous operations, it is necessary to roll back the images involved in the microservices to the previous version or a specific historical version, which is a remedial measure to correct this situation. By deploying containers, each container is isolated from each other, each container has its own file system, and the processes between containers will not affect each other, and computing resources can be distinguished. Compared with virtual machines, containers can be deployed quickly. Since containers are decoupled from the underlying facilities and machine file systems, they can be migrated between different clouds and different versions of operating systems. Containers take up less resources and are deployed quickly. Each application can be packaged into a container image. The one-to-one relationship between each application and the container also makes containers have greater advantages. Creating container images for applications, because each application does not need to be combined with the rest of the application stack, nor does it rely on the production environment infrastructure, this enables a consistent environment to be provided from R&D to testing and production.

[0056] Specifically, the user can log in to the system of a specific scenario by entering a username and password on a PC or mobile phone application or in a browser webpage. The user can initiate an image rollback request for a specific container through an app (Application) or a web browser. The system background receives the image rollback request for the container initiated by the client, and pushes the image rollback request for the container to the server through the data center. The server can receive the image rollback request for the container pushed by the data center, and the image rollback request carries an image identifier. Among them, the client (Client) or user end refers to a program corresponding to the server that provides local services to customers. In addition to some applications that only run locally, it is generally installed on an ordinary client and needs to cooperate with the server to run. It refers to a program corresponding to the server that provides local services to users. For example, the client can be a mobile terminal, a browser, or any tool that can initiate an http request based on user operations. A container refers to a single-process operating environment with resources isolated from each other. An image refers to a collection of necessary environments, resources, and processes required for container startup, usually including an image name, version number, and image ID. An image identifier is an image ID, which is used to identify a unique image name and version. An image rollback request is a request to roll back the current container to a specified image version.

[0057] Step 204: According to the image identifier, query in the local database whether the image name and version number corresponding to the image identifier exist.

[0058] After the server receives the image rollback request for the container initiated by the client, the server can query the local database for the image name and version number corresponding to the image identifier carried in the image rollback request. Specifically, the server's callback interface can be pre-registered in the image repository. The image repository generally refers to the Docker registry, but can also be any image repository management tool that supports image pulling and registration callback interfaces, such as Harbor. The image repository is used to store images, and can include a collection of multiple images with the same image name but different version numbers.

[0059] When a trigger event is generated for an image version in the image repository, the image repository will use the image name, version, address, ID, time and other information corresponding to the trigger event as parameters to call the server's callback interface. The server can synchronize and update the image table data stored in the local database in real time based on the received trigger event. When the server receives an image rollback request for a container initiated by the client, the server can directly query the data table in the local database to see if the specified image name and version exist.

[0060] Step 206: If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number.

[0061] Step 208: If it does not exist, an error message is returned.

[0062] According to the image identifier, the server queries the local database for the image name and version number corresponding to the image identifier. If it exists, the server initiates a request to update the image of the container to the container orchestration service, and updates the image version of the container according to the image name and version number. If it does not exist, the server returns an error message. Among them, the container orchestration service generally refers to kubernetes, abbreviated as K8s, which is an abbreviation formed by replacing the 8 characters "ubernete" with 8, that is, a container orchestration tool. kubernetes is an open source for managing containerized applications on multiple hosts in a cloud platform. The goal of kubernetes is to make the deployment of containerized applications simple and efficient (powerful). kubernetes provides a mechanism for application deployment, planning, updating, and maintenance. The container orchestration service can also be other services or tools with container orchestration functions, such as Docker Compose. Docker Compose is a command line tool provided by docker to define and run applications composed of multiple containers. Docker is a commonly used container management tool. Among them, the image repository is a service independent of the container orchestration tool, which is used to store images. Container orchestration tools can also provide services even when there is no image repository. Different types of image repositories do not affect the normal functions of container orchestration tools. Therefore, there is no direct subordinate relationship between image repositories and container orchestration tools that run containers.

[0063] Specifically, Figure 3A The figure shows a schematic diagram of the rollback process of a container image corresponding to a certain server. Based on the image identifier, the server queries the local database to see whether the image name and version number corresponding to the image identifier exist. If so, the server can initiate a request to the container orchestration service to update the image of the container, so that the container orchestration service can update the image version of the container based on the image name and version number, that is, the server can use the container orchestration tool to update the image of a running service. If it does not exist, the server returns an error message. That is, after the server receives the image rollback request for the container initiated by the client, the server can search the database table for an image version that meets the conditions based on the image name and version. If a record exists, the front end will display "rollback allowed" or a synonymous prompt, otherwise it will not display "rollback allowed" or will display a synonymous prompt such as "rollback prohibited". For example, Figure 3BAs shown in the figure, when the client sends a request to the server to roll back a container to a specified image version, the server first queries the data table to see if the specified image name and version exist. If so, the server sends a request to Kubernetes to update the deployment / statefulset to update the image of the specified container to the specified image and version; if not, the server returns an error message to the front end (i.e., the client). Among them, deployment / statefulset refers to an object defined by k8s, representing a running service, which is a collection of containers.

[0064] In the traditional way, for example, when using the rollback function of the container orchestration tool such as k8s, since there is no direct subordinate relationship between the image repository that stores the image and the container orchestration tool that runs the container, the container orchestration tool cannot identify whether the image required for the update exists, so even if the container is updated successfully, the new container cannot pull the corresponding image and cannot start normally, which leads to the inability to provide services. In this embodiment, by receiving the image rollback request of the container initiated by the client, the image rollback request carries the image identifier. According to the image identifier, the local database is queried to see whether the image name and version number corresponding to the image identifier exist. If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number. If it does not exist, an error message is returned. As a result, the container image can be rolled back to a specific version, and it can identify and feedback which image versions can be rolled back, which solves the problem that the new container cannot pull the corresponding version image, so that the new container can pull the specified image version to run normally and provide corresponding services.

[0065] In one embodiment, before receiving a container image rollback request initiated by a client, the method further includes:

[0066] Register a callback interface with the image repository service and use the callback interface to synchronously update the image table data stored in the local database.

[0067] Before the server receives the image rollback request for the container initiated by the client, the server can pre-register a callback interface with the image repository service, and synchronize and update the image table data stored in the local database through the callback interface. Specifically, the server can register a callback interface with the image repository service in a variety of ways, and synchronize and update the image table data stored in the local database through the callback interface. For example, corresponding configuration parameters can be added to the configuration file of the docker registry. Register the callback interface with the image repository service by modifying the parameters in the configuration file and then restarting the service. As a result, by pre-registering the callback interface with the image repository service, the image version data stored in the local database can be synchronized according to the push or deletion events of the image repository.

[0068] In one embodiment, if Figure 4 As shown in the figure, the steps to register the callback interface with the image repository service include:

[0069] Step 402: Set configuration parameters corresponding to the callback interface in a configuration file corresponding to the image repository service.

[0070] Step 404: The configuration parameters include a uniform resource locator system address, and the uniform resource locator system address is used to instruct the image repository service to send a callback event request to the uniform resource locator system parameter address.

[0071] The server can pre-register a callback interface with the image repository service, and synchronize and update the image table data stored in the local database through the callback interface. Specifically, the configuration parameters corresponding to the callback interface can be set in advance in the configuration file corresponding to the image repository service. The configuration parameters include a uniform resource locator system address, which is used to instruct the image repository service to send a callback event request to the uniform resource locator system parameter address. For example, the configuration parameters corresponding to the callback interface are set in the configuration file of the docker registry as follows: notifications:

[0072] Endpoints:

[0073] -name:callback

[0074] disabled:false

[0075] url:http: / / 127.0.0.1:8080 / callback / image

[0076] timeout:3000ms

[0077] threshold:5

[0078] Backoff: 1s

[0079] Among them, the configuration parameters added in the configuration file may include URL (Uniform Resource Locator), which is the uniform resource locator of WWW, that is, the network address. URL is the address to which the request is sent when executing the callback, and in this application refers to the callback interface provided by the server. The threshold and backoff in the configuration file are some additional attribute configuration information, threshold refers to the failure waiting time, and backoff refers to the failure retry interval. The above configuration parameters are only examples of configuring callback methods for one image repository, and the configuration methods for different image repositories include but are not limited to the above configuration parameters. As a result, by pre-registering the callback interface to the image repository service, the image version data stored in the local database can be synchronized according to the push or deletion events of the image repository.

[0080] In one embodiment, the step of synchronously updating the mirror table data stored in the local database through the callback interface includes:

[0081] When receiving a callback event request sent by the image repository through the callback interface, the image table data stored in the local database is synchronously updated according to the image identifier carried in the callback event request.

[0082] After the server registers the callback interface with the image repository service, the server can synchronize and update the image table data stored in the local database through the callback interface. Specifically, when the server receives the callback event request sent by the image repository through the callback interface, it synchronizes and updates the image table data stored in the local database according to the image identifier carried in the callback event request. For example, Figure 5As shown, it is a flowchart of the image warehouse service callback request. When the image version in the image warehouse generates a push or delete event, the image warehouse can use the image name, version, address, ID, time and other information corresponding to the push event or delete event as parameters to call the server's callback interface. If it is a push event, the server queries whether there is a record of the same image name and version in the local database based on the received push event. If not, the server inserts the record of the image name and version corresponding to the push event into the data table. If it exists, the server updates the corresponding ID according to the record of the image name and version corresponding to the push event. If it is a delete event, the server deletes the record of the image name and version corresponding to the delete event in the local database from the database table according to the delete event. Among them, the image warehouse is used to store images. When the user completes uploading the image to the image warehouse, an event will be triggered, which is a "push event". When the user deletes the image from the image warehouse, a "delete event" will be triggered. As a result, by registering a callback interface with the image repository service, the corresponding records in the local database can be added, updated, and deleted according to the callback event request, so that the local database records are consistent with the data of the image actually stored in the image repository service. Before the container image is rolled back, it is possible to quickly and easily query whether the image version to be rolled back still exists, so as to determine whether to roll back. This solves the problem that the new container cannot pull the corresponding version of the image, so that the new container can pull the specified image version to run normally and provide corresponding services.

[0083] In one embodiment, Figure 6 As shown, the step of synchronously updating the mirror table data stored in the local database according to the mirror identifier includes:

[0084] Step 602, when the callback event is a push event, query whether there is a record of the corresponding image name and version number in the image table data saved in the local database according to the image identifier. The push event is triggered when the user completes uploading the image to the image warehouse.

[0085] Step 604: If it exists, update the image identifier.

[0086] Step 606: If it does not exist, insert the image name and version number into the image table data.

[0087] When the server receives a callback event request sent by the image warehouse through the callback interface, the server can synchronize and update the image table data stored in the local database according to the image identifier carried in the callback event request. Specifically, when the callback event is a push event, the server can query whether there is a corresponding image name and version number record in the image table data stored in the local database according to the image identifier carried by the push event. The push event is triggered when the user completes uploading the image to the image warehouse. If it exists, the server updates the image identifier in the image table data stored in the local database. If it does not exist, the server inserts the image name and version number into the image table data in the local database. That is, when the image warehouse pushes the "push or delete" event to the server through the callback interface, the server can update the corresponding image table record in the local database according to the image ID of these events as the primary key, and save the image information currently existing in the image warehouse, including the name, version and other additional information. In traditional technology, since the container orchestration tool cannot identify whether the image required for the update exists, it will cause the container to be updated successfully, but the new container cannot pull the corresponding version of the image and cannot start normally, which leads to the inability to provide the corresponding service. In this embodiment, by querying the database by the image name and version number, it is possible to determine whether the image version exists, ensuring that the specified image version exists in the warehouse, thereby avoiding the problem that the new container cannot pull the corresponding version image, that is, each time the container image is rolled back, by querying the records in the local database, it is verified whether the specified image version exists, thereby ensuring that the container image is rolled back to a specific version, so that the new container can pull the specified image version to operate normally and provide corresponding services.

[0088] In one embodiment, the step of synchronously updating the mirror table data stored in the local database according to the mirror identifier includes:

[0089] When the callback event is a deletion event, the record of the corresponding image name and version number is deleted from the image table data saved in the local database. The deletion event is triggered when the user deletes the image from the image repository.

[0090] When the server receives a callback event request sent by the image warehouse through the callback interface, the server can synchronize and update the image table data stored in the local database according to the image identifier carried in the callback event request. Specifically, when the callback event is a deletion event, the server can delete the corresponding image name and version number records in the image table data stored in the local database according to the image identifier carried in the deletion event, wherein the deletion event is triggered when the user deletes the image from the image warehouse. Thus, by registering the callback interface with the image warehouse service, and according to the callback event request, the corresponding records in the local database are added, updated or deleted. Thus, by registering the callback interface with the image warehouse service, the corresponding records in the local database can be added, updated, and deleted according to the callback event request, so that the local database records and the image data actually stored by the image warehouse service are consistent, and before the container image is rolled back, it can quickly and conveniently query whether the image version to be rolled back still exists, so as to determine whether to roll back, solve the problem that the new container cannot pull the corresponding version image, so that the new container can pull the specified image version to run normally and provide corresponding services.

[0091] In one embodiment, the step of registering a callback interface with the image repository service includes:

[0092] Configure the callback interface through the docker registry service.

[0093] Alternatively, you can use the image repository management tool to configure the callback interface for some projects or the global callback interface.

[0094] Before the server receives the image rollback request for the container initiated by the client, the server can pre-register the callback interface with the image repository service. Specifically, when the server registers the callback interface with the image repository service, it can directly configure the callback interface parameters through the docker registry service, or it can configure the callback interface for some projects or globally through some image repository management intermediate services (such as harbor). As a result, by registering the callback interface with the image repository service, the image version data saved in the local database can be synchronously updated according to the push or deletion events of the image repository, ensuring that before rolling back, it can quickly and easily query whether the image version to be rolled back still exists, so as to determine whether a rollback can be performed.

[0095] It should be understood that although Figure 1-6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-6At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0096] In one embodiment, Figure 7 As shown, a container image rollback device is provided, including: a receiving module 702, a query module 704, an update module 706 and a return module 708, wherein:

[0097] The receiving module 702 is used to receive a container image rollback request initiated by a client, where the image rollback request carries an image identifier.

[0098] The query module 704 is used to query the local database whether the corresponding image name and version number exist according to the image identifier.

[0099] The update module 706 is used to initiate a request to update the image of the container to the container orchestration service if it exists, and update the image version of the container according to the image name and version number.

[0100] The return module 708 is used to return an error message if it does not exist.

[0101] In one embodiment, the update module is further used to register a callback interface with the image repository service, and synchronously update the image table data stored in the local database through the callback interface.

[0102] In one embodiment, the device further includes: a setting module.

[0103] The setting module is used to set the configuration parameters corresponding to the callback interface in the configuration file corresponding to the image repository service. The configuration parameters include a uniform resource locator system address, and the uniform resource locator system address is used to instruct the image repository service to send a callback event request to the uniform resource locator system parameter address.

[0104] In one embodiment, the update module is further configured to synchronously update the image table data stored in the local database according to the image identifier carried in the callback event request when receiving a callback event request sent by the image repository through the callback interface.

[0105] In one embodiment, the query module is also used to query whether there is a corresponding image name and version number record in the image table data stored in the local database according to the image identifier when the callback event is a push event. The push event is triggered when the user completes uploading the image to the image warehouse. If it exists, the image identifier is updated; if it does not exist, the image name and version number are inserted into the image table data.

[0106] In one embodiment, the device further includes: a deletion module.

[0107] The deletion module is used to delete the corresponding image name and version number records in the image table data saved in the local database when the callback event is a deletion event. The deletion event is triggered when the user deletes the image from the image repository.

[0108] In one embodiment, the device further includes: a configuration module.

[0109] The configuration module is used to configure the callback interface through the Docker registry service; or to configure the callback interface of some projects or the global callback interface through the image repository management tool.

[0110] For the specific definition of the container image rollback device, please refer to the definition of the container image rollback method above, which will not be repeated here. Each module in the above-mentioned container image rollback device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0111] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store rollback data of the container image. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a container image rollback method is implemented.

[0112] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0113] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above-mentioned method embodiments when executing the computer program.

[0114] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0115] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0116] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for rolling back a container image, the method comprising: Receive a container image rollback request initiated by the client; The image rollback request carries an image identifier; According to the image identifier, query in the local database whether the image name and version number corresponding to the image identifier exist; If it exists, a request to update the image of the container is initiated to the container orchestration service, and the image version of the container is updated according to the image name and version number; If it does not exist, an error message is returned; Before receiving the image rollback request for the container initiated by the client, the method further includes: Register a callback interface with the image repository service, and synchronously update the image table data stored in the local database through the callback interface; the image repository is a service independent of the container orchestration service and is used to store images.

2. The method according to claim 1, characterized in that The image repository includes a collection of multiple images with the same image name and different version numbers.

3. The method according to claim 1, characterized in that The registration of the callback interface to the image repository service includes: Setting configuration parameters corresponding to the callback interface in the configuration file corresponding to the image repository service; The configuration parameters include a uniform resource locator system address; the uniform resource locator system address is used to instruct the image repository service to send a callback event request to the uniform resource locator system parameter address.

4. The method according to claim 1, characterized in that: The synchronously updating the mirror table data stored in the local database through the callback interface includes: When receiving a callback event request sent by the image repository through the callback interface, the image table data stored in the local database is synchronously updated according to the image identifier carried in the callback event request.

5. The method according to claim 4, characterized in that The synchronously updating the mirror table data stored in the local database according to the mirror identifier includes: When the callback event is a push event, according to the image identifier, query whether there is a record of the corresponding image name and version number in the image table data stored in the local database; the push event is triggered when the user completes uploading the image to the image warehouse; If it exists, update the image identifier; If it does not exist, insert the image name and version number into the image table data.

6. The method according to claim 4, characterized in that The synchronously updating the mirror table data stored in the local database according to the mirror identifier includes: When the callback event is a deletion event, the record of the corresponding image name and version number is deleted from the image table data stored in the local database; the deletion event is triggered when the user deletes an image from the image warehouse.

7. The method according to claim 1, characterized in that The registering callback interface with the image repository service includes: Configure the callback interface through the docker registry service; Alternatively, you can use the image repository management tool to configure the callback interface for some projects or the global callback interface.

8. A container image rollback device, characterized in that: The device comprises: A receiving module, configured to receive a container image rollback request initiated by a client; the image rollback request carries an image identifier; A query module, used to query the local database for the existence of the corresponding image name and version number according to the image identifier; An update module, configured to initiate a request to update the image of the container to the container orchestration service if it exists, and update the image version of the container according to the image name and version number; Return module, which is used to return error information if it does not exist; The update module is also used to register a callback interface with the image repository service, and synchronously update the image table data stored in the local database through the callback interface; the image repository is a service independent of the container orchestration service and is used to store images.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. 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 any one of claims 1 to 7 are implemented.