A node image optimization method and device, electronic equipment and storage medium

By extracting repetitive setup statements from node images and constructing a unified base image, the problems of excessive space consumption and wasted time in node image setup methods are solved, achieving image optimization and efficiency improvement.

CN115357430BActive Publication Date: 2026-04-17GUANGZHOU WERIDE TECH LTD CO
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU WERIDE TECH LTD CO
Filing Date
2022-08-23
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

The existing node image building methods are not reusable, resulting in excessive total space usage and excessive time consumption when pulling large training images.

Method used

By obtaining the image setup scripts of each node, extracting duplicate image setup statements, building a unified base image, and optimizing node images based on this base image, the total number of duplicate image setup statements and the retrieval time are reduced.

Benefits of technology

The optimized node image has a smaller total space footprint and a lower time consumption when pulling images, thus improving efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115357430B_ABST
    Figure CN115357430B_ABST
Patent Text Reader

Abstract

The application discloses a node image optimization method and device, electronic equipment and a storage medium, and is used for solving the technical problems that the existing node image building method cannot be reused, the total occupied space is too large, and the time occupancy rate is too high when a large training image is pulled. The application comprises the following steps: acquiring node images of each node, and extracting image building scripts corresponding to the node images; acquiring repeated image building statements in the image building scripts of all nodes; building a unified basic image by using the repeated image building statements; and optimizing the node images by using the unified basic image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mirroring technology, and in particular to a node mirroring optimization method, apparatus, electronic device, and storage medium. Background Technology

[0002] In today's large-scale cluster training, each node pulls different images to create containers when it receives a container creation request.

[0003] Large training images often occupy more than 20GB of space, and the time for pulling and decompressing is very long. Excessive waiting time will delay the efficiency of engineers.

[0004] Furthermore, since large training images are often created by engineers themselves and cannot be reused, their total storage space can be very large. Large training images often quickly push node space to the warning threshold, necessitating node image cleanup. The clearing of previously cached images means that the next time a container needs to be created, the entire large training image must be fetched again from the first layer, resulting in excessive time consumption. Summary of the Invention

[0005] This invention provides a node image optimization method, apparatus, electronic device, and storage medium to solve the technical problems of existing node image building methods being unreusable, resulting in excessive total space usage, and excessive time consumption when pulling large training images.

[0006] This invention provides a node mirroring optimization method, comprising:

[0007] Obtain the node image of each node, and extract the image building script corresponding to the node image;

[0008] Retrieve duplicate image building statements in the image building scripts of all nodes;

[0009] A unified base image is built using the aforementioned repeated image building statement;

[0010] The node image is optimized using the unified base image.

[0011] Optionally, the step of obtaining duplicate image building statements in the image building scripts of all nodes includes:

[0012] Create a dictionary mapping;

[0013] Obtain the outdated image setup script from the image setup script;

[0014] Determine the current image build script from the unupdated image build script;

[0015] Obtain the first image building statement of the current image building script;

[0016] The dictionary mapping is updated using the first image building statement to obtain the updated dictionary mapping;

[0017] Determine if there is an outdated image build script;

[0018] If so, return to the step of determining the current image build script in the unupdated image build script;

[0019] If not, obtain the duplicate image building statements in the image building scripts of all the nodes according to the updated dictionary mapping.

[0020] Optionally, the step of updating the dictionary mapping using the first image building statement to obtain the updated dictionary mapping includes:

[0021] Identify any unmatched image building statements among all the first image building statements;

[0022] The current image building statement is determined from the unmatched image building statements;

[0023] Match the mapping relationship of the current image building statement in the dictionary mapping;

[0024] If the match fails, a mapping relationship is constructed using the current image building statement as the key and 1 as the value, and the mapping relationship is added to the dictionary mapping to obtain the updated dictionary mapping;

[0025] If a match is successful, the value of the mapping relationship in the dictionary mapping is incremented by 1 to obtain the updated dictionary mapping;

[0026] Determine if there are any unmatched image build statements;

[0027] If so, return to the step of determining the current image building statement among the unmatched image building statements;

[0028] If not, output the updated dictionary mapping.

