Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login to Docker Hub #2208

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 79 additions & 22 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Crystal Specs
on:
push:
paths:
branches:
- main
tags:
- '**'
- '!**.md'
- '!docs/*'
- '!doc-lint/*'
pull_request:
paths:
- '**'
Expand Down Expand Up @@ -61,6 +60,11 @@ jobs:
fail-fast: false
matrix: ${{fromJson(needs.tests.outputs.matrix)}}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cleanup Tmp DIR
run: |
sudo rm -rf /tmp/*
Expand Down Expand Up @@ -153,26 +157,23 @@ jobs:
- name: Run Crystal Spec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_USERNAMES: ${{ secrets.DOCKERHUB_USERNAMES }}
DOCKERHUB_PASSWORDS: ${{ secrets.DOCKERHUB_PASSWORDS }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_EMAIL: ${{ secrets.DOCKERHUB_EMAIL }}
IMAGE_REPO: ${{ secrets.IMAGE_REPO }}
run: |
USERNAME_ARRAY=($DOCKERHUB_USERNAMES)
PASSWORD_ARRAY=($DOCKERHUB_PASSWORDS)
EMAIL_ARRAY=($DOCKERHUB_EMAIL)
IMAGE_ARRAY=($IMAGE_REPO)

RANDOMIZER=$(( 0 + $RANDOM % 3 ))

export DOCKERHUB_USERNAME=${USERNAME_ARRAY[$RANDOMIZER]}
export DOCKERHUB_PASSWORD=${PASSWORD_ARRAY[$RANDOMIZER]}

export PROTECTED_DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME
export PROTECTED_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD
export PROTECTED_DOCKERHUB_EMAIL=${EMAIL_ARRAY[$RANDOMIZER]}
export PROTECTED_IMAGE_REPO=${IMAGE_ARRAY[$RANDOMIZER]}

echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

source cluster.env
export KUBECONFIG=$(pwd)/$CLUSTER.conf
until [[ $(kubectl get pods -l app=local-path-provisioner --namespace=local-path-storage -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') == "True" ]]; do
Expand All @@ -186,10 +187,13 @@ jobs:
#done
crystal build src/cnf-testsuite.cr
./cnf-testsuite setup

LOG_LEVEL=info crystal spec --warnings none --tag ${{ matrix.spec }} -v


echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
echo get ratelimit with a user account $DOCKERHUB_USERNAME
TOKEN=$(curl --user "$DOCKERHUB_USERNAME:$DOCKERHUB_PASSWORD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -200,6 +204,7 @@ jobs:
kubectl get all -A || true
kind delete cluster --name $CLUSTER --verbosity 1
continue-on-error: true

- name: upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
Expand All @@ -216,6 +221,11 @@ jobs:
matrix:
tag: ["pod_delete", "pod_io_stress", "pod_memory_hog", "pod_network_latency", "disk_fill", "pod_network_corruption", "pod_network_duplication", "zombie", "oran"]
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -274,14 +284,20 @@ jobs:
echo "RUNNER: $RUNNER_NAME"
- name: Run Crystal Spec
run: |
echo "Current path: $(echo pwd)"
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

source cluster.env
export KUBECONFIG=$(pwd)/$CLUSTER.conf
until [[ $(kubectl get pods -l app=kindnet --namespace=kube-system -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') == "True" ]]; do
echo "Waiting for kindnet"
sleep 1
done
LOG_LEVEL=info crystal spec --warnings none --tag ${{ matrix.tag }} -v
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -304,7 +320,12 @@ jobs:
runs-on: ubuntu-24.04
env:
CRYSTAL_IMAGE: "conformance/crystal:1.6.2-alpine"
steps:
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -332,7 +353,12 @@ jobs:
test_binary_configuration_lifecycle:
name: Test Binary Without Source(config_lifecycle)
runs-on: [v1.0.0]
steps:
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cleanup Tmp DIR
run: |
sudo rm -rf /tmp/*
Expand Down Expand Up @@ -383,6 +409,10 @@ jobs:
kubectl get nodes
- name: Run Test Suite without source(config_lifecycle)
run: |
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

source cluster.env
echo "SHARDS_INSTALL_PATH: $SHARDS_INSTALL_PATH"
export KUBECONFIG=/tmp/$CLUSTER.conf
Expand All @@ -396,6 +426,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~compatibility ~resilience ~reasonable_startup_time ~reasonable_image_size ~platform ~increase_capacity ~decrease_capacity ~install_script_helm ~helm_chart_valid ~helm_chart_published verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -416,7 +449,12 @@ jobs:
test_binary_microservice:
name: Test Binary Without Source(microservice)
runs-on: [v1.0.0]
steps:
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cleanup Tmp DIR
run: |
sudo rm -rf /tmp/*
Expand Down Expand Up @@ -464,6 +502,10 @@ jobs:
kubectl get nodes
- name: Run Test Suite without source(microservice)
run: |
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

source cluster.env
export KUBECONFIG=/tmp/$CLUSTER.conf
helm repo add stable https://cncf.gitlab.io/stable
Expand All @@ -476,6 +518,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~compatibility ~pod_network_latency ~platform ~increase_capacity ~decrease_capacity ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~install_script_helm ~helm_chart_valid ~helm_chart_published ~rollback ~secrets_used ~immutable_configmap verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -496,7 +541,12 @@ jobs:
test_binary_all:
name: Test Binary Without Source(all)
runs-on: [v1.0.0]
steps:
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cleanup Tmp DIR
run: |
sudo rm -rf /tmp/*
Expand Down Expand Up @@ -544,6 +594,10 @@ jobs:
kubectl get nodes
- name: Run Test Suite without source(all)
run: |
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

source cluster.env
export KUBECONFIG=/tmp/$CLUSTER.conf
helm repo add stable https://cncf.gitlab.io/stable
Expand All @@ -556,6 +610,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~platform ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~rollback ~secrets_used ~immutable_configmap ~reasonable_startup_time ~reasonable_image_size verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -577,7 +634,7 @@ jobs:
name: Publish Release
needs: [spec, build]
runs-on: ubuntu-24.04
steps:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.0
shards:
cluster_tools:
git: https://github.com/cnf-testsuite/cluster_tools.git
version: 1.0.7
version: 1.0.9

commander:
git: https://github.com/mrrooijen/commander.git
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies:
version: ~> 1.0.7
cluster_tools:
github: cnf-testsuite/cluster_tools
version: ~> 1.0.7
version: ~> 1.0.9
kernel_introspection:
github: cnf-testsuite/kernel_introspection
version: ~> 0.1.0
Expand Down
28 changes: 0 additions & 28 deletions src/tasks/platform/observability.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,6 @@ namespace "platform" do
end
end

def skopeo_sha_list(repo)
tags = skopeo_tags(repo)
Log.info { "sha_list tags: #{tags}" }

if tags
tags.as_a.reduce([] of Hash(String, String)) do |acc, i|
acc << {"name" => i.not_nil!.as_s, "manifest_digest" => skopeo_digest("#{repo}:#{i}").as_s}
end
end
end

def skopeo_digest(image)
ClusterTools.install
resp = ClusterTools.exec("skopeo inspect docker://#{image}")
Log.info { resp[:output] }
parsed_json = JSON.parse(resp[:output])
parsed_json["Digest"]
end

def skopeo_tags(repo)
ClusterTools.install
resp = ClusterTools.exec("skopeo list-tags docker://#{repo}")
Log.info { resp[:output] }
parsed_json = JSON.parse(resp[:output])
parsed_json["Tags"]
end


def named_sha_list(resp_json)
Log.debug { "sha_list resp_json: #{resp_json}" }
parsed_json = JSON.parse(resp_json)
Expand Down