Skip to content

Commit

Permalink
Merge pull request #1014 from gburges/disable
Browse files Browse the repository at this point in the history
[FEAT] Disable CJI
  • Loading branch information
gburges authored Aug 22, 2024
2 parents cc5950b + d640112 commit 8ab00bc
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 3 deletions.
3 changes: 3 additions & 0 deletions apis/cloud.redhat.com/v1alpha1/clowdjobinvocation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ type ClowdJobInvocationSpec struct {

// RunOnNotReady is a flag that when true, the job will not wait for the deployment to be ready to run
RunOnNotReady bool `json:"runOnNotReady,omitempty"`

// Disabled is a flag to turn off CJI(s) from running
Disabled bool `json:"disabled,omitempty"`
}

// ClowdJobInvocationStatus defines the observed state of ClowdJobInvocation
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/cloud.redhat.com_clowdjobinvocations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
appName:
description: Name of the ClowdApp who owns the jobs
type: string
disabled:
description: Disabled is a flag to turn off CJI(s) from running
type: boolean
jobs:
description: Jobs is the set of jobs to be run by the invocation
items:
Expand Down
8 changes: 5 additions & 3 deletions controllers/cloud.redhat.com/clowdjobinvocation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ func (r *ClowdJobInvocationReconciler) Reconcile(ctx context.Context, req ctrl.R
}
return ctrl.Result{}, nil
}
// This is a fresh CJI and needs to be invoked the first time
r.Log.Info("Reconciliation started", "ClowdJobInvocation", fmt.Sprintf("%s:%s", cji.Namespace, cji.Name))
ctx = context.WithValue(ctx, errors.ClowdKey("obj"), &cji)
// This is a fresh CJI and needs to be invoked the first time unless it's disabled
if !cji.Spec.Disabled {
r.Log.Info("Reconciliation started", "ClowdJobInvocation", fmt.Sprintf("%s:%s", cji.Namespace, cji.Name))
ctx = context.WithValue(ctx, errors.ClowdKey("obj"), &cji)
}

// Get the ClowdApp. Used to find definition of job being invoked
app := crd.ClowdApp{}
Expand Down
3 changes: 3 additions & 0 deletions deploy-mutate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7578,6 +7578,9 @@ objects:
appName:
description: Name of the ClowdApp who owns the jobs
type: string
disabled:
description: Disabled is a flag to turn off CJI(s) from running
type: boolean
jobs:
description: Jobs is the set of jobs to be run by the invocation
items:
Expand Down
3 changes: 3 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7578,6 +7578,9 @@ objects:
appName:
description: Name of the ClowdApp who owns the jobs
type: string
disabled:
description: Disabled is a flag to turn off CJI(s) from running
type: boolean
jobs:
description: Jobs is the set of jobs to be run by the invocation
items:
Expand Down
1 change: 1 addition & 0 deletions docs/antora/modules/ROOT/pages/api_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ ClowdJobInvocationSpec defines the desired state of ClowdJobInvocation
| *`jobs`* __string array__ | Jobs is the set of jobs to be run by the invocation
| *`testing`* __xref:{anchor_prefix}-github-com-redhatinsights-clowder-apis-cloud-redhat-com-v1alpha1-jobtestingspec[$$JobTestingSpec$$]__ | Testing is the struct for building out test jobs (iqe, etc) in a CJI
| *`runOnNotReady`* __boolean__ | RunOnNotReady is a flag that when true, the job will not wait for the deployment to be ready to run
| *`disabled`* __boolean__ | Disabled is a flag to turn off CJI(s) from running
|===


Expand Down
7 changes: 7 additions & 0 deletions tests/kuttl/test-cji-disabled/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: test-cji-disabled
spec:
finalizers:
- kubernetes
37 changes: 37 additions & 0 deletions tests/kuttl/test-cji-disabled/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: puptoo
namespace: test-cji-disabled
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: puptoo-processor
namespace: test-cji-disabled
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdJobInvocation
metadata:
name: runner-cji-disabled
namespace: test-cji-disabled
spec:
appName: puptoo
disabled: true
jobs:
- hello-cji
---
apiVersion: v1
kind: Secret
metadata:
name: puptoo
namespace: test-cji-disabled
labels:
app: puptoo
ownerReferences:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
name: puptoo
type: Opaque

7 changes: 7 additions & 0 deletions tests/kuttl/test-cji-disabled/01-errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: batch/v1
kind: Job
metadata:
namespace: test-cji-disabled
labels:
job: puptoo-hello-cji
65 changes: 65 additions & 0 deletions tests/kuttl/test-cji-disabled/01-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-cji-disabled
spec:
targetNamespace: test-cji-disabled
providers:
web:
port: 8000
mode: operator
metrics:
port: 9000
mode: operator
path: "/metrics"
kafka:
mode: none
db:
mode: none
logging:
mode: none
objectStore:
mode: none
inMemoryDb:
mode: none
featureFlags:
mode: none
resourceDefaults:
limits:
cpu: 400m
memory: 1024Mi
requests:
cpu: 30m
memory: 512Mi
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: puptoo
namespace: test-cji-disabled
spec:
envName: test-cji-disabled
deployments:
- name: processor
podSpec:
image: quay.io/psav/clowder-hello
jobs:
- name: hello-cji
podSpec:
image: busybox
args:
- /bin/sh
- -c
- echo "Hello!"
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdJobInvocation
metadata:
name: runner-cji-disabled
namespace: test-cji-disabled
spec:
appName: puptoo
disabled: true
jobs:
- hello-cji
10 changes: 10 additions & 0 deletions tests/kuttl/test-cji-disabled/02-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: v1
kind: Namespace
name: test-cji-disabled
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
name: test-cji-disabled

0 comments on commit 8ab00bc

Please sign in to comment.