[0029] Optionally, the step of obtaining duplicate image building statements in the image building scripts of all the nodes according to the updated dictionary mapping includes:

[0030] The first image building statement with a value greater than 1 is extracted from the updated dictionary mapping and used as the repeated image building statement.

[0031] Optionally, the step of optimizing the node image using the unified base image includes:

[0032] Obtain the image build script to be optimized from all the image build scripts described;

[0033] The current image build script to be optimized is determined in the image build script to be optimized.

[0034] Obtain the second image building statement of the current image building script to be optimized;

[0035] The second image building statement and the unified base image are used to generate a list of non-reusable image statements;

[0036] The optimized image building script is generated using the non-reusable image statement list and the unified base image, and the optimized node image is generated using the optimized image building script.

[0037] Determine if there are any image build scripts that need to be optimized;

[0038] If so, return to the step of determining the current image build script in the image build script to be optimized;

[0039] If not, output the optimized node image of all nodes.

[0040] Optionally, the step of generating a list of non-reusable image statements using the second image building statement and the unified base image includes:

[0041] Iterate through the second image building statements and determine in turn whether each second image building statement is in the unified base image;

[0042] If so, obtain the first image layer number of the second image building statement in the current image building script to be optimized, and add the second image building statement and the corresponding first image layer number into a preset set;

[0043] Obtain the second image layer number of each second image build statement in the unified base image;

[0044] Obtain the target image building statement whose first image layer number is the same as the second image layer number from the second image building statement;

[0045] Determine whether there is an initial image building statement with a first image layer number of 1 in the target image building statement;

[0046] If so, based on the first image layer number, obtain the consecutive image building statements containing the initial image building statement from the target image building statement, and count the number T of the consecutive image statements;

[0047] The second image building statement that is not in the continuous image building statement is saved in the list of non-reusable image statements.

[0048] Optionally, the step of generating the optimized image building script for the current image to be optimized using the list of non-reusable image statements and the unified base image includes:

[0049] Obtain the first T duplicate image building statements from the unified base image;

[0050] The optimized image building script is generated by using the first T repeated image building statements and the second image building statement corresponding to the list of non-reusable image statements.

[0051] The present invention also provides a node mirroring optimization device, comprising:

[0052] The image setup script extraction module is used to obtain the node images of each node and extract the image setup scripts corresponding to the node images.

[0053] The module for obtaining duplicate image setup statements is used to retrieve duplicate image setup statements from the image setup scripts of all nodes.

[0054] A unified base image building module is used to build a unified base image using the repeated image building statement.

[0055] An optimization module is used to optimize the node image using the unified base image.

[0056] The present invention also provides an electronic device, the device comprising a processor and a memory:

[0057] The memory is used to store program code and transmit the program code to the processor;

[0058] The processor is used to execute the node image optimization method as described above, according to the instructions in the program code.

[0059] The present invention also provides a computer-readable storage medium for storing program code for executing the node mirroring optimization method as described in any of the preceding claims.

[0060] As can be seen from the above technical solutions, the present invention has the following advantages: The present invention discloses a node image optimization method, including: obtaining the node image of each node and extracting the image building script corresponding to the node image; obtaining the duplicate image building statements in the image building script of all nodes; building a unified base image using the duplicate image building statements; and optimizing the node image using the unified base image.

[0061] As shown in the above steps, this invention constructs a unified base image by extracting duplicate image construction statements from the node images of each node, and optimizes the node images of each node based on the unified base image. By reusing duplicate image construction statements, the total space occupied by the optimized node images of all nodes is reduced. Furthermore, because of the unified base image, when each node pulls an image, it does not need to pull the reusable image construction statements from that image and the unified base image, thereby reducing the time consumed when pulling images. Attached Figure Description

[0062] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0063] Figure 1 A flowchart illustrating the steps of a node mirroring optimization method provided in an embodiment of the present invention;

[0064] Figure 2 A flowchart illustrating the steps of a node mirroring optimization method according to another embodiment of the present invention;

[0065] Figure 3 This is a structural block diagram of a node mirroring optimization device provided in an embodiment of the present invention. Detailed Implementation

[0066] This invention provides a node image optimization method, apparatus, electronic device, and storage medium to solve the technical problems of existing node image building methods being unreusable, resulting in excessive total space usage, and excessive time consumption when pulling large training images.

