From bdd6eaac120835b57737c4c00dfa414ef3386d96 Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Thu, 18 Jul 2024 07:18:22 -0700 Subject: [PATCH 1/8] Add get verifiers API Signed-off-by: Wade Barnes Signed-off-by: GuillaumeBourque-QC --- fetch-validator-status/rest_api.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fetch-validator-status/rest_api.py b/fetch-validator-status/rest_api.py index ea98cc2..7e63995 100644 --- a/fetch-validator-status/rest_api.py +++ b/fetch-validator-status/rest_api.py @@ -78,7 +78,7 @@ async def networks(): @app.get("/networks/{network}") async def network(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code."), - status: bool = Query(False, description="Filter results to status only."), + status: bool = Query(False, description="Filter results to status only."), alerts: bool = Query(False, description="Filter results to alerts only."), seed: Optional[str] = Header(None, description="Your network monitor seed.")): monitor_plugins = set_plugin_parameters(status, alerts) @@ -93,10 +93,18 @@ async def network(network: Network = Path(path=example_network_enum, example=exa result = await pool.get_transactions() return result +@app.get("/networks/{network}/pool/verifiers") +async def network(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code.")): + set_plugin_parameters() + pool, _ = await pool_collection.get_pool(network.value) + await pool.refresh() + result = await pool.get_verifiers() + return result + @app.get("/networks/{network}/{node}") async def node(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code."), node: str = Path(..., example="FoundationBuilder", description="The node name."), - status: bool = Query(False, description="Filter results to status only."), + status: bool = Query(False, description="Filter results to status only."), alerts: bool = Query(False, description="Filter results to alerts only."), seed: Optional[str] = Header(None, description="Your network monitor seed.")): monitor_plugins = set_plugin_parameters(status, alerts) @@ -107,4 +115,4 @@ async def node(network: Network = Path(path=example_network_enum, example=exampl print(error) raise HTTPException(status_code=400, detail=str(error)) - return result \ No newline at end of file + return result From eb2f44999a53c78d845e121b8eb29652a03e0db9 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Tue, 3 Sep 2024 11:44:31 -0400 Subject: [PATCH 2/8] Add a tmp directory Signed-off-by: GuillaumeBourque-QC --- fetch-validator-status/Dockerfile | 3 ++- fetch-validator-status/networks.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fetch-validator-status/Dockerfile b/fetch-validator-status/Dockerfile index adcb60e..ca80d17 100644 --- a/fetch-validator-status/Dockerfile +++ b/fetch-validator-status/Dockerfile @@ -45,12 +45,13 @@ RUN usermod -a -G root $user # Note: PIP_NO_CACHE_DIR environment variable should be cleared to allow caching RUN mkdir -p \ $HOME/log \ + $HOME/tmp \ $(python -m site --user-site) # The root group needs access the directories under $HOME for the container to function in OpenShift. # Also ensure the permissions on the python 'site-packages' folder are set correctly. RUN chown -R $user:root $HOME && \ - chmod -R ug+rw $HOME $HOME/log && \ + chmod -R ug+rw $HOME $HOME/log $HOME/tmp && \ chmod +rx $(python -m site --user-site) USER $user diff --git a/fetch-validator-status/networks.py b/fetch-validator-status/networks.py index d079d74..5a2669c 100644 --- a/fetch-validator-status/networks.py +++ b/fetch-validator-status/networks.py @@ -59,7 +59,7 @@ def get_NetworkEnum() -> NetworkEnum: def resolve(self, network_id: str = None, genesis_url: str = None, genesis_path: str = None): network_name = None - genesis_path_base = f"{self.__get_script_dir()}/" + genesis_path_base = f"{self.__get_script_dir()}/tmp/" if network_id and network_id in self.ids: log("Connecting to '{0}' ...".format(self.networks[network_id]["name"])) From b8606eca62009d52d87029a92007c576b6a1e882 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Tue, 3 Sep 2024 13:54:09 -0400 Subject: [PATCH 3/8] Replace tmp by cache to reflect the directory usage Signed-off-by: GuillaumeBourque-QC --- fetch-validator-status/Dockerfile | 4 ++-- fetch-validator-status/networks.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fetch-validator-status/Dockerfile b/fetch-validator-status/Dockerfile index ca80d17..764770b 100644 --- a/fetch-validator-status/Dockerfile +++ b/fetch-validator-status/Dockerfile @@ -45,13 +45,13 @@ RUN usermod -a -G root $user # Note: PIP_NO_CACHE_DIR environment variable should be cleared to allow caching RUN mkdir -p \ $HOME/log \ - $HOME/tmp \ + $HOME/cache \ $(python -m site --user-site) # The root group needs access the directories under $HOME for the container to function in OpenShift. # Also ensure the permissions on the python 'site-packages' folder are set correctly. RUN chown -R $user:root $HOME && \ - chmod -R ug+rw $HOME $HOME/log $HOME/tmp && \ + chmod -R ug+rw $HOME $HOME/log $HOME/cache && \ chmod +rx $(python -m site --user-site) USER $user diff --git a/fetch-validator-status/networks.py b/fetch-validator-status/networks.py index 5a2669c..2916ef7 100644 --- a/fetch-validator-status/networks.py +++ b/fetch-validator-status/networks.py @@ -59,7 +59,7 @@ def get_NetworkEnum() -> NetworkEnum: def resolve(self, network_id: str = None, genesis_url: str = None, genesis_path: str = None): network_name = None - genesis_path_base = f"{self.__get_script_dir()}/tmp/" + genesis_path_base = f"{self.__get_script_dir()}/cache/" if network_id and network_id in self.ids: log("Connecting to '{0}' ...".format(self.networks[network_id]["name"])) From e95c5dc415f96a32793999b30ab258b3e57dd151 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Thu, 17 Oct 2024 17:15:02 -0400 Subject: [PATCH 4/8] Add GitHub Actions workflow to publish Docker image Signed-off-by: GuillaumeBourque-QC --- .../workflows/build-indy-node-monitor.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/build-indy-node-monitor.yaml diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml new file mode 100644 index 0000000..4e4adcf --- /dev/null +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -0,0 +1,26 @@ +name: Publish Docker image + +on: + push: + branches: + - main + paths: + - 'fetch-validator-status/**' # Build only if their are changes in thos directory + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to GitHub Container Registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build the Docker image + run: docker build -t ghcr.io/${{ github.actor }}/REPOSITORY_NAME:${{ github.sha }} . + + - name: Push the Docker image + run: docker push ghcr.io/${{ github.actor }}/REPOSITORY_NAME:${{ github.sha }} + From c3e511431dc163ec381af1e953633a7ca15aa4b6 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Thu, 17 Oct 2024 17:38:50 -0400 Subject: [PATCH 5/8] Add GitHub Action correct repo name and tag Signed-off-by: GuillaumeBourque-QC --- .github/workflows/build-indy-node-monitor.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index 4e4adcf..c6b370f 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -18,9 +18,11 @@ jobs: - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Extract version from Git tag + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Build the Docker image - run: docker build -t ghcr.io/${{ github.actor }}/REPOSITORY_NAME:${{ github.sha }} . + run: docker build -t ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} . - name: Push the Docker image - run: docker push ghcr.io/${{ github.actor }}/REPOSITORY_NAME:${{ github.sha }} - + run: docker push ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} From d530a257ac229d3dcc37bbcca2abc34f320b588e Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Fri, 18 Oct 2024 18:13:06 -0400 Subject: [PATCH 6/8] Adapt workflow to build from a specific tag Signed-off-by: GuillaumeBourque-QC --- .../workflows/build-indy-node-monitor.yaml | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index c6b370f..fcd87a5 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -5,24 +5,48 @@ on: branches: - main paths: - - 'fetch-validator-status/**' # Build only if their are changes in thos directory + - 'fetch-validator-status/**' # Build only if their are changes in this directory + + workflow_dispatch: + inputs: + ref: + required: false + type: string + description: "This is the tag version number use to build and publish the container. Don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag version from the repo" jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository main + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags - - name: Log in to GitHub Container Registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Extract latest version from Git tag, excludind the v. + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" - - name: Extract version from Git tag - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Checkout repository specific tag + uses: actions/checkout@v4 + with: + ref: v${{ inputs.ref || env.LATEST_TAG }} + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set lowercase username + run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Build the Docker image - run: docker build -t ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} . + run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ - name: Push the Docker image - run: docker push ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/indy-node-monitor:${{ env.VERSION }} + run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} From acc8df92eb90c77b9a939a97f245eeab4d39a597 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Fri, 18 Oct 2024 18:13:06 -0400 Subject: [PATCH 7/8] Adapt workflow to build from a specific tag --- .../workflows/build-indy-node-monitor.yaml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index fcd87a5..0d75dcb 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -12,7 +12,7 @@ on: ref: required: false type: string - description: "This is the tag version number use to build and publish the container. Don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag version from the repo" + description: "This is the tag version, don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag" jobs: build: @@ -42,11 +42,38 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set lowercase username + run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Checkout repository main + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags + + - name: Extract latest version from Git tag, excludind the v. + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" + + - name: Checkout repository specific tag + uses: actions/checkout@v4 + with: + ref: v${{ inputs.ref || env.LATEST_TAG }} + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set lowercase username run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Build the Docker image run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ + run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ - name: Push the Docker image run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} + run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} From cf4c43dba1824534d93d5247a98702a4abfa4ea0 Mon Sep 17 00:00:00 2001 From: GuillaumeBourque-QC Date: Fri, 18 Oct 2024 18:35:03 -0400 Subject: [PATCH 8/8] Adapt workflow to build from a specific tag and sign the commit Signed-off-by: GuillaumeBourque-QC --- .github/workflows/build-indy-node-monitor.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml index 0d75dcb..fbd9c43 100644 --- a/.github/workflows/build-indy-node-monitor.yaml +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -72,8 +72,6 @@ jobs: - name: Build the Docker image run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ - run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ - name: Push the Docker image run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} - run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }}