Skip to content

Commit

Permalink
PLTFRS-18353: Filter out non healthy on non in services instances fro…
Browse files Browse the repository at this point in the history
…m ASG
  • Loading branch information
bplessis-swi committed Sep 28, 2023
1 parent 9f6a790 commit 1c6579d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 77 deletions.
81 changes: 19 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,39 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Create Release
name: Build Release

on:
workflow_dispatch:
inputs:
snapshot:
description: 'is snapshot version?'
type: boolean
default: true
required: true
push:
branches:
- master
release:
types: [created]

permissions: read-all

jobs:
release:
permissions:
contents: write # To upload release assets.
actions: read # To read workflow path.

strategy:
matrix:
os: ['ubuntu-latest']
go-version: [1.18.x]

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:

-
name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
id: go

-
name: Compute release version
uses: AirVantage/github-actions/version-action@v37
id: get-version
with:
is-snapshot: ${{ github.event.inputs.snapshot == 'true' && '1' || '0' }}

-
name: GitHub Tag & Release
uses: AirVantage/github-actions/github-release-action@v37
id: create-release
with:
version: ${{ steps.get-version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: ${{ github.event.inputs.snapshot == 'true' && '1' || '0' }}


-
name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Fetch whole repository to get release tags
# See https://github.com/actions/checkout/issues/701
fetch-depth: 0

# Option B: split checkout + local tags ?
#-
# name: Tag local copy
# run: git tag ${{ steps.get-version.outputs.version }}

-
name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version-file: go.mod

-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand All @@ -72,19 +42,6 @@ jobs:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

-
name: Release on JIRA
if: github.event.inputs.snapshot == 'false'
continue-on-error: true # Useful if JIRA is down
uses: AirVantage/github-actions/tag-jira-action@v37
with:
version: ${{ steps.get-version.outputs.version }}
jira-url: ${{ secrets.JIRA_URL }}
jira-username: ${{ secrets.JIRA_USERNAME }}
jira-password: ${{ secrets.JIRA_PASSWORD }}
repo-name: ${{ github.event.repository.name }}
#env:
# # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
16 changes: 9 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']

go-version: [1.18.x]
go-arch: [ amd64 ]
go-arch: [ amd64, arm64 ]
go-os: [ linux ]

runs-on: ${{ matrix.os }}

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
id: go
go-version-file: go.mod

- id: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-file: go.mod

- name: Build
run: go build -o build/${{ github.event.repository.name }}-${{ matrix.go-os }}-${{ matrix.go-arch }} -v
env:
GOARCH: ${{ matrix.go-arch }}
GOOS: ${{ matrix.go-os }}

- name: Test
run: go test -v -cover -race -timeout 120s ./...
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module github.com/AirVantage/overlord

go 1.13
go 1.21

require (
github.com/BurntSushi/toml v0.3.1
github.com/aws/aws-sdk-go v1.31.9
github.com/BurntSushi/toml v1.3.2
github.com/aws/aws-sdk-go v1.45.18
)

require github.com/jmespath/go-jmespath v0.4.0 // indirect
12 changes: 7 additions & 5 deletions pkg/lookable/asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ func (asg AutoScalingGroup) LookupIPs(ipv6 bool) ([]string, error) {
return output, nil
}

// Make a list of instance ID
instances := make([]*string, numInstances)
for i, inst := range resp2.AutoScalingGroups[0].Instances {
instances[i] = inst.InstanceId
}
// Make a list of healthy instance ID in the ASG
instances := make([]*string, numInstances)
for i, inst := range resp2.AutoScalingGroups[0].Instances {
if (*inst.HealthStatus == "Healthy" && *inst.LifecycleState == "InService") {
instances[i] = inst.InstanceId
}
}

// Find running instances IP
params3 := &ec2.DescribeInstancesInput{
Expand Down

0 comments on commit 1c6579d

Please sign in to comment.