[0067] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0068] Please see Figure 1 , Figure 1 The flowchart illustrates the steps of a node mirroring optimization method provided in this embodiment of the invention.

[0069] The present invention provides a method for building a node mirror, which may specifically include the following steps:

[0070] Step 101: Obtain the node image of each node and extract the image building script corresponding to the node image;

[0071] An image is a special file system. Besides providing the programs, libraries, and resource configurations required for container runtime, it also includes configuration parameters (such as environment variables) prepared for runtime. An image does not contain dynamic data, and its content remains unchanged after it is created. Essentially, it is the result of multiple image layers mounted sequentially, while the container's file system is a read-write environment added after the image is mounted in read-only mode.

[0072] An image is typically created from an image build script. Each statement in a Dockerfile corresponds to a layer of the image being built.

[0073] In this embodiment of the invention, the image building script for each node's image can be obtained through the official image command.

[0074] Step 102: Obtain duplicate image building statements in the image building scripts of all nodes;

[0075] In this embodiment of the invention, each image build script consists of multiple image build statements. A repeated image build statement refers to an image build statement that appears repeatedly in the image build scripts of all nodes.

[0076] In this embodiment of the invention, although each image build script is often built by individual engineers and cannot be directly reused, there may be image build statements with the same structure within each image build script. These structurally identical image build statements can often be reused in different image build scripts. Therefore, in this embodiment of the invention, duplicate image build statements can be selected from the image build scripts of all nodes as duplicate image build statements, serving as the basis for statement reuse during subsequent image builds.

[0077] Step 103: Build a unified base image using the repeated image building statement;

[0078] A unified base image is an image generated from duplicate image building statements found in the node images of all nodes. Because the unified base image stores these duplicate image building statements, it can serve as the foundation for building multiple images. By caching the unified base image, multiple images built upon it do not need to repeatedly fetch the unified base image, thus reducing the time spent fetching images.

[0079] Step 104: Optimize node images using a unified base image.

[0080] In this embodiment of the invention, the node images of each node can be regenerated based on a unified base image. Since there is a unified base image, the script building statements in the unified base image can be reused, thereby reducing the total number of image building statements in the node and thus reducing the total space occupied by the node images.

[0081] As shown in the above steps, this invention constructs a unified base image by extracting duplicate image construction statements from the node images of each node, and optimizes the node images of each node based on the unified base image. By reusing duplicate image construction statements, the total space occupied by the optimized node images of all nodes is reduced. Furthermore, because of the unified base image, when each node pulls an image, it does not need to pull the reusable image construction statements from that image and the unified base image, thereby reducing the time consumed when pulling images.

[0082] Please see Figure 2 , Figure 2 This is a flowchart illustrating the steps of a node mirroring optimization method according to another embodiment of the present invention. This embodiment further refines and supplements any of the above embodiments. Specifically, it may include the following steps:

[0083] Step 201: Obtain the node image of each node and extract the image building script corresponding to the node image;

[0084] Step 201 is the same as step 101. For details, please refer to the description of step 101. It will not be repeated here.

[0085] Step 202, create dictionary mapping;

[0086] In this embodiment of the invention, a dictionary mapping D can be created to count the frequency of each image building statement in all image building scripts. The initial value of D is empty.

[0087] Specifically, each image building statement can be used as the key, and the number of times the image building statement appears can be used as the value to generate key-value pairs and store them in a dictionary mapping D, so as to generate a dictionary mapping associated with all image building statements.

[0088] Step 203: Obtain the outdated image build script from the image build script;

[0089] Step 204: Determine the current image build script in the unupdated image build script;

[0090] Step 205: Obtain the first image building statement of the current image building script;

[0091] Step 206: Use the first mirror to build the statement to update the dictionary mapping, and obtain the updated dictionary mapping;

[0092] In the specific implementation, each unupdated image build script can be used as the current image build script in turn, and the first image build statement of the current image build script can be used to update the dictionary mapping to obtain the updated dictionary mapping with updated values ​​of duplicate image build statements.

[0093] In one example, step 206 may include the following sub-steps:

