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

Mintmaker: create a cronjob for generating the OSV database #5379

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/mintmaker/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resources:
- cronjobs/
- rbac/
- osv-database-builder/

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: create-database-generator
namespace: mintmaker
spec:
schedule: "0 */4 * * *"
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
containers:
- name: database-generator
image: quay.io/konflux-ci/mintmaker:next
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- /osv-generator -destination-dir /mnt/database -docker-filename docker.nedb -rpm-filename rpm.nedb -days 1
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check how many data will be generated with days=1 (which can be done after Feb 10 when released.csv is available), but I would consider to increase this to 3 possibly, so we can still fix vulnerabilities in case of an outage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a placeholder value, I expect that we will gather more than just one day's worth of data. But for testing purposes, changes.csv has a lot of entries even for 1 day, so it will generate quite sizable databases.

resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 100m
memory: 500Mi
volumeMounts:
- name: osv-db
mountPath: /mnt/database
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
volumes:
- name: osv-db
persistentVolumeClaim:
claimName: osv-offline-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: Job
metadata:
name: database-generator
namespace: mintmaker
annotations:
argocd.argoproj.io/hook: Sync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
template:
spec:
restartPolicy: Never
containers:
- name: database-generator
image: quay.io/konflux-ci/mintmaker:next
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- /osv-generator -destination-dir /mnt/database -docker-filename docker.nedb -rpm-filename rpm.nedb -days 1
resources:
requests:
cpu: 100m
memory: 500Mi
limits:
cpu: 100m
memory: 500Mi
volumeMounts:
- name: osv-db
mountPath: /mnt/database
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
volumes:
- name: osv-db
persistentVolumeClaim:
claimName: osv-offline-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
Copy link
Member

Choose a reason for hiding this comment

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

The default storage class provides EBS volumes. The pvc is going to be bounded to a single node, it means that all the jobs that will use it would need to be scheduled on the same node, this can cause a bottleneck.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Checking the storage classes, it seems all of them use EBS volumes. Is there a way to overcome this limitation?

Copy link
Member

Choose a reason for hiding this comment

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

not at this moment.

kind: PersistentVolumeClaim
metadata:
name: osv-offline-db
namespace: mintmaker
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
volumeMode: Filesystem
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- create-database-pvc.yaml
- create-database-generator-cronjob.yaml
- create-database-generator-job.yaml
namespace: mintmaker
Loading