Skip to content

Commit

Permalink
notifier-v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jkupferer committed Jul 30, 2024
1 parent 1f80691 commit d17c2f5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 43 deletions.
42 changes: 17 additions & 25 deletions .github/workflows/notifier-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@master

- name: Get image tags
id: image_tags
Expand All @@ -24,40 +24,32 @@ jobs:
RELEASE=${GITHUB_REF#refs/tags/notifier-}
# To determine VERSION, strip off any release number suffix
VERSION=${RELEASE/-*/}
echo "::set-output name=RELEASE::${RELEASE}"
echo "::set-output name=VERSION::${VERSION}"
# Only build image if version tag without release number
# Releases indicate a change in the repository that should not trigger a new build.
if [[ "${VERSION}" == "${RELEASE}" ]]; then
# Publish to latest, minor, and patch tags
# Ex: latest,v0.1.2,v0.1
IMAGE_TAGS=(
'${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest'
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION%.*}"
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION}"
)
# Set IMAGE_TAGS output for use in next step
( IFS=$','; echo "::set-output name=IMAGE_TAGS::${IMAGE_TAGS[*]}" )
echo "IMAGE_TAGS=latest ${VERSION%.*} ${VERSION}" >> $GITHUB_OUTPUT
fi
- name: Set up buildx
uses: docker/setup-buildx-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS

- name: Login to image registry
uses: docker/login-action@v1
- name: Buildah Action
id: buildah-build
if: steps.image_tags.outputs.IMAGE_TAGS
uses: redhat-actions/buildah-build@v2
with:
registry: ${{ secrets.REGISTRY_URI }}
username: ${{ secrets.GPTE_REGISTRY_USERNAME }}
password: ${{ secrets.GPTE_REGISTRY_PASSWORD }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.image_tags.outputs.IMAGE_TAGS }}
context: notifier
containerfiles: notifier/Containerfile

- name: Build and publish image
uses: docker/build-push-action@v2
- name: Push image to registry
id: push-to-registry
if: steps.image_tags.outputs.IMAGE_TAGS
uses: redhat-actions/push-to-registry@v2
with:
context: notifier
file: notifier/Dockerfile
push: true
tags: ${{ steps.image_tags.outputs.IMAGE_TAGS }}
image: ${{ steps.buildah-build.outputs.image }}
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ vars.BABYLON_IMAGE_REGISTRY }}/${{ vars.BABYLON_IMAGE_REPOSITORY }}
username: ${{ secrets.BABYLON_IMAGE_REGISTRY_USERNAME }}
password: ${{ secrets.BABYLON_IMAGE_REGISTRY_PASSWORD }}
4 changes: 2 additions & 2 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ configNamespace:
notifier:
deploy: false
image:
repository: quay.io/redhat-gpte/babylon-notifier
repository: quay.io/rhpds/babylon-notifier
pullPolicy: IfNotPresent
tag: v0.7.0
tag: v0.7.1
namespace:
create: true
name: babylon-notifier
Expand Down
File renamed without changes.
7 changes: 2 additions & 5 deletions notifier/build-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ parameters:
value: https://github.com/redhat-cop/babylon.git
- name: GIT_REF
value: main
- name: KOPF_S2I_IMAGE
value: quay.io/redhat-cop/python-kopf-s2i:v1.37

objects:
- apiVersion: image.openshift.io/v1
Expand Down Expand Up @@ -45,7 +43,6 @@ objects:
strategy:
type: Docker
dockerStrategy:
from:
kind: DockerImage
name: ${KOPF_S2I_IMAGE}
dockerfilePath: Containerfile
forcePull: true
triggers: []
18 changes: 8 additions & 10 deletions notifier/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,16 @@ async def notify_ready(catalog_item, catalog_namespace, email_addresses, logger,
to = email_addresses,
)

async def notify_retirement_scheduled_after(interval, **kwargs):
async def notify_retirement_scheduled_after(interval, resource_claim, **kwargs):
try:
await asyncio.sleep(interval)
await notify_retirement_scheduled(**kwargs)
await resource_claim.refetch()
if not resource_claim.ignore:
await notify_retirement_scheduled(resource_claim=resource_claim, **kwargs)
except asyncio.CancelledError:
pass

async def notify_retirement_scheduled(catalog_item, catalog_namespace, email_addresses, logger, resource_claim):
if resource_claim.ignore:
return

logger.info("sending retirement schedule notification")

await send_notification_email(
Expand All @@ -620,17 +619,16 @@ async def notify_retirement_scheduled(catalog_item, catalog_namespace, email_add
template = "retirement-scheduled",
)

async def notify_stop_scheduled_after(interval, **kwargs):
async def notify_stop_scheduled_after(interval, resource_claim, **kwargs):
try:
await asyncio.sleep(interval)
await notify_stop_scheduled(**kwargs)
await resource_claim.refetch()
if not resource_claim.ignore:
await notify_stop_scheduled(resource_claim=resource_claim, **kwargs)
except asyncio.CancelledError:
pass

async def notify_stop_scheduled(catalog_item, catalog_namespace, email_addresses, logger, resource_claim):
if resource_claim.ignore:
return

logger.info("sending stop schedule notification")

await send_notification_email(
Expand Down
11 changes: 10 additions & 1 deletion notifier/operator/resource_claim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from pydantic.utils import deep_update
from pydantic.v1.utils import deep_update

from babylon import Babylon

Expand Down Expand Up @@ -303,3 +303,12 @@ def get_provision_data(self):
except (IndexError, KeyError):
pass
return merged_data, component_data

async def refetch(self):
self.definition = await Babylon.custom_objects_api.get_namespaced_custom_object(
group=Babylon.resource_broker_domain,
name=self.name,
namespace=self.namespace,
plural='resourceclaims',
version=Babylon.resource_broker_api_version,
)

0 comments on commit d17c2f5

Please sign in to comment.