[0094] S11, Identify unmatched image building statements among all first image building statements;

[0095] S12, determine the current image building statement among the unmatched image building statements;

[0096] S13, Match the mapping relationship of the current image building statement in the dictionary mapping;

[0097] S14. If the match fails, the current image building statement is used as the key and 1 is used as the value to build a mapping relationship. The mapping relationship is then added to the dictionary mapping to obtain the updated dictionary mapping.

[0098] S15, if the match is successful, increment the value of the mapping relationship in the dictionary mapping by 1 to obtain the updated dictionary mapping;

[0099] S16, Determine if there is an unmatched image build statement;

[0100] S17, If yes, return to the step of determining the current image build statement in the unmatched image build statement;

[0101] S18, if not, output the updated dictionary mapping.

[0102] In the implementation, the first image building statement in the current image building script that does not match the dictionary mapping can be taken as the current image building statement. Then, the dictionary mapping is checked to see if a mapping relationship exists with the key of the current image building statement. If a match is found, it indicates that the current image building statement has appeared before, and the value of the mapping relationship corresponding to the current image building statement in the dictionary mapping is incremented by 1, indicating that the current image building statement has appeared again. If a match fails, it indicates that the current image building statement is appearing for the first time, and a new mapping relationship can be added to the dictionary mapping, with the current image building statement as the key and 1 as the value, to indicate that the current image building statement is appearing for the first time.

[0103] Then, the next first image building statement that has not yet matched the dictionary mapping is taken as the current image building statement, and the matching operation is repeated until all the first image building statements in the current image building script have matched the dictionary mapping. Then, the updated dictionary mapping is output.

[0104] Step 207: Determine if there is an outdated image setup script;

[0105] Step 208: If yes, return to the step of determining the current image build script in the unupdated image build script;

[0106] Step 209: If not, obtain the duplicate image building statements in the image building script of all nodes according to the updated dictionary mapping;

[0107] After completing the traversal of the current image build script, the next unmatched image build script is taken as the current image build script, and the above steps are repeated to update the dictionary mapping. The matching operation stops when all image build scripts have been matched, and duplicate image build statements are retrieved from the image build scripts of all nodes based on the final updated dictionary mapping.

[0108] In one example, step 209 may include: extracting the first mirror building statement with a value greater than 1 from the updated dictionary mapping, as a repeating mirror building statement.

[0109] After the entire update dictionary mapping is built, the first image building statement with a value greater than 1 can be extracted from the update dictionary mapping as the repeating image building statement.

[0110] Step 210: Build a unified base image using the repeated image building statement;

[0111] A unified base image is an image generated from duplicate image building statements found in the node images of all nodes. Because the unified base image stores these duplicate image building statements, it can serve as the foundation for building multiple images. By caching the unified base image, multiple images built upon it do not need to repeatedly fetch the unified base image, thus reducing the time spent fetching images.

[0112] Step 211: Optimize node images using a unified base image.

[0113] In this embodiment of the invention, the node images of each node can be regenerated based on a unified base image. Since there is a unified base image, the script building statements in the unified base image can be reused, thereby reducing the total number of image building statements in the node and thus reducing the total space occupied by the node images.

[0114] In one example, the steps of optimizing node images using a unified base image may include the following sub-steps:

[0115] S21, Obtain the image build script to be optimized from all image build scripts;

[0116] S22, Determine the current image build script to be optimized in the image build script to be optimized;

[0117] S23, obtain the second image building statement of the current image building script to be optimized;

[0118] S24, use the second image building statement and the unified base image to generate a list of non-reusable image statements;

[0119] In this embodiment of the invention, the non-reusable image statement list is used to store image script statements that do not appear in multiple image building scripts.

[0120] After generating a unified base image, each image build script to be optimized in the image build script can be used as the current image build script to be optimized, and the current image build script to be optimized can be optimized.

[0121] In the specific implementation, when optimizing the current image building script, the first step is to filter out the unreusable second image building statements in the current image building script using a unified base image, and then generate a list of unreusable image statements using the unreusable second image building statements.

[0122] In one example, the steps of generating a list of non-reusable image statements using a second image build statement and a unified base image may include:

