Methods, apparatus, electronic devices and readable storage media for managing mirror repositories
By using different storage methods to distinguish between newly uploaded and existing image layers in the image repository, the problem of downtime required for image repository garbage cleanup is solved, and parallel operations of image uploading and cleanup are achieved, ensuring the normal operation of the image repository and saving resources.
Patent Information
- Application Number
- CN201910507414.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-12
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2039-06-12
AI Technical Summary
The existing image repository service requires the entire service to be put into a read-only state when cleaning up junk image layers, which makes it impossible to shut down for a long time in a real environment and fails to meet actual needs.
By using different storage methods to store newly uploaded image layers and existing image layers in the image repository—namely, the first storage method and the second storage method—garbage cleanup during image upload operations is avoided, ensuring that the two do not interfere with each other.
This allows for garbage cleanup during image upload, avoiding concurrency issues and ensuring the normal operation of the image repository while conserving resources.
Smart Images

Figure CN112084165B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer application technology, and specifically to a method, apparatus, electronic device, and readable storage medium for managing a mirror repository. Background Technology
[0002] In the Docker system, images are stored through image repositories. Clients can download images from and upload images to these repositories. A Registry is an open-source Docker image storage and management center. When a client performs a Docker instantiation operation, it can download the required images from the image repository and save them locally. Conversely, when a client modifies an image to create a new image, it can upload the new image to the image repository. An image can contain multiple image layers, and adjacent image layers have dependencies on each other. The Docker system uses image metadata to describe the dependencies between image layers.
[0003] In proposing this invention, the inventors discovered that existing image repository services face difficulties in cleaning up junk image layers. The main reason is that existing junk cleanup solutions require the entire service to be placed in a read-only state, during which all image upload operations are blocked. However, in real-world environments, the system cannot remain in a read-only state for extended periods; therefore, existing junk cleanup solutions do not meet practical needs. Summary of the Invention
[0004] To address the problems in the related technologies, embodiments of this disclosure provide a method, apparatus, electronic device, and readable storage medium for managing a mirror repository.
[0005] Firstly, this disclosure provides a method for managing a mirror repository.
[0006] Specifically, the method for managing the mirror repository includes:
[0007] Receive one or more uploaded image layers;
[0008] The uploaded image layer is stored in the image repository using the first storage method;
[0009] Identify one or more original image layers to be cleaned in the image repository, which are stored in a second storage method, where the first storage method is different from the second storage method.
[0010] Clean the image layer to be cleaned.
[0011] In conjunction with the first aspect, in a first implementation of the first aspect of this disclosure, the original image layer includes the image layer stored in the image repository before and / or after the uploaded image layer is received.
[0012] In conjunction with the first aspect, in a second implementation of the first aspect, storing the uploaded image layer in the image repository using the first storage method includes:
[0013] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0014] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0015] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0016] In conjunction with the first aspect, in a third implementation of the first aspect, the determination and / or cleanup operations are performed concurrently with the receiving and / or the storage operations.
[0017] In conjunction with the first aspect, the fourth implementation of the first aspect further includes:
[0018] After cleaning the image layer to be cleaned, the uploaded image layer is stored using the second storage method.
[0019] In conjunction with the fourth implementation of the first aspect, in the fifth implementation of the first aspect of this disclosure, storing the uploaded image layer in the second storage method includes:
[0020] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0021] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0022] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0023] In conjunction with the first aspect, the sixth implementation of the first aspect further includes:
[0024] During the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; and / or
[0025] After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0026] In conjunction with the first aspect, the seventh implementation of the first aspect further includes: when the received image layer and any of the original image layers belong to the same image, storing the received image layer as the original image layer in the image repository in a second storage manner.
[0027] In conjunction with the first aspect, in the eighth implementation of the first aspect, when the received image layer does not belong to the same image as any of the original image layers, the received image layer is stored in the image repository as the uploaded image layer using the first storage method.
[0028] In conjunction with the first aspect, in the ninth implementation of the first aspect, the determination and / or cleanup operation is started after uploading the image metadata of the original image layer.
[0029] In conjunction with the first aspect, in the tenth implementation of the first aspect of this disclosure, there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method.
[0030] In conjunction with the first aspect, in the eleventh implementation of the first aspect, storing the uploaded image layer in the image repository in a first storage manner includes storing the uploaded image layer in a temporary image layer directory in the image repository.
[0031] In conjunction with the eleventh implementation of the first aspect, the twelfth implementation of the first aspect further includes, when processing the download of the uploaded mirror layer:
[0032] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0033] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0034] In conjunction with the fourth implementation of the first aspect, in the thirteenth implementation of the first aspect, the step of storing the uploaded image layer in the second storage method after cleaning the image layer to be cleaned includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0035] Secondly, this disclosure provides an apparatus for managing a mirror repository.
[0036] Specifically, the apparatus for managing the mirror repository includes:
[0037] The receiving module is configured to receive one or more uploaded image layers;
[0038] The first storage module is configured to store the uploaded image layer in the image repository in a first storage method;
[0039] The determination module is configured to determine the image layer to be cleaned in one or more original image layers stored in the image repository in a second storage method, wherein the first storage method is different from the second storage method.
[0040] The cleanup module is configured to clean the image layer to be cleaned.
[0041] In conjunction with the second aspect, in a first implementation of the second aspect of this disclosure, the original image layer includes the image layer stored in the image repository before and / or after the uploaded image layer is received.
[0042] In conjunction with the second aspect, in a second implementation of the second aspect of this disclosure, storing the uploaded image layer in the image repository using the first storage method includes:
[0043] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0044] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0045] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0046] In conjunction with the second aspect, in a third implementation of the second aspect, the determination and / or cleanup operations are performed concurrently with the receiving and / or the storage operations.
[0047] In conjunction with the second aspect, the fourth implementation of the present disclosure further includes a second storage module, configured as follows:
[0048] After cleaning the image layer to be cleaned, the uploaded image layer is stored using the second storage method.
[0049] In conjunction with the fourth implementation of the second aspect, in the fifth implementation of the second aspect of this disclosure, storing the uploaded image layer in the second storage method includes:
[0050] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0051] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0052] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0053] In conjunction with the second aspect, the sixth implementation of the present disclosure also includes a download module, configured as follows:
[0054] During the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; and / or
[0055] After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0056] In conjunction with the second aspect, the seventh implementation of the present disclosure further includes a third storage module, configured to: store the received image layer as the original image layer in the image repository in a second storage manner when the received image layer belongs to the same image as any of the original image layers.
[0057] In conjunction with the second aspect, in the eighth implementation of the second aspect of this disclosure, storing the uploaded image layer in the image repository in the first storage method includes: when the received image layer does not belong to the same image as any of the original image layers, storing the received image layer in the image repository as the uploaded image layer in the first storage method.
[0058] In conjunction with the second aspect, in the ninth implementation of the second aspect, the determination and / or cleanup operation is initiated after uploading the image metadata of the original image layer.
[0059] In conjunction with the second aspect, in the tenth implementation of the second aspect of this disclosure, there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method.
[0060] In conjunction with the second aspect, in the eleventh implementation of the second aspect, storing the uploaded image layer in the image repository in a first storage manner includes storing the uploaded image layer in a temporary image layer directory in the image repository.
[0061] In conjunction with the eleventh implementation of the second aspect, the twelfth implementation of the second aspect further includes a second download module configured to, when processing the download of the uploaded mirror layer:
[0062] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0063] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0064] In conjunction with the fourth implementation of the second aspect, in the thirteenth implementation of the second aspect, the step of storing the uploaded image layer in the second storage method after cleaning the image layer to be cleaned includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0065] Thirdly, embodiments of this disclosure provide an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the following method steps:
[0066] Receive one or more uploaded image layers;
[0067] The uploaded image layer is stored in the image repository using the first storage method;
[0068] Identify one or more original image layers to be cleaned in the image repository, which are stored in a second storage method, where the first storage method is different from the second storage method.
[0069] Clean the image layer to be cleaned.
[0070] In conjunction with the third aspect, in a first implementation of the third aspect, the original image layer includes the image layer stored in the image repository before and / or after the uploaded image layer is received.
[0071] In conjunction with the third aspect, in the second implementation of the third aspect of this disclosure, storing the uploaded image layer in the image repository using the first storage method includes:
[0072] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0073] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0074] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0075] In conjunction with the third aspect, in a third implementation of the third aspect, the determination and / or cleanup operations are performed concurrently with the receiving and / or the storage operations.
[0076] In conjunction with the third aspect, in a fourth implementation of the third aspect, the one or more computer instructions are further executed by the processor to implement the following method steps:
[0077] After cleaning the image layer to be cleaned, the uploaded image layer is stored using the second storage method.
[0078] In conjunction with the fourth implementation of the third aspect, in the fifth implementation of the third aspect, the step of storing the uploaded image layer using the second storage method includes:
[0079] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0080] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0081] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0082] In conjunction with the third aspect, in a sixth implementation of the third aspect, the one or more computer instructions are further executed by the processor to implement the following method steps:
[0083] During the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; and / or
[0084] After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0085] In conjunction with the third aspect, in a seventh implementation of the third aspect, the one or more computer instructions are further executed by the processor to implement the following method steps: when the received image layer is the same image as any of the original image layers, the received image layer is stored in the image repository as the original image layer in a second storage manner.
[0086] In conjunction with the third aspect, in the eighth implementation of the third aspect, storing the uploaded image layer in the image repository using the first storage method includes: storing the received image layer as the uploaded image layer in the image repository using the first storage method when the received image layer does not belong to the same image as any of the original image layers.
[0087] In conjunction with the third aspect, in the ninth implementation of the third aspect, the determination and / or cleanup operation is started after uploading the image metadata of the original image layer.
[0088] In conjunction with the third aspect, in the tenth implementation of the third aspect of this disclosure, according to the method of claim 1, the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method are not referenced.
[0089] In conjunction with the third aspect, in the eleventh implementation of the third aspect, the storage of the uploaded image layer in the image repository in the first storage method includes storing the uploaded image layer in a temporary image layer directory in the image repository.
[0090] In conjunction with the eleventh implementation of the third aspect, in the twelfth implementation of the third aspect of this disclosure, the one or more computer instructions are further executed by the processor to implement the following method steps when processing the download of the uploaded mirror layer:
[0091] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0092] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0093] In conjunction with the fourth implementation of the third aspect, in the thirteenth implementation of the third aspect, the step of storing the uploaded image layer in the second storage method after cleaning the image layer to be cleaned includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0094] Fourthly, this disclosure provides a readable storage medium storing computer instructions that, when executed by a processor, implement the method described in any one of the first, first to thirteenth implementations of the first aspect.
[0095] The technical solutions provided in this disclosure may have the following beneficial effects:
[0096] According to the technical solution provided in this disclosure, by storing the newly uploaded image layer and the original image layer in the image repository using two different storage methods, namely the first storage method and the second storage method, the image layer in the image upload operation is separated from the image layer in the garbage cleanup operation. This makes it possible to perform garbage cleanup simultaneously with the image upload operation, avoiding concurrency issues. The garbage cleanup problem of the image repository is solved without introducing other databases or middleware.
[0097] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0098] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:
[0099] Figure 1 A flowchart illustrating a method for managing a mirror repository according to an embodiment of the present disclosure;
[0100] Figure 2 A schematic diagram illustrating a method for managing a mirror repository according to an embodiment of the present disclosure;
[0101] Figure 3 A schematic diagram illustrating the provision of an upload mirror layer download service during the determination and / or the cleanup operation;
[0102] Figure 4 This diagram illustrates a process of providing an upload and download service for the image layer after it has been cleaned.
[0103] Figure 5 A structural block diagram of an apparatus for managing a mirror repository according to an embodiment of the present disclosure is shown;
[0104] Figure 6 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown;
[0105] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing a method for managing a mirror repository according to embodiments of the present disclosure is shown. Detailed Implementation
[0106] In the following, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings to enable those skilled in the art to readily implement them. Furthermore, for clarity, portions unrelated to the description of exemplary embodiments have been omitted from the drawings.
[0107] In this disclosure, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of features, figures, steps, behaviors, components, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility of the presence or addition of one or more other features, figures, steps, behaviors, components, parts or combinations thereof.
[0108] It should also be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0109] As mentioned above, an image consists of multiple image layers. An image repository stores at least image layers and image metadata describing the dependencies between them. When cleaning up the image repository, the image layers to be deleted are determined based on the image metadata. For example, it identifies which image layers in the image repository are not depended upon, and then deletes the undependent image layers, thereby achieving the purpose of image garbage cleanup.
[0110] However, the inventors discovered that because image layers and image metadata are uploaded separately during image upload, some image layers may be uploaded before their corresponding image metadata. This can lead to concurrency issues when performing garbage collection during the image upload process. For example, after some image layers have been uploaded but before their corresponding image metadata has been uploaded, these image layers may not be described as being depended on by other image layers by any image metadata. If garbage collection is performed at this time, and these undependent image layers are detected, they will be cleaned up, rendering the image unusable.
[0111] Figure 1 A flowchart illustrating a method for managing a mirror repository according to an embodiment of this disclosure is shown. Figure 1 As shown, the method for managing a mirror repository includes the following steps S101-S104:
[0112] In step S101, one or more uploaded mirror layers are received;
[0113] In step S102, the uploaded image layer is stored in the image repository using a first storage method;
[0114] In step S103, one or more original image layers to be cleaned are identified in the image repository, which are stored in the second storage method. The first storage method is different from the second storage method.
[0115] In step S104, the image layer to be cleaned is cleaned.
[0116] Figure 2A schematic diagram illustrating a method for managing a mirror repository according to an embodiment of the present disclosure is shown.
[0117] like Figure 1 and 2 As shown, the mirror repository receives one or more uploaded image layers and stores them in the mirror repository using a first storage method. Existing image layers in the mirror repository are stored using a second storage method. Since the first and second storage methods differ, they effectively distinguish between uploaded and existing image layers. This allows for cleanup operations to be performed on existing image layers without cleaning up uploaded image layers, thus preventing accidental deletion of uploaded image layers due to incomplete or missing image metadata.
[0118] Specifically, when performing determination and / or cleanup operations on existing image layers, the image layers to be cleaned can be identified first. For example, based on the image metadata of the existing image layers, identify which existing image layers are not dependent on, and determine these undependent existing image layers as the image layers to be cleaned. Then, the image layers to be cleaned are cleaned, for example, by directly deleting them or placing them in other storage spaces, thereby freeing up the storage space originally occupied by the image layers to be cleaned.
[0119] According to embodiments of this disclosure, the existing image layers include image layers stored in the image repository before and / or after the uploaded image layers are received. For example, it can be pre-set that image layers of new images received after a certain time point are stored as uploaded image layers in a first manner, while image layers received by the image repository before this time point are stored as existing image layers in a second manner. If, at that time point, some image layers of some images have started uploading but have not yet finished uploading, the remaining image layers of that image can be stored as existing image layers in the second manner.
[0120] In other words, after this point in time, if the received image layer belongs to the same image as any existing image layer, the received image layer is stored in the image repository as the existing image layer using the second storage method; if the received image layer does not belong to the same image as any existing image layer, the received image layer is stored in the image repository as the uploaded image layer using the first storage method. This way, the uploading process will not be interrupted by switching from the second storage method to the first storage method. For example, image M includes image layers M1, M2, M3, M4, M5, and M6, where M1, M2, M3, M4, and M5 are already stored in the image repository using the second storage method. Since image layer M6 also belongs to image M, if image layer M6 is received after the aforementioned point in time, then image layer M6 is also stored in the image repository using the second storage method. On the other hand, for example, if the image layer Z1 received after the above time point does not belong to the same image as any existing image layer, that is, if the image layer Z1 belongs to a new image, then the image layer Z1 is stored in the image repository as an uploaded image layer in the first storage method.
[0121] According to embodiments of this disclosure, there is no dependency between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method.
[0122] According to embodiments of this disclosure, when uploading multiple image layers of an image, all image layers included in the image can be uploaded to the image repository, or only image layers not present in the image repository can be uploaded, omitting those already present, thereby saving communication, processing, and storage resources. For example, some images may include basic software image layers such as operating systems and databases. When uploading multiple image layers of an image, these basic software image layers may be omitted, and only image layers not present in the image repository may be uploaded. For instance, if the uploaded image contains an image layer of a Linux operating system, and the image repository already stores an image layer of the same Linux operating system, then to save communication resources and storage space in the image repository, the Linux operating system image layer may be omitted, and only other image layers not present in the image repository need to be uploaded.
[0123] Therefore, when uploading multiple image layers, it can be determined whether one or more of these image layers exist in the image repository. If so, these image layers do not need to be uploaded repeatedly. If uploading image layers is allowed to depend on existing image layers in the image repository, it is possible that when determining which image layers need to be cleaned up, the metadata of the uploaded image layer has not yet been uploaded, resulting in the deletion of the dependent original image layer. In this embodiment, dependencies between uploaded image layers and original image layers are prohibited; that is, the original image layer does not contain the parent and / or child layers of the uploaded image layer. This avoids the situation where the original image layer depended on by the uploaded image layer is deleted, causing the uploaded image to become unusable.
[0124] According to embodiments of this disclosure, storing the uploaded image layer in the image repository using a first storage method includes:
[0125] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0126] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0127] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0128] For example, if the original image layer is stored in the first image layer directory, the uploaded image layer can be stored in the second image layer directory. This allows the uploaded image layer and the original image layer to be stored in two different ways. At the same time, the confirmation and / or cleanup operations are only performed in the first image layer directory, while no confirmation and / or cleanup operations are performed in the second image layer directory.
[0129] According to embodiments of this disclosure, storing the uploaded image layer in the image repository using a first storage method includes storing the uploaded image layer in a temporary image layer directory within the image repository.
[0130] For example, existing image layers can be stored in the existing image layer directory, while uploaded image layers can be stored in a temporary image layer directory, different from the existing image layer directory. Since the existing and temporary image layer directories are two different directories, isolation between the uploaded and existing image layers can be achieved by storing them in separate directories. When performing confirm and / or cleanup operations on image layers in the existing image layer directory, no new image layers will be added to the existing image layer directory. That is, the existing image layer directory is in a read-only state, and confirm and / or cleanup operations are only performed in the existing image layer storage directory, not in the temporary image layer directory. This allows image layer uploads to continue while confirm and / or cleanup operations are being performed, and avoids the concurrency problem of accidentally deleting uploaded image layers due to the inability to upload image metadata in a timely manner when uploading and cleanup operations are performed simultaneously.
[0131] Alternatively, if the existing image layers use the first naming method, the uploaded image layer can use the second naming method. For example, if the existing image layers use an identifier ID (70618b6e8070) for naming, the uploaded image layer can use a new-ID (new-80618b6e8070) for naming. This way, during the confirmation and / or cleanup operations, image layers whose names include the character "new" will not be processed. It should be understood that this embodiment of the invention is only illustrated by using an identifier to name the image layers, but the invention is not limited thereto.
[0132] Alternatively, when the image repository receives uploaded image layers, it can store the uploaded image layers with a flag indicating that they are prohibited from being cleaned. In this case, no determination and / or cleanup operations are performed on the image layers with the flag indicating that they are prohibited from being cleaned.
[0133] According to embodiments of this disclosure, after uploading the image metadata of the original image layer, the determination and / or cleanup operation is initiated.
[0134] In this embodiment, the determination and / or cleanup of the original image layer is only performed after ensuring that the original image layer and its corresponding image metadata have been stored in the image repository. At this time, the original image layer will be in a read-only state and will not be depended on by new image metadata. In this way, the image layers that the original image layer depends on can be found based on the image metadata of all the original image layers, thereby determining the image layers to be cleaned up and avoiding the situation of accidentally deleting the image layers that the original image layer depends on.
[0135] According to an embodiment of this disclosure, after cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method.
[0136] After the garbage cleanup of the image layer is completed, the uploaded image layer can be merged into the original image layer, that is, the uploaded image layer can be stored using the same second storage method as the original image layer.
[0137] According to embodiments of this disclosure, storing the uploaded image layer in the second storage method includes:
[0138] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0139] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0140] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0141] For example, if the original mirror layer is stored in the first mirror layer directory, after cleaning up the mirror layer to be cleaned up, the uploaded mirror layer stored in the second mirror layer directory can be copied to the first mirror layer directory. After a preset time period, the uploaded mirror layer stored in the second mirror layer directory can be deleted, or the second mirror layer directory and its uploaded mirror layers can be deleted. The preset time period can be set according to actual needs. For example, after the validity period of the download service provided based on the second mirror layer directory expires, the uploaded mirror layer in the second mirror layer directory can be deleted, or the second mirror layer directory and its uploaded mirror layers can be deleted.
[0142] Alternatively, if the existing image layers use the first naming convention, then after cleaning the image layers to be cleaned, the naming convention of the uploaded image layers can be changed to the first naming convention. For example, if the existing image layers use an identifier ID for naming, and the uploaded image layers use the new-ID convention, then the naming convention of the uploaded image layers can be changed to use the identifier ID, for example, renaming "new-80618b6e8070" to "80618b6e8070".
[0143] Alternatively, when the image repository stores uploaded image layers in association with the identification information of prohibited cleanup, the association between the uploaded image layer and the identification information of prohibited cleanup can be removed after the image layer to be cleaned is cleaned.
[0144] According to an embodiment of this disclosure, after cleaning the image layer to be cleaned, storing the uploaded image layer in the second storage method includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0145] For example, after cleaning up the image layers to be cleaned in the original image layer directory, the uploaded image layers stored in the temporary image layer directory can be added to the original image layer directory. After a preset time period, the uploaded image layers stored in the temporary image layer directory can be deleted, or the temporary image layer directory and its uploaded image layers can be deleted. The preset time period can be set according to actual needs. For example, after the validity period of the download service provided based on the temporary image layer directory expires, the uploaded image layers in the temporary image layer directory or the temporary image layer directory and its uploaded image layers can be deleted.
[0146] According to embodiments of this disclosure, the determine and / or cleanup operations can be performed concurrently with the receive and / or store operations.
[0147] In this embodiment, since the target of the determine and / or cleanup operation is the existing image layer stored in the image repository using the second storage method, while the target of the receive and / or store operation is the uploaded image layer, the two operations target different objects. Therefore, the receive and / or store operation and the determine and / or cleanup operation can be executed concurrently. This ensures that image uploads can still be received normally while the image repository is undergoing garbage cleanup.
[0148] In addition to providing image upload services, image repositories can also provide image download services. According to embodiments of this disclosure, when downloading an image, the client sends a message to the image repository to query for an image. This message includes at least the identifier of the specified image to be downloaded. Based on the image identifier, the image repository returns information about the specified image, such as the image size, image layer structure, and identifiers of each image layer. The client then checks its locally stored image layers against the identifiers of each image layer returned by the image repository to see which image layers are not present. If some image layers already exist locally, these existing image layers do not need to be downloaded; instead, the client downloads the image layers that are not present locally from the image repository, and the image download process ends.
[0149] According to embodiments of this disclosure, during the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method.
[0150] Figure 3 This diagram illustrates the provision of a download service for the uploaded mirror layer during the determination and / or cleanup operation.
[0151] like Figure 3As shown, when the mirror repository performs confirm and / or cleanup operations on existing image layers, the existing image layers will be in a read-only state and will not accept newly uploaded image layers. Therefore, uploaded image layers will be stored in the mirror repository using the first storage method. Since the uploaded image layers are stored in the mirror repository using the first storage method, the mirror repository provides download services for the uploaded image layers based on these first storage methods. For example, the mirror repository can provide a download link for an uploaded image layer stored in the first storage method: 10.175.10.100:8080 / layername1 / b750fe792670, where 10.175.10.100:8080 represents the address where the image layer is stored in the mirror repository using the first storage method, layername1 is the name of the image layer to be downloaded, and b750fe792670 following layername1 is the identifier of the image layer.
[0152] According to embodiments of this disclosure, after cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0153] Figure 4 This diagram illustrates the provision of an upload image layer download service after the image layer to be cleaned is cleaned.
[0154] like Figure 4 As shown, after cleaning up the image layers to be cleaned in the image repository, the uploaded image layers are stored in the image repository using a second storage method. Since the uploaded image layers are stored in the image repository using this second storage method, the image repository provides download services for the uploaded image layers based on these second storage methods. That is, the image information provided by the image repository originates from the uploaded image layers stored in the second storage method, according to their identifiers. For example, the image repository can provide a download link for an uploaded image layer stored in the second storage method: 10.175.10.100:9090 / layername2 / f750fe792670. Here, 10.175.10.100:9090 represents the address where the image layer is stored in the image repository using the second storage method, layername2 is the name of the image layer to be downloaded, and f750fe792670 following layername2 is the identifier of that image layer.
[0155] According to embodiments of this disclosure, the method further includes, when processing the download of the uploaded mirror layer:
[0156] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0157] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0158] For example, the original mirror layer can be stored in the original mirror layer directory, and the uploaded mirror layer can be stored in a temporary mirror layer directory that is different from the original mirror layer directory. When processing the download of uploaded mirror layer N, it is first determined whether uploaded mirror layer N exists in the temporary mirror layer directory. If uploaded mirror layer N exists in the temporary mirror layer directory, the download link of uploaded mirror layer N in the temporary mirror layer directory is provided first; if uploaded mirror layer N does not exist in the temporary mirror layer directory, the download link of uploaded mirror layer N in the original mirror layer directory is provided. For example, if the name of the uploaded image layer N is layername and its identifier is f850fe792670, when processing the download of the uploaded image layer N, first check if the uploaded image layer N exists in the temporary image layer directory. If the uploaded image layer N exists in the temporary image layer directory, then provide the download link for the uploaded image layer N in the temporary image layer directory: 10.275.10.100:9090 / layername / f850fe792670; if the identifier f850fe792670 of the uploaded image layer N does not exist in the temporary image layer directory, then provide the download link for the uploaded image layer N in the original image layer directory: 20.275.20.200:9090 / layername / f850fe792670.
[0159] Figure 5 A structural block diagram of an apparatus 500 for managing a mirror repository according to an embodiment of the present disclosure is shown. This apparatus can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 5 As shown, the device 500 for managing the mirror repository includes a receiving module 510, a first storage module 520, a determining module 530, and a cleaning module 540.
[0160] The receiving module 510 is configured to receive one or more uploaded image layers;
[0161] The first storage module 520 is configured to store the uploaded image layer in the image repository in a first storage method;
[0162] The determining module 530 is configured to determine the image layer to be cleaned in one or more original image layers stored in the image repository in a second storage method, wherein the first storage method is different from the second storage method.
[0163] The cleaning module 540 is configured as a cleaning module and is configured to clean the image layer to be cleaned.
[0164] According to embodiments of this disclosure, the original image layer includes image layers stored in the image repository before and / or after the uploaded image layer is received.
[0165] According to embodiments of this disclosure, storing the uploaded image layer in the image repository using a first storage method includes:
[0166] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0167] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0168] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0169] According to embodiments of this disclosure, the determine and / or cleanup operations are performed concurrently with the receive and / or store operations.
[0170] According to embodiments of this disclosure, the device 500 may further include a second storage module 550, configured to:
[0171] After cleaning the image layer to be cleaned, the uploaded image layer is stored using the second storage method.
[0172] According to embodiments of this disclosure, storing the uploaded image layer in the second storage method includes:
[0173] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0174] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0175] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0176] According to embodiments of this disclosure, the device 500 may further include a first download module 560, configured to:
[0177] During the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; and / or
[0178] After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0179] According to an embodiment of this disclosure, the apparatus 500 may further include a third storage module 570, configured to: store the received image layer as the original image layer in the image repository in a second storage manner when the received image layer belongs to the same image as any of the original image layers.
[0180] According to an embodiment of this disclosure, storing the uploaded image layer in the image repository in a first storage method includes: storing the received image layer as the uploaded image layer in the image repository in the first storage method when the received image layer does not belong to the same image as any of the original image layers.
[0181] According to embodiments of this disclosure, after uploading the image metadata of the original image layer, the determination and / or cleanup operation is initiated.
[0182] According to embodiments of this disclosure, there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method.
[0183] According to embodiments of this disclosure, storing the uploaded image layer in the image repository in a first storage manner includes storing the uploaded image layer in a temporary image layer directory in the image repository.
[0184] According to embodiments of this disclosure, the apparatus 500 may further include a second download module 580, configured to: when processing the download of the uploaded mirror layer:
[0185] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0186] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0187] According to an embodiment of this disclosure, after cleaning the image layer to be cleaned, storing the uploaded image layer in the second storage method includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0188] This disclosure also discloses an electronic device, Figure 6 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0189] like Figure 6 As shown, the electronic device 600 includes a memory 601 and a processor 602; wherein,
[0190] The memory 601 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 602 to implement the following method steps:
[0191] Receive one or more uploaded image layers;
[0192] The uploaded image layer is stored in the image repository using the first storage method;
[0193] Identify one or more original image layers to be cleaned in the image repository, which are stored in a second storage method, where the first storage method is different from the second storage method.
[0194] Clean the image layer to be cleaned.
[0195] According to embodiments of this disclosure, the original image layer includes image layers stored in the image repository before and / or after the uploaded image layer is received.
[0196] According to embodiments of this disclosure, storing the uploaded image layer in the image repository using a first storage method includes:
[0197] The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or
[0198] The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or
[0199] The uploaded image layer is stored in association with identification information that prohibits cleanup.
[0200] According to embodiments of this disclosure, the determine and / or cleanup operations are performed concurrently with the receive and / or store operations.
[0201] According to embodiments of this disclosure, the one or more computer instructions are further executed by the processor 602 to implement the following method steps:
[0202] After cleaning the image layer to be cleaned, the uploaded image layer is stored using the second storage method.
[0203] According to embodiments of this disclosure, storing the uploaded image layer in the second storage method includes:
[0204] The uploaded image layer is stored in the storage directory of the original image layer; and / or
[0205] The uploaded image layer shall be named using the same naming convention as the original image layer; and / or
[0206] Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
[0207] According to embodiments of this disclosure, the one or more computer instructions are further executed by the processor 602 to implement the following method steps:
[0208] During the determination and / or the cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; and / or
[0209] After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
[0210] According to an embodiment of this disclosure, the one or more computer instructions are further executed by the processor 602 to implement the following method steps: when the received image layer belongs to the same image as any of the original image layers, the received image layer is stored in the image repository as the original image layer in a second storage manner.
[0211] According to an embodiment of this disclosure, storing the uploaded image layer in the image repository in a first storage method includes: storing the received image layer as the uploaded image layer in the image repository in the first storage method when the received image layer does not belong to the same image as any of the original image layers.
[0212] According to embodiments of this disclosure, after uploading the image metadata of the original image layer, the determination and / or cleanup operation is initiated.
[0213] According to embodiments of this disclosure, there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method.
[0214] According to embodiments of this disclosure, storing the uploaded image layer in the image repository in a first storage manner includes storing the uploaded image layer in a temporary image layer directory in the image repository.
[0215] According to embodiments of this disclosure, the one or more computer instructions are further executed by the processor to implement the following method steps when processing the download of the uploaded mirror layer:
[0216] When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first.
[0217] If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
[0218] According to an embodiment of this disclosure, after cleaning the image layer to be cleaned, storing the uploaded image layer in the second storage method includes adding the uploaded image layer stored in the temporary image layer directory to the storage directory storing the one or more original image layers.
[0219] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing a food recommendation method according to embodiments of the present disclosure is shown.
[0220] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can execute various processes described in the above embodiments according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage section 708 into a random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the system 700. The CPU 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0221] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed into the storage section 708 as needed.
[0222] In particular, according to embodiments of this disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing the above-described object category determination method. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711.
[0223] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0224] The units or modules described in the embodiments of this disclosure can be implemented in software or programmable hardware. The described units or modules can also be located in a processor, and the names of these units or modules do not necessarily constitute a limitation on the unit or module itself.
[0225] In another aspect, this disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus described in the above embodiments; or it may be a standalone computer-readable storage medium not assembled into the device. The computer-readable storage medium stores one or more programs that are used by one or more processors to perform the methods described in this disclosure.
[0226] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
Claims
1. A method for managing a mirror repository, characterized in that, The method includes: Receive one or more uploaded image layers; The uploaded image layer is stored in the temporary image layer directory of the image repository using the first storage method; Concurrently with the receiving and / or the storage operation, determine the image layers to be cleaned in one or more original image layers stored in the image repository in a second storage method, wherein the first storage method is different from the second storage method, and there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method. Clean the image layer to be cleaned; After cleaning the image layer to be cleaned, the uploaded image layer stored in the temporary image layer directory is added to the storage directory storing the one or more original image layers, and the uploaded image layer is stored in the second storage method.
2. The method according to claim 1, characterized in that: The original image layer includes the image layer stored in the image repository before and / or after the uploaded image layer is received.
3. The method according to claim 1, characterized in that, Storing the uploaded image layer in the image repository using the first storage method includes: The uploaded image layer is stored in a storage directory different from the storage directory of the original image layer; and / or The uploaded image layer shall be named using a naming convention different from that of the original image layer; and / or The uploaded image layer is stored in association with identification information that prohibits cleanup.
4. The method according to claim 1, characterized in that, The step of storing the uploaded image layer using the second storage method includes: The uploaded image layer is stored in the storage directory of the original image layer; and / or The uploaded image layer shall be named using the same naming convention as the original image layer; and / or Remove the association between the uploaded image layer and the identification information that prohibits cleaning.
5. The method according to claim 1, characterized in that, Also includes: During the determination and / or cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; And / or After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
6. The method according to claim 1, characterized in that, Also includes: If the received image layer is the same image as any of the original image layers, the received image layer is stored in the image repository as the original image layer using the second storage method.
7. The method according to claim 1, characterized in that, The step of storing the uploaded image layer in the image repository using the first storage method includes: when the received image layer does not belong to the same image as any of the original image layers, storing the received image layer in the image repository as the uploaded image layer using the first storage method.
8. The method according to claim 1, characterized in that, After uploading the image metadata of the original image layer, the determination and / or cleanup operation begins.
9. The method according to claim 1, characterized in that, This also includes, when processing the download of the uploaded mirror layer: When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first. If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
10. An apparatus for managing a mirror repository, characterized in that, The device includes: The receiving module is configured to receive one or more uploaded image layers; The first storage module is configured to store the uploaded image layer in the temporary image layer directory of the image repository in a first storage method; The determination module is configured to concurrently with the receiving and / or the storage operation to determine the image layer to be cleaned in one or more original image layers stored in the image repository in a second storage method, wherein the first storage method is different from the second storage method, and there is no reference relationship between the uploaded image layer stored in the first storage method and the original image layer stored in the second storage method. The cleanup module is configured to clean the image layer to be cleaned; After cleaning the image layer to be cleaned, the uploaded image layer stored in the temporary image layer directory is added to the storage directory storing the one or more original image layers, and the uploaded image layer is stored in the second storage method.
11. The apparatus according to claim 10, characterized in that, It also includes the first download module, which is configured as follows: During the determination and / or cleanup operation, a download service for the uploaded image layer is provided based on the uploaded image layer stored in the first storage method; And / or After cleaning the image layer to be cleaned, the uploaded image layer is stored in the second storage method, and a download service for the uploaded image layer is provided based on the uploaded image layer stored in the second storage method.
12. The apparatus according to claim 10, characterized in that, It also includes a third storage module, configured to: if the received image layer is the same image as any of the original image layers, store the received image layer in the image repository as the original image layer in a second storage method.
13. The apparatus according to claim 10, characterized in that, It also includes a second download module, configured to: when processing the download of the uploaded mirror layer: When the uploaded mirror layer exists in the temporary mirror layer directory, the download link of the uploaded mirror layer in the temporary mirror layer directory shall be provided first. If the uploaded image layer does not exist in the temporary image layer directory, a download link for the uploaded image layer is provided in the storage directory that stores the one or more original image layers.
14. An electronic device, characterized in that, It includes a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps according to any one of claims 1-9.
15. A readable storage medium having computer instructions stored thereon, characterized in that, When executed by a processor, the computer instructions implement the method steps of any one of claims 1-9.
Citation Information
Patent Citations
Method and device for clearing mirror image in cluster node
CN107066296A
Mirror image garbage cleaning system and method for docker mirror image warehouse
CN107105054A