Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug-automation: add automation to redeploy on changes in github #42

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfiles/Dockerfile.bug-automation
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM registry.access.redhat.com/ubi8/go-toolset AS builder
ENV CMD=bug-automation
ENV GOPATH=/go
ENV PROJECT=${GOPATH}/src/github.com/openshift/bugzilla-tools/
ENV CMDBASE=cmd/${CMD}/
ENV CMDDIR=${PROJECT}/${CMDBASE}/

COPY . ${PROJECT}
WORKDIR ${CMDDIR}
RUN make build

FROM registry.access.redhat.com/ubi8/ubi-minimal
ENV CMD=bug-automation
ENV GOPATH=/go
ENV PROJECT=${GOPATH}/src/github.com/openshift/bugzilla-tools/
ENV CMDBASE=cmd/${CMD}/
ENV CMDDIR=${PROJECT}/${CMDBASE}/

RUN microdnf update -y && microdnf clean all
COPY --from=builder ${CMDDIR}/${CMD} /${CMD}
RUN chmod +x /${CMD}
COPY --from=builder ${CMDDIR}/operations/ operations/
CMD /${CMD} --bugzilla-key=/etc/bugzilla/bugzillaKey
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

Assorted tooling for monitoring and manipulating [Bugzilla](https://bugzilla.redhat.com) bugs for the OpenShift project.

### Repo Layout

The repo is a collection of tools and shared libraries. Each tool lives in cmd/* and shared code in pkg/*

Most tools have 2 Dockerfiles.
1 in cmd/*/Dockerfile
1 in Dockerfiles/Dockerfile.*

The one in cmd/*/Dockerfile is just for local testing and building.
The one in Dockerfiles/Dockerfile.* is used to build on cluster - the reason it isn't used for local building is because it does a cp of the whole repo into the build container, which is slow.

Most tools have a cmd/*/manifests/ (or cmd/*/deploment if it is old) which have the kube objects which run the tool on top of OpenShift. These are applied manually using oc apply -f. There is no automation to apply these changes.

### Adding automation to automatically run new tools

A reasonable example of adding new automation so that changes to a command are automatically applied when updated in github can be found here https://github.com/openshift/bugzilla-tools/pull/42/files

This adds an imagestream, a buildconfig, and a 'git-build-watcher'. The git-build-watcher is the magic. Since the cluster is not reachable by github we need to poll instead of get notification froma webhook. That magic polls github and forced a buildconfig to run when github has changed since the last successful build.

Most tools are deployments, not cronjobs, and thus they need a trigger to restart after a build. Pull 42 is using a cronjob so that is not present.

License
-------

Expand Down
39 changes: 39 additions & 0 deletions cmd/bug-automation/manifests/bug-automation.buildconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
annotations:
app.openshift.io/vcs-ref: main
app.openshift.io/vcs-uri: 'https://github.com/openshift/bugzilla-tools.git'
name: bug-automation
labels:
app: bug-automation
app.kubernetes.io/component: bug-automation
app.kubernetes.io/instance: bug-automation
app.kubernetes.io/part-of: openshift-bugzilla-tools
spec:
output:
to:
kind: ImageStreamTag
name: 'bug-automation:latest'
strategy:
type: Docker
dockerStrategy:
dockerfilePath: Dockerfiles/Dockerfile.bug-automation
source:
type: Git
git:
uri: 'https://github.com/openshift/bugzilla-tools.git'
ref: main
contextDir: /
triggers:
- type: ConfigChange
resources:
requests:
cpu: '1'
memory: 2G
limits:
cpu: '1.5'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we've generally said there's no good reason to limit your cpu on a pod in general. use whatever the system is willing to give you.

the full core request also seems high.

memory: 2G
runPolicy: Serial
successfulBuildsHistoryLimit: 1
failedBuildsHistoryLimit: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it were me i'd want more history than 1.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
defaultMode: 420
containers:
- name: bug-automation
image: 'quay.io/eparis/bug-automation:latest'
image: image-registry.openshift-image-registry.svc:5000/ocp-eng-architects/bug-automation:latest
resources: {}
volumeMounts:
- name: bugzilla-api-key
Expand Down
9 changes: 9 additions & 0 deletions cmd/bug-automation/manifests/bug-automation.imagestream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: bug-automation
labels:
app: bug-automation
app.kubernetes.io/component: bug-automation
app.kubernetes.io/instance: bug-automation
app.kubernetes.io/part-of: openshift-bugzilla-tools
50 changes: 50 additions & 0 deletions cmd/bug-automation/manifests/git-build-watcher.cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
kind: CronJob
apiVersion: batch/v1beta1
metadata:
name: bug-automation-git-build-watcher
annotations:
app.openshift.io/vcs-ref: master
app.openshift.io/vcs-uri: 'https://github.com/openshift/bugzilla-tools.git'
image.openshift.io/triggers: >-
[{"from":{"kind":"ImageStreamTag","name":"git-build-watcher:latest","namespace":"ocp-eng-architects"},"fieldPath":"spec.template.spec.containers[?(@.name==\"bug-automation-git-build-watcher\")].image","pause":"false"}]
labels:
app: bug-automation-git-build-watcher
app.kubernetes.io/component: bug-automation-git-build-watcher
app.kubernetes.io/instance: bug-automation-git-build-watcher
app.kubernetes.io/part-of: openshift-bugzilla-tools
spec:
concurrencyPolicy: Forbid
schedule: '*/5 * * * *'
startingDeadlineSeconds: 3600
jobTemplate:
metadata:
labels:
app: bug-automation-git-build-watcher
app.kubernetes.io/component: bug-automation-git-build-watcher
app.kubernetes.io/instance: bug-automation-git-build-watcher
app.kubernetes.io/part-of: openshift-bugzilla-tools
spec:
template:
spec:
containers:
- name: bug-automation-git-build-watcher
image: image-registry.openshift-image-registry.svc:5000/ocp-eng-architects/git-build-watcher:latest
command:
- /git-build-watcher
- -v=2
- bug-automation
resources:
requests:
memory: "50Mi"
cpu: "10m"
limits:
memory: "50Mi"
cpu: "10m"
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: OnFailure
serviceAccountName: git-build-watcher
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
1 change: 1 addition & 0 deletions cmd/bug-automation/manifests/git-build-watcher.role.yml