[0123] S241, Traverse the second image building statements and determine in turn whether each second image building statement is in the unified base image;

[0124] S242, If so, obtain the first image layer number of the second image building statement in the current image building script to be optimized, and add the second image building statement and the corresponding first image layer number into the preset set;

[0125] S243, obtain the second image layer number of each second image build statement in the unified base image;

[0126] S244, Obtain the target image building statement with the same first image layer number and second image layer number from the second image building statement;

[0127] S245, Determine whether there is an initial image building statement with the first image layer number 1 in the target image building statement;

[0128] S246, If so, based on the first image layer number, obtain the consecutive image building statements containing the initial image building statement in the target image building statement, and count the number T of consecutive image statements;

[0129] S247, save the second image building statement that is not in the continuous image building statement in the list of non-reusable image statements.

[0130] In the specific implementation, the second image building statements can be traversed, and it can be determined whether there are statements in the unified base image that are the same as the second image building statements. If so, the first image layer number of the second image building statement that has the same statement as the unified base image in the current image building script to be optimized is obtained, and the second image building statement and the corresponding first image layer number are added to a preset set. This set records all the second image building statements in the current image building script to be optimized that exist in the unified base image.

[0131] Next, obtain the second image layer number of the second image building statement that exists in the unified base image, and extract the second image building statements with the same first image layer number and second image layer number as the target image building statements.

[0132] It should be noted that the purpose of extracting the target image building statements is that when replacing the target image building statements with statements from the unified base image that correspond to the target image statements for image building, the statements obtained from the unified base image are image building statements that are completely corresponding to the target image building statements in terms of hierarchy and content. Therefore, they should not affect the integrity of the original image script structure, and the order and content of the image building statements in the newly generated image building script should also be consistent with the original image script.

[0133] After obtaining the target image building statement, it can be determined whether an initial image building statement with a first image title of 1 exists within the target image building statement. If so, it indicates that the first layer of the current image building script to be optimized is the same as the first layer of the unified base image. At this point, based on the first image layer number, T consecutive image statements with the first image layer number can be obtained. These T consecutive image statements represent the portion of the unified base image that can be reused by the current image building statement to be optimized. The portion of the current image building statement to be optimized other than these T consecutive image statements is the non-reusable portion. This non-reusable portion of the image building statement is stored in the list of non-reusable image statements for use in subsequent node image optimization.

[0134] It should be noted that since the first and second image layer numbers of the target image building statement are the same, and the second image layer numbers of the T consecutive image statements with the first image layer number are also the same, the T consecutive image statements are also the T consecutive image statements starting from the first layer in the unified base image. Therefore, when reusing these T consecutive image statements, no additional image layers not present in the current image building statement to be optimized will be introduced.

[0135] S25, using the list of non-reusable image statements and the unified base image to generate the optimized image building script of the current image to be optimized, and using the optimized image building script to generate the optimized node image;

[0136] After obtaining the list of non-reusable image statements in the current image build script to be optimized, the list of non-reusable image statements and the unified base image can be used to generate an optimized image build script for the current image build script to be optimized, and the optimized image build script can be used to generate an optimized node image.

[0137] In one example, the steps of generating the optimization image build script from the list of non-reusable image statements and the unified base image may include:

[0138] S251, Obtain the first T duplicate image building statements from the unified base image;

[0139] S252, using the first T repeated image building statements and the second image building statement corresponding to the list of non-reusable image statements, generate the optimized image building script of the image building script to be optimized.

[0140] In this embodiment of the invention, the first T duplicate image building statements can be obtained from the unified base image cached in the node, and the second image building statement in the list of non-reusable image statements can be pulled to generate an optimized image building script for the image building script to be optimized.

[0141] Since the process of generating the optimized image build script only requires fetching the second image build statement from the list of non-reusable image statements, it has a lower time consumption compared to traditional image build methods. Furthermore, because the unified base image in the cache is reused during image generation, the number of image build statements used in all image build scripts to be optimized is reduced, thereby decreasing the overall space usage.

[0142] S26, Determine if there is an image build script to be optimized;

[0143] S27, If yes, return to the step of determining the current image build script in the image build script to be optimized;

[0144] S28, if not, output the optimized node mirrors of all nodes.

