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

Add icinga states to job #103

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Add icinga states to job #103

merged 2 commits into from
Jul 29, 2024

Conversation

jhoxhaa
Copy link
Collaborator

@jhoxhaa jhoxhaa commented Jul 2, 2024

No description provided.

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Jul 2, 2024
@jhoxhaa jhoxhaa self-assigned this Jul 2, 2024
@jhoxhaa jhoxhaa force-pushed the add-icinga-states-to-job branch from 6536a7f to 00c9104 Compare July 10, 2024 09:24
@jhoxhaa
Copy link
Collaborator Author

jhoxhaa commented Jul 11, 2024

apiVersion: batch/v1
kind: Job
metadata:
  name: job-with-retries
  namespace: failures
spec:
  backoffLimit: 3
  template:
    spec:
      containers:
        - name: retry-container
          image: busybox
          command: ["sh", "-c", "echo 'Simulating failure'; exit 1"]
      restartPolicy: Never

@jhoxhaa
Copy link
Collaborator Author

jhoxhaa commented Jul 11, 2024

apiVersion: batch/v1
kind: Job
metadata:
  name: zero-completions-job
  namespace: failures
spec:
  completions: 0
  template:
    metadata:
      name: zero-completions-pod
    spec:
      containers:
        - name: job-container
          image: nginx:latest
      restartPolicy: Never

---

apiVersion: batch/v1
kind: Job
metadata:
  name: kubernetes-parallel-job
  namespace: failures
  labels:
    jobgroup: jobexample
spec:
  completions: 6
  parallelism: 2
  template:
    metadata:
      name: kubernetes-parallel-job
      labels:
        jobgroup: jobexample
    spec:
      containers:
        - name: c
          image: devopscube/kubernetes-job-demo:latest
          args: ["100"]
      restartPolicy: OnFailure

---

apiVersion: batch/v1
kind: Job
metadata:
  name: parallel-job
  namespace: failures
spec:
  parallelism: 6
  completions: 3
  template:
    spec:
      containers:
        - name: job-container
          image: nginx
      restartPolicy: OnFailure
  backoffLimit: 2

@@ -166,6 +171,28 @@ func (j *Job) Obtain(k8s kmetav1.Object) {
j.Yaml = string(output)
}

func (j *Job) getIcingaState(job *kbatchv1.Job) (IcingaState, string) {
if gracePeriodReason := IsWithinGracePeriod(j); gracePeriodReason != nil {
Copy link
Member

Choose a reason for hiding this comment

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

There is no need for a grace period as we will do the following:

  • If condition is complete, return ok: Job .. has finished its execution successfully with %d necessary pod completions.
  • If condition is failed, return critical. Message should stay the same.
  • If condition is suspend, return unknown. Message should indicate that the job is suspended.
  • If none of the above applies, return pending. Job .. is running since %s with currently %d active, %d completed and %d failed pods. Successful termination requires %d pod completions. The back-off limit is %d.
  • If ActiveDeadlineSeconds is set, the pending message should be extended: Deadline for completion is %s.

@@ -792,6 +792,8 @@ CREATE TABLE job (
succeeded int unsigned NOT NULL,
failed int unsigned NOT NULL,
yaml mediumblob DEFAULT NULL,
icinga_state enum('pending', 'ok', 'warning', 'critical', 'unknown') COLLATE utf8mb4_unicode_ci NOT NULL,
icinga_state_reason text NULL DEFAULT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Change that to NOT NULL as well.

@jhoxhaa jhoxhaa force-pushed the add-icinga-states-to-job branch from 00c9104 to bc2dd0a Compare July 25, 2024 14:49
@jhoxhaa jhoxhaa requested a review from lippserd July 25, 2024 14:50
@jhoxhaa jhoxhaa force-pushed the add-icinga-states-to-job branch from bc2dd0a to 6159e9a Compare July 25, 2024 14:53
@jhoxhaa jhoxhaa force-pushed the add-icinga-states-to-job branch from 6159e9a to 1921b28 Compare July 25, 2024 14:57
@lippserd lippserd merged commit bb1ea80 into main Jul 29, 2024
7 checks passed
@lippserd lippserd deleted the add-icinga-states-to-job branch July 29, 2024 08:38
@lippserd lippserd added this to the 0.2.0 milestone Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants