mirror of
				https://github.com/DaoCloud/public-image-mirror.git
				synced 2025-11-04 16:57:22 +08:00 
			
		
		
		
	Support parallel differential tags
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/workflows/deep-sync-check.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/deep-sync-check.yml
									
									
									
									
										vendored
									
									
								
							@@ -18,6 +18,7 @@ jobs:
 | 
				
			|||||||
          INCREMENTAL: "true"
 | 
					          INCREMENTAL: "true"
 | 
				
			||||||
          DEBUG: "true"
 | 
					          DEBUG: "true"
 | 
				
			||||||
          QUICKLY: ""
 | 
					          QUICKLY: ""
 | 
				
			||||||
 | 
					          PARALLET: "10"
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          ./scripts/check-image.sh
 | 
					          ./scripts/check-image.sh
 | 
				
			||||||
      - name: Update badge
 | 
					      - name: Update badge
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ set -o pipefail
 | 
				
			|||||||
DEBUG="${DEBUG:-}"
 | 
					DEBUG="${DEBUG:-}"
 | 
				
			||||||
INCREMENTAL="${INCREMENTAL:-}"
 | 
					INCREMENTAL="${INCREMENTAL:-}"
 | 
				
			||||||
QUICKLY="${QUICKLY:-}"
 | 
					QUICKLY="${QUICKLY:-}"
 | 
				
			||||||
 | 
					PARALLET="${PARALLET:-0}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare -A DOMAIN_MAP=()
 | 
					declare -A DOMAIN_MAP=()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -45,7 +46,7 @@ done
 | 
				
			|||||||
LOGFILE="./check-image.log"
 | 
					LOGFILE="./check-image.log"
 | 
				
			||||||
echo >"${LOGFILE}"
 | 
					echo >"${LOGFILE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for line in $(cat ./mirror.txt); do
 | 
					for line in $(cat ./mirror.txt | shuf); do
 | 
				
			||||||
    line="${line/ /}"
 | 
					    line="${line/ /}"
 | 
				
			||||||
    if [[ "$line" == "" ]]; then
 | 
					    if [[ "$line" == "" ]]; then
 | 
				
			||||||
        continue
 | 
					        continue
 | 
				
			||||||
@@ -62,7 +63,7 @@ for line in $(cat ./mirror.txt); do
 | 
				
			|||||||
    domain="${line%%/*}"
 | 
					    domain="${line%%/*}"
 | 
				
			||||||
    new_image=$(echo "${line}" | sed "s/^${domain}/${DOMAIN_MAP["${domain}"]}/g")
 | 
					    new_image=$(echo "${line}" | sed "s/^${domain}/${DOMAIN_MAP["${domain}"]}/g")
 | 
				
			||||||
    echo "Diff image ${line} ${new_image}"
 | 
					    echo "Diff image ${line} ${new_image}"
 | 
				
			||||||
    DEBUG="${DEBUG}" QUICKLY="${QUICKLY}" INCREMENTAL="${INCREMENTAL}" EXCLUDED="${exclude}" ./scripts/diff-image.sh "${line}" "${new_image}" 2>&1 | tee -a "${LOGFILE}" || {
 | 
					    DEBUG="${DEBUG}" QUICKLY="${QUICKLY}" INCREMENTAL="${INCREMENTAL}" PARALLET="${PARALLET}" EXCLUDED="${exclude}" ./scripts/diff-image.sh "${line}" "${new_image}" 2>&1 | tee -a "${LOGFILE}" || {
 | 
				
			||||||
        echo "Error: diff image ${line} ${new_image}"
 | 
					        echo "Error: diff image ${line} ${new_image}"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,9 @@ QUICKLY="${QUICKLY:-}"
 | 
				
			|||||||
# Exclude tags that do not need to be checked
 | 
					# Exclude tags that do not need to be checked
 | 
				
			||||||
EXCLUDED="${EXCLUDED:-}"
 | 
					EXCLUDED="${EXCLUDED:-}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Compare the number of tags in parallel
 | 
				
			||||||
 | 
					PARALLET="${PARALLET:-0}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SELF="$(basename "${BASH_SOURCE[0]}")"
 | 
					SELF="$(basename "${BASH_SOURCE[0]}")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function check() {
 | 
					function check() {
 | 
				
			||||||
@@ -36,6 +39,7 @@ function check() {
 | 
				
			|||||||
        echo " INCREMENTAL=true   # Allow image2 to have more tags than image1"
 | 
					        echo " INCREMENTAL=true   # Allow image2 to have more tags than image1"
 | 
				
			||||||
        echo " QUICKLY=true       # Compare only tags that are in both images"
 | 
					        echo " QUICKLY=true       # Compare only tags that are in both images"
 | 
				
			||||||
        echo " EXCLUDED=<pattern> # Exclude tags that do not need to be checked"
 | 
					        echo " EXCLUDED=<pattern> # Exclude tags that do not need to be checked"
 | 
				
			||||||
 | 
					        echo " PARALLET=<size>    # Compare the number of tags in parallel"
 | 
				
			||||||
        return 2
 | 
					        return 2
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -204,6 +208,15 @@ function diff-image() {
 | 
				
			|||||||
    return 0
 | 
					    return 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function wait_jobs() {
 | 
				
			||||||
 | 
					    local job_num=${1:-3}
 | 
				
			||||||
 | 
					    local perc=$(jobs -p | wc -l)
 | 
				
			||||||
 | 
					    while [ "${perc}" -gt "${job_num}" ]; do
 | 
				
			||||||
 | 
					        sleep 1
 | 
				
			||||||
 | 
					        perc=$(jobs -p | wc -l)
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function main() {
 | 
					function main() {
 | 
				
			||||||
    local image1="${1:-}"
 | 
					    local image1="${1:-}"
 | 
				
			||||||
    local image2="${2:-}"
 | 
					    local image2="${2:-}"
 | 
				
			||||||
@@ -216,9 +229,17 @@ function main() {
 | 
				
			|||||||
    local list=$(diff-image "${image1}" "${image2}")
 | 
					    local list=$(diff-image "${image1}" "${image2}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local unsync=()
 | 
					    local unsync=()
 | 
				
			||||||
    for tag in ${list}; do
 | 
					    if [[ "${QUICKLY}" != "true" ]] || [[ "${PARALLET}" -eq 0 ]]; then
 | 
				
			||||||
        diff-image-with-tag "${image1}:${tag}" "${image2}:${tag}" >/dev/null || unsync+=("${tag}")
 | 
					        for tag in ${list}; do
 | 
				
			||||||
    done
 | 
					            diff-image-with-tag "${image1}:${tag}" "${image2}:${tag}" >/dev/null || unsync+=("${tag}")
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        for tag in ${list}; do
 | 
				
			||||||
 | 
					            wait_jobs "${PARALLET}"
 | 
				
			||||||
 | 
					            diff-image-with-tag "${image1}:${tag}" "${image2}:${tag}" >/dev/null || unsync+=("${tag}") &
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					        wait
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ "${#unsync[@]}" -gt 0 ]]; then
 | 
					    if [[ "${#unsync[@]}" -gt 0 ]]; then
 | 
				
			||||||
        echo "${SELF}: INFO: ${image1} and ${image2} are not in synchronized, there are unsynchronized tags ${#unsync[@]}: ${unsync[*]}" >&2
 | 
					        echo "${SELF}: INFO: ${image1} and ${image2} are not in synchronized, there are unsynchronized tags ${#unsync[@]}: ${unsync[*]}" >&2
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user