[0145] After optimizing the current image building script, you can continue to optimize other image building scripts that have not yet been optimized, until all image building scripts are optimized and the optimized node images of all nodes are output.

[0146] As shown in the above steps, this invention constructs a unified base image by extracting duplicate image construction statements from the node images of each node, and optimizes the node images of each node based on the unified base image. By reusing duplicate image construction statements, the total space occupied by the optimized node images of all nodes is reduced. Furthermore, because of the unified base image, when each node pulls an image, it does not need to pull the reusable image construction statements from that image and the unified base image, thereby reducing the time consumed when pulling images.

[0147] Please see Figure 3 , Figure 3 This is a structural block diagram of a node mirroring optimization device provided in an embodiment of the present invention.

[0148] This invention provides a node mirroring optimization device, comprising:

[0149] The image setup script extraction module 301 is used to obtain the node images of each node and extract the image setup scripts corresponding to the node images.

[0150] The module 302 for obtaining duplicate image building statements is used to obtain duplicate image building statements in the image building scripts of all nodes.

[0151] The unified base image building module 303 is used to build a unified base image using repeated image building statements.

[0152] Optimization module 304 is used to optimize node images using a unified base image.

[0153] In this embodiment of the invention, the repeating image building statement acquisition module 302 includes:

[0154] The dictionary mapping creation submodule is used to create dictionary mappings;

[0155] The "Unupdated Image Setup Script Acquisition" submodule is used to retrieve the unupdated image setup script from the image setup script.

[0156] The Current Image Setup Script Determination Submodule is used to determine the current image setup script when the image setup script has not been updated.

[0157] The first image build statement retrieval submodule is used to retrieve the first image build statement of the current image build script.

[0158] The dictionary mapping generation submodule is used to build the dictionary mapping using the first image and obtain the updated dictionary mapping.

[0159] The "Unupdated Image Setup Script Detection" submodule is used to determine whether an unupdated image setup script exists.

[0160] The first return submodule is used to return the steps for determining the current image build script in the case where the image build script has not been updated.

[0161] The "Repeated Image Building Statements" submodule is used to retrieve repeated image building statements from the image building scripts of all nodes, if not, based on the updated dictionary mapping.

[0162] In this embodiment of the invention, the dictionary mapping generation submodule includes:

[0163] The unit for determining unmatched image building statements is used to identify unmatched image building statements among all first image building statements.

[0164] The current image build statement determination unit is used to determine the current image build statement among unmatched image build statements;

[0165] The mapping relationship matching unit is used to match the mapping relationship of the current image building statement in the dictionary mapping;

[0166] The mapping relationship building unit is used to build a mapping relationship with the current image building statement as the key and 1 as the value if the match fails, and add the mapping relationship to the dictionary mapping to obtain the updated dictionary mapping;

[0167] The dictionary mapping generation unit is used to increment the value of the mapping relationship in the dictionary mapping by 1 if a match is successful, thus obtaining the updated dictionary mapping;

[0168] The unmatched image build statement judgment unit is used to determine whether an unmatched image build statement exists.

[0169] The return unit, if applicable, returns the step used to determine the current image build statement among the unmatched image build statements;

[0170] Update dictionary mapping output unit, used to output updated dictionary mapping if no.

[0171] In this embodiment of the invention, the repeating image building statement acquisition submodule includes:

[0172] The Repeated Mirror Building Statement Acquisition Unit is used to extract the first mirror building statement with a mapping value greater than 1 from the updated dictionary mapping, and use it as the repeated mirror building statement.

[0173] In this embodiment of the invention, the optimization module 304 includes:

[0174] The submodule for obtaining the build script of the image to be optimized is used to obtain the build script of the image to be optimized from all the build scripts of the image.

[0175] The "Current Optimized Image Building Script Determination" submodule is used to determine the current optimized image building script within the image building scripts.

[0176] The second image building statement acquisition submodule is used to obtain the second image building statement of the current image building script to be optimized.

[0177] The "Non-Reusable Image Statement List Generation Submodule" is used to generate a list of non-reusable image statements using the second image build statement and the unified base image.

