# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: batch/v1
kind: Job
metadata:
  name: file-generator-job-lustre
spec:
  ttlSecondsAfterFinished: 120
  completions: 1
  parallelism: 1
  template:
    spec:
      priorityClassName: higher-priority
      # nodeSelector:
      #   cloud.google.com/compute-class: spot-capacity
      containers:
      - name: file-generator
        image: fio
        command: ["/bin/bash", "/scripts/generate_files.sh"]
        env:
        - name: OUTPUT_DIR
          value: "/data/test_files"  # Default output directory
        - name: MAX_RETRIES
          value: "5"  # Number of retries for mount detection
        - name: SLEEP_TIME
          value: "1"  # Initial sleep time in seconds
        - name: NUM_FILES
          value: "1000" # Number of files to generate
        - name: MIN_FILE_SIZE_KB
          value: "1000000" # Minimum file size in KB
        - name: MAX_FILE_SIZE_KB
          value: "10000000" # Maximum file size in KB
        resources:
          requests:
            memory: "8Gi"
            cpu: "4"
          limits:
            memory: "16Gi"
            cpu: "8"
        volumeMounts:
        - name: script-volume
          mountPath: /scripts
        - name: lustre-volume
          mountPath: /data
      volumes:
      - name: script-volume
        configMap:
          name: file-generator-config
      - name: lustre-volume
        persistentVolumeClaim:
          claimName: lustre-pvc
      restartPolicy: Never
  backoffLimit: 4
