Browse Source

[Feature]: nm-quick script tackling arm TODO support (#2488)

* domain flag for auto installs

* use static servers with custom domain (#2421)

* send delete peer update always

* fix add/remove host api calls

* keep mq updates in a single go func

* move branch test logic to devops (#2443)

* handle IOT OS

* save server name to env (#2460)

* ensure branch test servers available after test runs (#2467)

* save server name to env

* free server always; add PR to discord messages

* use correct method to delete droplets (#2468)

* quick fix for the launcher

* removed exit when triggering not supported exit and removed the TODO comments related to this issue

---------

Co-authored-by: Matthew R Kasun <[email protected]>
Co-authored-by: Alex Feiszli <[email protected]>
Co-authored-by: Christopher Blaha <[email protected]>
Co-authored-by: Abhishek Kondur <[email protected]>
Co-authored-by: Abhishek K <[email protected]>
bornav 2 years ago
parent
commit
7476da3368
2 changed files with 30 additions and 9 deletions
  1. 18 4
      .github/workflows/deletedroplets.yml
  2. 12 5
      scripts/nm-quick.sh

+ 18 - 4
.github/workflows/deletedroplets.yml

@@ -18,7 +18,13 @@ jobs:
           if_no_artifact_found: warn
           if_no_artifact_found: warn
       - name: get server name
       - name: get server name
         run: |
         run: |
-          echo "SERVER=$(cat ./server/server) >> $GITHUB_ENV"
+          echo "SERVER=$(cat ./server/server)" >> $GITHUB_ENV
+      - name: get PR
+        env:
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          echo "pull_request=$(gh api -H 'Accept: application/vnd.github+json' -H 'X-Github-Api-Version: 2022-11-28' \
+            /repos/${{ github.repository}}/actions/runs/${{ github.event.workflow_run.id }} | jq .pull_requests[0].number)" >> $GITHUB_ENV
       - name: discord success message
       - name: discord success message
         uses: appleboy/discord-action@master
         uses: appleboy/discord-action@master
         with:
         with:
@@ -32,7 +38,7 @@ jobs:
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
           sleep 15m
           sleep 15m
-          curl -X GET \
+          curl -X DELETE \
             -H "Content-Type: application/json" \
             -H "Content-Type: application/json" \
             -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
             -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
             "https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
             "https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
@@ -40,6 +46,7 @@ jobs:
           DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
           DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
           TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
           TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
       - name: mark server as available
       - name: mark server as available
+        if: success() || failure()
         uses: appleboy/ssh-action@master
         uses: appleboy/ssh-action@master
         with:
         with:
           host: server.${{ env.SERVER }}.clustercat.com
           host: server.${{ env.SERVER }}.clustercat.com
@@ -59,7 +66,13 @@ jobs:
           if_no_artifact_found: warn
           if_no_artifact_found: warn
       - name: get server name
       - name: get server name
         run: |
         run: |
-          echo "SERVER=$(cat ./server/server) >> $GITHUB_ENV"
+          echo "SERVER=$(cat ./server/server)" >> $GITHUB_ENV
+      - name: get PR
+        env:
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          echo "pull_request=$(gh api -H 'Accept: application/vnd.github+json' -H 'X-Github-Api-Version: 2022-11-28' \
+            /repos/${{ github.repository}}/actions/runs/${{ github.event.workflow_run.id }} | jq .pull_requests[0].number)" >> $GITHUB_ENV
       - name: discord failure message
       - name: discord failure message
         uses: appleboy/discord-action@master
         uses: appleboy/discord-action@master
         with:
         with:
@@ -82,7 +95,7 @@ jobs:
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
           sleep 3h
           sleep 3h
-          curl -X GET \
+          curl -X DELETE \
             -H "Content-Type: application/json" \
             -H "Content-Type: application/json" \
             -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
             -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
             "https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
             "https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
@@ -90,6 +103,7 @@ jobs:
           DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
           DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
           TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
           TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
       - name: mark server as available
       - name: mark server as available
+        if: success() || failure()
         uses: appleboy/ssh-action@master
         uses: appleboy/ssh-action@master
         with:
         with:
           host: server.${{ env.SERVER }}.clustercat.com
           host: server.${{ env.SERVER }}.clustercat.com

+ 12 - 5
scripts/nm-quick.sh

@@ -176,8 +176,7 @@ setup_netclient() {
 	netclient uninstall
 	netclient uninstall
 	set -e
 	set -e
 
 
-	# TODO arm support
-	wget -qO netclient https://github.com/gravitl/netclient/releases/download/$LATEST/netclient-linux-amd64
+	wget -qO netclient https://github.com/gravitl/netclient/releases/download/$LATEST/netclient-linux-$ARCH
 	chmod +x netclient
 	chmod +x netclient
 	./netclient install
 	./netclient install
 	echo "Register token: $TOKEN"
 	echo "Register token: $TOKEN"
@@ -227,8 +226,7 @@ configure_netclient() {
 # setup_nmctl - pulls nmctl and makes it executable
 # setup_nmctl - pulls nmctl and makes it executable
 setup_nmctl() {
 setup_nmctl() {
 
 
-	# TODO arm support
-	local URL="https://github.com/gravitl/netmaker/releases/download/$LATEST/nmctl-linux-amd64"
+	local URL="https://github.com/gravitl/netmaker/releases/download/$LATEST/nmctl-linux-$ARCH"
 	echo "Downloading nmctl..."
 	echo "Downloading nmctl..."
 	wget -qO /usr/bin/nmctl "$URL"
 	wget -qO /usr/bin/nmctl "$URL"
 
 
@@ -430,7 +428,16 @@ install_dependencies() {
 		#  ask the user to install manually and continue when ready
 		#  ask the user to install manually and continue when ready
 		exit 1
 		exit 1
 	fi
 	fi
-
+	# TODO add other supported architectures
+	ARCH=$(uname -m)
+    if [ "$ARCH" = "x86_64" ]; then
+    	ARCH=amd64
+    elif [ "$ARCH" = "aarch64" ]; then
+    	ARCH=arm64
+    else
+    	echo "Unsupported architechure"
+    	# exit 1
+    fi
 	set -- $dependencies
 	set -- $dependencies
 
 
 	${update_cmd}
 	${update_cmd}