[0178] The optimized node image generation submodule is used to generate an optimized image building script for the current image to be optimized using a list of non-reusable image statements and a unified base image, and to generate an optimized node image using the optimized image building script.

[0179] The submodule for determining the build script of the image to be optimized is used to determine whether a build script for the image to be optimized exists.

[0180] The second return submodule is used to return the steps in the image build script to be optimized that determine the current image build script if the condition is met.

[0181] The optimized node image output submodule is used to output optimized node images of all nodes if no other option is found.

[0182] In this embodiment of the invention, the non-reusable mirror statement list generation submodule includes:

[0183] The traversal judgment unit is used to traverse the second image building statements and determine whether each second image building statement is in the unified base image.

[0184] The first image layer number acquisition unit is used to, if so, acquire the first image layer number of the second image building statement in the current image building script to be optimized, and add the second image building statement and the corresponding first image layer number into a preset set;

[0185] The second image layer number acquisition unit is used to obtain the second image layer number of each second image building statement in the unified base image.

[0186] The target image building statement acquisition unit is used to obtain the target image building statement with the same first image layer number and second image layer number from the second image building statement;

[0187] The initial image building statement judgment unit is used to determine whether there is an initial image building statement with the first image layer number 1 in the target image building statement;

[0188] The continuous image building statement acquisition unit is used to, if so, based on the first image layer number, acquire the continuous image building statements containing the initial image building statement from the target image building statements, and count the number T of continuous image statements;

[0189] The save unit is used to save the second image build statement, which is not in the consecutive image build statement, in the list of non-reusable image statements.

[0190] In this embodiment of the invention, the optimized node image generation submodule includes:

[0191] The duplicate image build statement acquisition unit is used to retrieve the first T duplicate image build statements from the unified base image;

[0192] The optimized image build script building unit is used to generate an optimized image build script by taking the first T repeated image build statements and the second image build statement corresponding to the list of non-reusable image statements.

[0193] This invention also provides an electronic device, which includes a processor and a memory:

[0194] The memory is used to store program code and transfer the program code to the processor;

[0195] The processor is used to execute the node image optimization method of this embodiment of the invention according to the instructions in the program code.

[0196] This invention also provides a computer-readable storage medium for storing program code for executing the node image optimization method of this invention.

[0197] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0198] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0199] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0200] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0201] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0202] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0203] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0204] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0205] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for node mirror optimization, the method comprising: determining a node mirror configuration for a node mirror; and optimizing the node mirror configuration for the node mirror. include: Obtain the node image of each node, and extract the image building script corresponding to the node image; Retrieve duplicate image building statements in the image building scripts of all nodes; A unified base image is built using the aforementioned repeated image building statement; The node image is optimized using the unified base image. The step of optimizing the node image using the unified base image includes: Obtain the image build script to be optimized from all the image build scripts described; The current image build script to be optimized is determined in the image build script to be optimized. Obtain the second image building statement of the current image building script to be optimized; The second image building statement and the unified base image are used to generate a list of non-reusable image statements; The optimized image building script is generated using the non-reusable image statement list and the unified base image, and the optimized node image is generated using the optimized image building script. Determine if there are any image build scripts that need to be optimized; If so, return to the step of determining the current image build script in the image build script to be optimized; If not, output the optimized node images of all nodes; The step of generating a list of non-reusable image statements using the second image building statement and the unified base image includes: Iterate through the second image building statements and determine in turn whether each second image building statement is in the unified base image; If so, obtain the first image layer number of the second image building statement in the current image building script to be optimized, and add the second image building statement and the corresponding first image layer number into a preset set; Obtain the second image layer number of each second image build statement in the unified base image; Obtain the target image building statement whose first image layer number is the same as the second image layer number from the second image building statement; Determine whether there is an initial image building statement with a first image layer number of 1 in the target image building statement; If so, based on the first image layer number, obtain the consecutive image building statements containing the initial image building statement from the target image building statement, and count the number T of the consecutive image building statements; The second image building statement that is not in the continuous image building statement is saved in the list of non-reusable image statements.

