Skip to content

Commit

Permalink
Configure GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dippynark committed Dec 27, 2023
1 parent b66a096 commit f41bbc7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# https://docs.docker.com/build/ci/github-actions/multi-platform/
name: ci
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate tag
run: |
set -euo pipefail
# https://github.com/github/docs/issues/15319#issuecomment-1662257301
echo TAG="${{ github.event.pull_request && github.head_ref || github.ref_name }}"
if [ "$TAG" = "main" ]; then
TAG=latest
fi
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:${{ env.TAG }}
7 changes: 4 additions & 3 deletions pkg/controller/spot_migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (sm *SpotMigrator) Start(ctx context.Context) error {
}
}

// run runs spot migration
func (sm *SpotMigrator) run(ctx context.Context) error {
logger := log.FromContext(ctx)
for {
Expand Down Expand Up @@ -162,7 +163,7 @@ func (sm *SpotMigrator) run(ctx context.Context) error {
// If any on-demand Nodes were created while draining then we assume that there are no more
// spot VMs available and that spot migration is complete
if nodeCreated(beforeDrainOnDemandNodes, afterDrainOnDemandNodes) {
logger.Info("Node was created while draining")
logger.Info("Spot migration complete")
return nil
}
}
Expand All @@ -187,7 +188,7 @@ func (sm *SpotMigrator) listOnDemandNodes(ctx context.Context) ([]*corev1.Node,
return onDemandNodes, nil
}

// drainNode drains the specified Node and deletes the underlying instance
// drainAndDeleteNode drains the specified Node and deletes the underlying instance
func (sm *SpotMigrator) drainAndDeleteNode(ctx context.Context, node *corev1.Node) error {
logger := log.FromContext(ctx, "node", node.Name)

Expand Down Expand Up @@ -215,7 +216,7 @@ func (sm *SpotMigrator) drainAndDeleteNode(ctx context.Context, node *corev1.Nod
// Since the underlying instance has been deleted we expect the Node object to be deleted from
// the Kubernetes API server by the node controller:
// https://kubernetes.io/docs/concepts/architecture/cloud-controller/#node-controller
logger.Info("Waiting for Node to be deleted")
logger.Info("Waiting for Node object to be deleted")
err = kubernetes.WaitForNodeToBeDeleted(ctx, sm.Clientset, node.Name)
if err != nil {
return err
Expand Down

0 comments on commit f41bbc7

Please sign in to comment.