From 204d8d93bdf6032e23ccb0bcb084556dc5a505db Mon Sep 17 00:00:00 2001 From: Chou Hu Date: Wed, 29 May 2024 14:23:55 +0800 Subject: [PATCH] cleanup: delete unused files (#4444) --- .../.builder-Marketplace-win-template.yaml | 37 -------- Makefile | 1 - test.mk | 30 ------ .../new-sku-and-add-image-version.sh | 92 ------------------- .../publish/Marketplace/sku-template.json | 41 --------- vhdbuilder/publish/cleanup.sh | 8 -- vhdbuilder/publish/prepare-sig.sh | 59 ------------ vhdbuilder/publish/sig-version-create.sh | 43 --------- vhdbuilder/publish/sig-version-scale.sh | 19 ---- 9 files changed, 330 deletions(-) delete mode 100644 .pipelines/templates/.builder-Marketplace-win-template.yaml delete mode 100644 test.mk delete mode 100755 vhdbuilder/publish/Marketplace/new-sku-and-add-image-version.sh delete mode 100644 vhdbuilder/publish/Marketplace/sku-template.json delete mode 100755 vhdbuilder/publish/cleanup.sh delete mode 100755 vhdbuilder/publish/prepare-sig.sh delete mode 100755 vhdbuilder/publish/sig-version-create.sh delete mode 100644 vhdbuilder/publish/sig-version-scale.sh diff --git a/.pipelines/templates/.builder-Marketplace-win-template.yaml b/.pipelines/templates/.builder-Marketplace-win-template.yaml deleted file mode 100644 index 7c188b47317..00000000000 --- a/.pipelines/templates/.builder-Marketplace-win-template.yaml +++ /dev/null @@ -1,37 +0,0 @@ -steps: - - task: DownloadPipelineArtifact@2 - displayName: Download VHD publishing info - inputs: - source: 'specific' - path: artifacts/vhd - project: 'CloudNativeCompute' - pipeline: $(VHD_PIPELINE_ID) - runVersion: 'specific' - runId: $(VHD_PIPELINE_RUN_ID) - - script: | - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - ${CONTAINER_IMAGE} make bootstrap - displayName: Setup tools - - script: | - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e AZURE_TENANT_ID=${AZURE_TENANT_ID} \ - -e AZURE_CLIENT_ID=${AZURE_CLIENT_ID} \ - -e AZURE_CLIENT_SECRET="$(AZURE_CLIENT_SECRET)" \ - -e SKU_PREFIX=${SKU_PREFIX} \ - -e SKU_TEMPLATE_FILE=${SKU_TEMPLATE_FILE} \ - -e PUBLISHER=${PUBLISHER} \ - -e OFFER=${OFFER} \ - -e CONTAINER_RUNTIME=${CONTAINER_RUNTIME} \ - ${CONTAINER_IMAGE} ./vhdbuilder/publish/Marketplace/new-sku-and-add-image-version.sh - displayName: Create a new marketplace SKU - - script: | - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - ${CONTAINER_IMAGE} make tools-clean - displayName: cleanup - clean hack/tools/bin - condition: always() diff --git a/Makefile b/Makefile index 33523370e55..d15348f03f9 100644 --- a/Makefile +++ b/Makefile @@ -208,4 +208,3 @@ unit-tests: $(GO) test `go list ./... | grep -v e2e` -coverprofile coverage_raw.out -covermode count include versioning.mk -include test.mk diff --git a/test.mk b/test.mk deleted file mode 100644 index c50a05ff689..00000000000 --- a/test.mk +++ /dev/null @@ -1,30 +0,0 @@ -LOCATION ?= westus2 -CLUSTER_DEFINITION ?= examples/kubernetes.json -SSH_KEY_NAME ?= id_rsa -SKIP_TEST ?= false - -TEST_CMD = docker run --rm \ - -v ${CURDIR}:${DEV_ENV_WORK_DIR} \ - -w ${DEV_ENV_WORK_DIR} \ - -e LOCATION=${LOCATION} \ - -e CLIENT_ID=${CLIENT_ID} \ - -e CLIENT_SECRET=${CLIENT_SECRET} \ - -e TENANT_ID=${TENANT_ID} \ - -e SUBSCRIPTION_ID=${SUBSCRIPTION_ID} \ - -e CLUSTER_DEFINITION=${CLUSTER_DEFINITION} \ - -e DNS_PREFIX=${DNS_PREFIX} \ - -e SSH_KEY_NAME=${SSH_KEY_NAME} \ - -e SKIP_TEST=${SKIP_TEST} - -test-interactive: - ${TEST_CMD} -it -e TEST=kubernetes ${DEV_ENV_IMAGE} bash - -test-functional: test-kubernetes - -test-kubernetes: - make -C ./test/e2e build - @ORCHESTRATOR=kubernetes bash -c 'pgrep ssh-agent || eval `ssh-agent` && ./test/e2e/bin/e2e-runner' - -test-azure-constants: - ./scripts/azure-const.sh - diff --git a/vhdbuilder/publish/Marketplace/new-sku-and-add-image-version.sh b/vhdbuilder/publish/Marketplace/new-sku-and-add-image-version.sh deleted file mode 100755 index e6017d6d331..00000000000 --- a/vhdbuilder/publish/Marketplace/new-sku-and-add-image-version.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -xeu - -required_env_vars=( - "SKU_PREFIX" - "SKU_TEMPLATE_FILE" - "AZURE_TENANT_ID" - "AZURE_CLIENT_ID" - "AZURE_CLIENT_SECRET" - "PUBLISHER" - "OFFER" - "CONTAINER_RUNTIME" -) - -for v in "${required_env_vars[@]}" -do - if [ -z "${!v}" ]; then - echo "$v was not set!" - exit 1 - fi -done - -if [ ! -f "$SKU_TEMPLATE_FILE" ]; then - echo "Could not find sku template file: ${SKU_TEMPLATE_FILE}!" - exit 1 -fi - -# we use token as a workaround even after a successful login as a result of pub tool Authorization failure. -# allow-no-subscriptions is safe because we have no sub-level operations -echo "Get cloudpartner access token" -az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID --allow-no-subscriptions -token=$(az account get-access-token --resource https://cloudpartner.azure.com --query "accessToken" -o tsv) -export AZURE_TOKEN=$token - -ls -lhR artifacts -vhd_artifacts_path="publishing-info-2019" -if [[ ${CONTAINER_RUNTIME} = "containerd" ]]; then - vhd_artifacts_path="publishing-info-2019-containerd" -fi -VHD_INFO="artifacts/vhd/${vhd_artifacts_path}/vhd-publishing-info.json" -if [ ! -f "$VHD_INFO" ]; then - echo "Could not find VHD info file: ${VHD_INFO}!" - exit 1 -fi - -short_date=$(date +"%y%m") -pretty_date=$(date +"%b %Y") -sku_id="${SKU_PREFIX}-${short_date}" -echo "Checking if offer contains SKU: $sku_id" -# Check if SKU already exists in offer -(set -x; hack/tools/bin/pub skus list -p $PUBLISHER -o $OFFER | jq ".[] | .planId" | tr -d '"' | tee skus.txt) -echo "" -if grep -q $sku_id skus.txt; then - echo "Offer already has SKU" -else - echo "Creating new SKU" - < $SKU_TEMPLATE_FILE sed s/{{ID}}/"$sku_id"/ | sed s/{{MONTH-YEAR}}/"$pretty_date/" | sed s/{{CONTAINER_RUNTIME}}/"$CONTAINER_RUNTIME/" > sku.json - echo "" ; cat sku.json ; echo "" - hack/tools/bin/pub skus put -p $PUBLISHER -o $OFFER -f sku.json ; echo "" -fi - -echo "Vhd publishing info:" -cat $VHD_INFO -echo - -# Get VHD version info for vhd-publishing-info.json produced by previous pipeline stage -vhd_url=$(< $VHD_INFO jq -r ".vhd_url") -redact_vhd_url=${vhd_url/\?*/?***} -image_version=$(< $VHD_INFO jq -r ".image_version") - -# generate media name -# Media name must be under 63 characters -media_name="${SKU_PREFIX}-${image_version}" -if [ "${#media_name}" -ge 63 ]; then - echo "$media_name should be undr 63 characters" - exit 1 -fi - -published_date=$(date +"%m/%d/%Y") -published_image_label="AKS Base Image for Windows" -published_image_description="AKS Base Image for Windows" -echo "publish image version to Marketplace" -echo "pubilsher: $PUBLISHER" -echo "offer: $OFFER" -echo "sku id: $sku_id" -echo "image version: $image_version" -echo "vhd url: $redact_vhd_url" -echo "media name: $media_name" -echo "published date: $published_date" -echo "image label: $published_image_label" -echo "image description: $published_image_description" -echo "" -set -x ; hack/tools/bin/pub versions put corevm -p $PUBLISHER -o $OFFER -s $sku_id --version $image_version --vhd-uri $vhd_url --media-name $media_name --label "AKS Base Image for Windows" --desc "AKS Base Image for Windows" --published-date "$published_date" \ No newline at end of file diff --git a/vhdbuilder/publish/Marketplace/sku-template.json b/vhdbuilder/publish/Marketplace/sku-template.json deleted file mode 100644 index 32ce6f7646f..00000000000 --- a/vhdbuilder/publish/Marketplace/sku-template.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "planId": "{{ID}}", - "microsoft-azure-corevm.skuTitle": "AKS Windows K8s base image - {{CONTAINER_RUNTIME}}, {{MONTH-YEAR}}", - "microsoft-azure-corevm.skuSummary": "AKS Windows K8s base image - {{CONTAINER_RUNTIME}}, {{MONTH-YEAR}}", - "microsoft-azure-corevm.skuLongSummary": "AKS Windows K8s base image - {{CONTAINER_RUNTIME}}, {{MONTH-YEAR}}", - "microsoft-azure-corevm.hideSKUForSolutionTemplate": true, - "microsoft-azure-corevm.hardened": false, - "microsoft-azure-corevm.deploymentModels": [ - "ARM" - ], - "microsoft-azure-corevm.cloudAvailability": [ - "PublicAzure", - "Mooncake", - "Fairfax" - ], - "microsoft-azure-corevm.imageType": "VmImage", - "microsoft-azure-corevm.imageVisibility": true, - "microsoft-azure-corevm.generation": "1", - "microsoft-azure-corevm.operatingSystemFamily": "Windows", - "microsoft-azure-corevm.osType": "Other", - "microsoft-azure-corevm.supportsHubOnOffSwitch": false, - "microsoft-azure-corevm.supportsClientHub": false, - "microsoft-azure-corevm.isPremiumThirdParty": false, - "microsoft-azure-corevm.supportsHub": false, - "microsoft-azure-corevm.supportsBackup": false, - "microsoft-azure-corevm.freeTierEligible": true, - "microsoft-azure-corevm.supportsSriov": false, - "microsoft-azure-corevm.supportsAADLogin": false, - "microsoft-azure-corevm.defaultImageSizeGB": "30", - "microsoft-azure-corevm.vmImagesPublicAzure": {}, - "microsoft-azure-corevm.skuDescriptionPublicAzure": "Windows Base Image for Azure Kubernetes", - "microsoft-azure-corevm.skuDescriptionFairfax": "Windows Base Image for Azure Kubernetes", - "microsoft-azure-corevm.skuDescriptionMooncake": "Windows Base Image for Azure Kubernetes", - "microsoft-azure-corevm.smallLogo": "https://azcupublogos.blob.core.windows.net/publishing-logos/small.png", - "microsoft-azure-corevm.mediumLogo": "https://azcupublogos.blob.core.windows.net/publishing-logos/medium.png", - "microsoft-azure-corevm.largeLogo": "https://azcupublogos.blob.core.windows.net/publishing-logos/large.png", - "microsoft-azure-corevm.wideLogo": "https://azcupublogos.blob.core.windows.net/publishing-logos/large.png", - "microsoft-azure-corevm.privacyURL": "https://github.com/Azure/aks-engine/blob/master/LICENSE", - "microsoft-azure-corevm.termsOfUseURL": "https://github.com/Azure/aks-engine/blob/master/LICENSE", - "microsoft-azure-corevm.migratedOffer": false -} \ No newline at end of file diff --git a/vhdbuilder/publish/cleanup.sh b/vhdbuilder/publish/cleanup.sh deleted file mode 100755 index c6b3cf85333..00000000000 --- a/vhdbuilder/publish/cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -[[ -z "${MANAGED_IMAGE_NAME}" ]] && echo "MANAGED_IMAGE_NAME is not set" && exit 1 -[[ -z "${MANAGED_IMAGE_RG_NAME}" ]] && echo "MANAGED_IMAGE_RG_NAME is not set" && exit 1 - -echo "Deleting managed image ${MANAGED_IMAGE_NAME}, from resource group ${MANAGED_IMAGE_RG_NAME}" -az image delete \ - --resource-group ${MANAGED_IMAGE_RG_NAME} \ - --name ${MANAGED_IMAGE_NAME} \ No newline at end of file diff --git a/vhdbuilder/publish/prepare-sig.sh b/vhdbuilder/publish/prepare-sig.sh deleted file mode 100755 index 50a0729f664..00000000000 --- a/vhdbuilder/publish/prepare-sig.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Create the necessary infrastructure if it doesn't exist, so that we can publish the SIG image version -[[ -z "${CLIENT_ID}" ]] && echo "CLIENT_ID is not set" && exit 1 -[[ -z "${CLIENT_SECRET}" ]] && echo "CLIENT_SECRET is not set" && exit 1 -[[ -z "${TENANT_ID}" ]] && echo "TENANT_ID is not set" && exit 1 -[[ -z "${SUBSCRIPTION_ID}" ]] && echo "SUBSCRIPTION_ID is not set" && exit 1 -[[ -z "${REGION}" ]] && echo "REGION is not set" && exit 1 - -[[ -z "${RG_NAME}" ]] && echo "RG_NAME is not set" && exit 1 -[[ -z "${OS_NAME}" ]] && echo "OS_NAME is not set" && exit 1 -[[ -z "${GALLERY_NAME}" ]] && echo "GALLERY_NAME is not set" && exit 1 -[[ -z "${IMAGEDEFINITION_NAME}" ]] && echo "IMAGEDEFINITION_NAME is not set" && exit 1 -[[ -z "${HYPERV_GENERATION}" ]] && echo "HYPERV_GENERATION is not set" && exit 1 - -echo "az login --service-principal -u ${CLIENT_ID} -p *** --tenant ${TENANT_ID}" -az login --service-principal -u ${CLIENT_ID} -p ${CLIENT_SECRET} --tenant ${TENANT_ID} - -echo "az account set --subscription ${SUBSCRIPTION_ID}" -az account set --subscription ${SUBSCRIPTION_ID} - - echo "Check if Resource Group exists, if not create it" - id=$(az group show --name ${RG_NAME}) - if [ -z "$id" ] ; then - echo "Creating resource group ${RG_NAME} in ${REGION} region" - az group create --name ${RG_NAME} --location ${REGION} - fi - - echo "Check if Shared Image Gallery exists, if not create it" - id=$(az sig show --resource-group ${RG_NAME} --gallery-name ${GALLERY_NAME}) - if [ -z "$id" ]; then - echo "Creating Shared Image Gallery ${GALLERY_NAME} in the resource group ${RG_NAME}" - az sig create --resource-group ${RG_NAME} --gallery-name ${GALLERY_NAME} --location ${REGION} - fi - - echo "Check if SIG imagedefnition exists, if not create it" - id=$(az sig image-definition show \ - --resource-group ${RG_NAME} \ - --gallery-name ${GALLERY_NAME} \ - --gallery-image-definition ${IMAGEDEFINITION_NAME}) - if [ -z "$id" ]; then - echo "Creating image definition ${IMAGEDEFINITION_NAME} generation ${HYPERV_GENERATION} in Shared Image Gallery ${GALLERY_NAME} inside the resource group ${RG_NAME}" - az sig image-definition create \ - --resource-group ${RG_NAME} \ - --gallery-name ${GALLERY_NAME} \ - --gallery-image-definition ${IMAGEDEFINITION_NAME} \ - --publisher microsoft-aks \ - --offer ${GALLERY_NAME} \ - --sku ${IMAGEDEFINITION_NAME} \ - --os-type ${OS_NAME} \ - --location ${REGION} \ - --hyper-v-generation ${HYPERV_GENERATION} - fi - -echo "##vso[task.setvariable variable=RG_NAME;]$RG_NAME" -echo "##vso[task.setvariable variable=GALLERY_NAME;]$GALLERY_NAME" -echo "##vso[task.setvariable variable=IMAGEDEFINITION_NAME;]$IMAGEDEFINITION_NAME" - -echo "##vso[task.setvariable variable=OS_NAME;]$OS_NAME" diff --git a/vhdbuilder/publish/sig-version-create.sh b/vhdbuilder/publish/sig-version-create.sh deleted file mode 100755 index f888120c2cc..00000000000 --- a/vhdbuilder/publish/sig-version-create.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# Create managed Image from VHD sas url and then publish the managed image into the already created shared image gallery - -[[ -z "${REGION}" ]] && echo "REGION is not set" && exit 1 -[[ -z "${RG_NAME}" ]] && echo "RG_NAME is not set" && exit 1 -[[ -z "${GALLERY_NAME}" ]] && echo "GALLERY_NAME is not set" && exit 1 -[[ -z "${IMAGEDEFINITION_NAME}" ]] && echo "IMAGEDEFINITION_NAME is not set" && exit 1 -[[ -z "${IMAGE_VERSION}" ]] && echo "IMAGE_VERSION is not set" && exit 1 -#TARGET_REGIONS must be set in the following format region=replicacount "westus2=1 eastus=4 uksouth=3" -[[ -z "${TARGET_CREATE_REGIONS}" ]] && echo "TARGET_CREATE_REGIONS is not set" && exit 1 -[[ -z "${MANAGED_IMAGE_RG_NAME}" ]] && echo "MANAGED_IMAGE_RG_NAME is not set" && exit 1 -[[ -z "${VHD_SOURCE}" ]] && echo "VHD_SOURCE is not set" && exit 1 -[[ -z "${OS_NAME}" ]] && echo "OS_NAME is not set" && exit 1 -[[ -z "${HYPERV_GENERATION}" ]] && echo "HYPERV_GENERATION is not set" && exit 1 - -MANAGED_IMAGE_NAME="MI_${REGION}_${GALLERY_NAME}_${IMAGEDEFINITION_NAME}_${IMAGE_VERSION}" - -# TODO(qinhao): change image version pattern of Windows to ${WINDOWS_VERSION}.$(date +"%y%m%d"), e.g. 17763.1457.200909, -# in which, WINDOWS_VERSION can be obtained from vhd-publishing-info.json in VHD building artifacts - -echo "Creating managed image ${MANAGED_IMAGE_NAME} from VHD, inside resource group ${MANAGED_IMAGE_RG_NAME}" -create_managed_image_command="az image create --resource-group ${MANAGED_IMAGE_RG_NAME} --name ${MANAGED_IMAGE_NAME} --os-type ${OS_NAME} --hyper-v-generation ${HYPERV_GENERATION} --source ${VHD_SOURCE}" -eval $create_managed_image_command - -echo "Get managed image URI for the managed image ${MANAGED_IMAGE_NAME}" -sleep 1m -MANAGED_IMAGE_URI=$(az image show --resource-group ${MANAGED_IMAGE_RG_NAME} --name ${MANAGED_IMAGE_NAME} -o json | jq -r ".id") - -echo "publishing managed image to /resourcegroup/${RG_NAME}/galleries/${GALLERY_NAME}/images/${IMAGEDEFINITION_NAME}/versions/${IMAGE_VERSION} with 5 replcia count in ${TARGET_CREATE_REGIONS}" - - az sig image-version create \ - --resource-group ${RG_NAME} \ - --gallery-name ${GALLERY_NAME} \ - --gallery-image-definition ${IMAGEDEFINITION_NAME} \ - --gallery-image-version ${IMAGE_VERSION} \ - --managed-image "${MANAGED_IMAGE_URI}" \ - --target-regions ${TARGET_CREATE_REGIONS} \ - --storage-account-type Premium_LRS \ - --replica-count 5 - - -echo "##vso[task.setvariable variable=MANAGED_IMAGE_NAME;]$MANAGED_IMAGE_NAME" \ No newline at end of file diff --git a/vhdbuilder/publish/sig-version-scale.sh b/vhdbuilder/publish/sig-version-scale.sh deleted file mode 100644 index 35d4e3ad3c0..00000000000 --- a/vhdbuilder/publish/sig-version-scale.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Create managed Image from VHD sas url and then publish the managed image into the already created shared image gallery - -[[ -z "${RG_NAME}" ]] && echo "RG_NAME is not set" && exit 1 -[[ -z "${GALLERY_NAME}" ]] && echo "GALLERY_NAME is not set" && exit 1 -[[ -z "${IMAGEDEFINITION_NAME}" ]] && echo "IMAGEDEFINITION_NAME is not set" && exit 1 -[[ -z "${IMAGE_VERSION}" ]] && echo "IMAGE_VERSION is not set" && exit 1 -#TARGET_REGIONS must be set in the following format region=replicacount "westus2=1 eastus=4 uksouth=3" -[[ -z "${TARGET_REGIONS}" ]] && echo "TARGET_REGIONS is not set" && exit 1 - -echo "scaling the image version /resourcegroup/${RG_NAME}/galleries/${GALLERY_NAME}/images/${IMAGEDEFINITION_NAME}/versions/${IMAGE_VERSION} as follows ${TARGET_REGIONS}" - - az sig image-version update \ - --resource-group ${RG_NAME} \ - --gallery-name ${GALLERY_NAME} \ - --gallery-image-definition ${IMAGEDEFINITION_NAME} \ - --gallery-image-version ${IMAGE_VERSION} \ - --target-regions ${TARGET_REGIONS} \