2. The method of claim 1, wherein, The step of obtaining duplicate image building statements in the image building scripts of all nodes includes: Create a dictionary mapping; Obtain the outdated image setup script from the image setup script; Determine the current image build script from the unupdated image build script; Obtain the first image building statement of the current image building script; The dictionary mapping is updated using the first image building statement to obtain the updated dictionary mapping; Determine if there is an outdated image build script; If so, return to the step of determining the current image build script in the unupdated image build script; If not, obtain the duplicate image building statements in the image building scripts of all the nodes according to the updated dictionary mapping.

3. The method of claim 2, wherein, The step of updating the dictionary mapping using the first image construction statement to obtain the updated dictionary mapping includes: Identify any unmatched image building statements among all the first image building statements; The current image building statement is determined from the unmatched image building statements; Match the mapping relationship of the current image building statement in the dictionary mapping; If the match fails, a mapping relationship is constructed using the current image building statement as the key and 1 as the value, and the mapping relationship is added to the dictionary mapping to obtain the updated dictionary mapping; If a match is successful, the value of the mapping relationship in the dictionary mapping is incremented by 1 to obtain the updated dictionary mapping; Determine if there are any unmatched image build statements; If so, return to the step of determining the current image building statement among the unmatched image building statements; If not, output the updated dictionary mapping.

4. The method of claim 2, wherein, The step of obtaining duplicate image building statements in the image building scripts of all the nodes according to the updated dictionary mapping includes: The first image building statement with a value greater than 1 is extracted from the updated dictionary mapping and used as the repeated image building statement.

5. The method of claim 1, wherein, The step of generating the optimized image building script for the current image to be optimized using the list of non-reusable image statements and the unified base image includes: Obtain the first T duplicate image building statements from the unified base image; The optimized image building script is generated by using the first T repeated image building statements and the second image building statement corresponding to the list of non-reusable image statements.

6. A node mirror optimization apparatus, characterized by, include: The image setup script extraction module is used to obtain the node images of each node and extract the image setup scripts corresponding to the node images. The module for obtaining duplicate image setup statements is used to retrieve duplicate image setup statements from the image setup scripts of all nodes. A unified base image building module is used to build a unified base image using the repeated image building statement. An optimization module is used to optimize the node image using the unified base image; The optimization module includes: The submodule for obtaining the build script of the image to be optimized is used to obtain the build script of the image to be optimized from all the build scripts of the image. The "Current Optimized Image Building Script Determination" submodule is used to determine the current optimized image building script within the image building scripts. The second image building statement acquisition submodule is used to obtain the second image building statement of the current image building script to be optimized. The "Non-Reusable Image Statement List Generation Submodule" is used to generate a list of non-reusable image statements using the second image build statement and the unified base image. The optimized node image generation submodule is used to generate an optimized image building script for the current image to be optimized using a list of non-reusable image statements and a unified base image, and to generate an optimized node image using the optimized image building script. The submodule for determining the build script of the image to be optimized is used to determine whether a build script for the image to be optimized exists. The second return submodule is used to return the steps in the image build script to be optimized that determine the current image build script if the condition is met. The optimized node image output submodule is used to output optimized node images of all nodes if no other option is found. The submodule for generating a list of non-reusable mirror statements includes: The traversal judgment unit is used to traverse the second image building statements and determine whether each second image building statement is in the unified base image. The first image layer number acquisition unit is used to, if so, acquire the first image layer number of the second image building statement in the current image building script to be optimized, and add the second image building statement and the corresponding first image layer number into a preset set; The second image layer number acquisition unit is used to obtain the second image layer number of each second image building statement in the unified base image. The target image building statement acquisition unit is used to obtain the target image building statement with the same first image layer number and second image layer number from the second image building statement; The initial image building statement judgment unit is used to determine whether there is an initial image building statement with the first image layer number 1 in the target image building statement; The continuous image building statement acquisition unit is used to, if so, based on the first image layer number, acquire the continuous image building statements containing the initial image building statement in the target image building statement, and count the number T of continuous image building statements; The save unit is used to save the second image build statement, which is not in the consecutive image build statement, in the list of non-reusable image statements.

7. An electronic device, comprising: The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the node mirroring optimization method according to any one of claims 1-5 according to the instructions in the program code.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for executing the node mirroring optimization method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Mirror image processing method and device, electronic equipment and computer readable storage medium

    CN113934510A