Skip to content

Commit 6b272cd

Browse files
authored
chore(engine): Updates mandatory fields in the engine probe spec (#447)
* updates mandatory fields in the engine spec Signed-off-by: neelanjan00 <[email protected]>
1 parent 054c3e2 commit 6b272cd

File tree

3 files changed

+91
-27
lines changed

3 files changed

+91
-27
lines changed

api/litmuschaos/v1alpha1/chaosengine_types.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ type ExperimentAttributes struct {
221221
// ProbeAttributes contains details of probe, which can be applied on the experiments
222222
type ProbeAttributes struct {
223223
// Name of probe
224-
Name string `json:"name,omitempty"`
224+
Name string `json:"name"`
225225
// Type of probe
226-
Type string `json:"type,omitempty"`
226+
Type string `json:"type"`
227227
// inputs needed for the k8s probe
228228
K8sProbeInputs K8sProbeInputs `json:"k8sProbe/inputs,omitempty"`
229229
// inputs needed for the http probe
@@ -233,10 +233,10 @@ type ProbeAttributes struct {
233233
// inputs needed for the prometheus probe
234234
PromProbeInputs PromProbeInputs `json:"promProbe/inputs,omitempty"`
235235
// RunProperty contains timeout, retry and interval for the probe
236-
RunProperties RunProperty `json:"runProperties,omitempty"`
236+
RunProperties RunProperty `json:"runProperties"`
237237
// mode for k8s probe
238238
// it can be SOT, EOT, Edge
239-
Mode string `json:"mode,omitempty"`
239+
Mode string `json:"mode"`
240240
// Data contains the manifest/data for the resource, which need to be created
241241
// it supported for create operation only
242242
Data string `json:"data,omitempty"`
@@ -245,11 +245,11 @@ type ProbeAttributes struct {
245245
// K8sProbeInputs contains all the inputs required for k8s probe
246246
type K8sProbeInputs struct {
247247
// group of the resource
248-
Group string `json:"group,omitempty"`
248+
Group string `json:"group"`
249249
// apiversion of the resource
250-
Version string `json:"version,omitempty"`
250+
Version string `json:"version"`
251251
// kind of resource
252-
Resource string `json:"resource,omitempty"`
252+
Resource string `json:"resource"`
253253
// ResourceNames to get the resources using their list of comma separated names
254254
ResourceNames string `json:"resourceNames,omitempty"`
255255
// namespace of the resource
@@ -260,15 +260,15 @@ type K8sProbeInputs struct {
260260
LabelSelector string `json:"labelSelector,omitempty"`
261261
// Operation performed by the k8s probe
262262
// it can be create, delete, present, absent
263-
Operation string `json:"operation,omitempty"`
263+
Operation string `json:"operation"`
264264
}
265265

266-
//CmdProbeInputs contains all the inputs required for cmd probe
266+
// CmdProbeInputs contains all the inputs required for cmd probe
267267
type CmdProbeInputs struct {
268268
// Command need to be executed for the probe
269-
Command string `json:"command,omitempty"`
269+
Command string `json:"command"`
270270
// Comparator check for the correctness of the probe output
271-
Comparator ComparatorInfo `json:"comparator,omitempty"`
271+
Comparator ComparatorInfo `json:"comparator"`
272272
// The source where we have to run the command
273273
// It will run in inline(inside experiment itself) mode if source is nil
274274
Source SourceDetails `json:"source,omitempty"`
@@ -277,7 +277,7 @@ type CmdProbeInputs struct {
277277
// SourceDetails contains source details of the cmdProbe
278278
type SourceDetails struct {
279279
// Image for the source pod
280-
Image string `json:"image,omitempty"`
280+
Image string `json:"image"`
281281
// HostNetwork define the hostNetwork of the external pod
282282
// it supports boolean values and default value is false
283283
HostNetwork bool `json:"hostNetwork,omitempty"`
@@ -308,16 +308,16 @@ type SourceDetails struct {
308308
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
309309
}
310310

311-
//PromProbeInputs contains all the inputs required for prometheus probe
311+
// PromProbeInputs contains all the inputs required for prometheus probe
312312
type PromProbeInputs struct {
313313
// Endpoint for the prometheus probe
314-
Endpoint string `json:"endpoint,omitempty"`
314+
Endpoint string `json:"endpoint"`
315315
// Query to get promethus metrics
316316
Query string `json:"query,omitempty"`
317317
// QueryPath contains filePath, which contains prometheus query
318318
QueryPath string `json:"queryPath,omitempty"`
319319
// Comparator check for the correctness of the probe output
320-
Comparator ComparatorInfo `json:"comparator,omitempty"`
320+
Comparator ComparatorInfo `json:"comparator"`
321321
}
322322

323323
// ComparatorInfo contains the comparator details
@@ -328,19 +328,19 @@ type ComparatorInfo struct {
328328
// Criteria for matching data
329329
// it supports >=, <=, ==, >, <, != for int and float
330330
// it supports equal, notEqual, contains for string
331-
Criteria string `json:"criteria,omitempty"`
331+
Criteria string `json:"criteria"`
332332
// Value contains relative value for criteria
333-
Value string `json:"value,omitempty"`
333+
Value string `json:"value"`
334334
}
335335

336-
//HTTPProbeInputs contains all the inputs required for http probe
336+
// HTTPProbeInputs contains all the inputs required for http probe
337337
type HTTPProbeInputs struct {
338338
// URL which needs to curl, to check the status
339-
URL string `json:"url,omitempty"`
339+
URL string `json:"url"`
340340
// InsecureSkipVerify flag to skip certificate checks
341341
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
342342
// Method define the http method, it can be get or post
343-
Method HTTPMethod `json:"method,omitempty"`
343+
Method HTTPMethod `json:"method"`
344344
}
345345

346346
// HTTPMethod define the http method details
@@ -353,9 +353,9 @@ type HTTPMethod struct {
353353
type GetMethod struct {
354354
// Criteria for matching data
355355
// it supports == != operations
356-
Criteria string `json:"criteria,omitempty"`
356+
Criteria string `json:"criteria"`
357357
// Value contains relative value for criteria
358-
ResponseCode string `json:"responseCode,omitempty"`
358+
ResponseCode string `json:"responseCode"`
359359
}
360360

361361
// PostMethod define the http Post method
@@ -368,17 +368,17 @@ type PostMethod struct {
368368
BodyPath string `json:"bodyPath,omitempty"`
369369
// Criteria for matching data
370370
// it supports == != operations
371-
Criteria string `json:"criteria,omitempty"`
371+
Criteria string `json:"criteria"`
372372
// Value contains relative value for criteria
373-
ResponseCode string `json:"responseCode,omitempty"`
373+
ResponseCode string `json:"responseCode"`
374374
}
375375

376-
//RunProperty contains timeout, retry and interval for the probe
376+
// RunProperty contains timeout, retry and interval for the probe
377377
type RunProperty struct {
378378
//ProbeTimeout contains timeout for the probe
379-
ProbeTimeout int `json:"probeTimeout,omitempty"`
379+
ProbeTimeout int `json:"probeTimeout"`
380380
// Interval contains the interval for the probe
381-
Interval int `json:"interval,omitempty"`
381+
Interval int `json:"interval"`
382382
// Retry contains the retry count for the probe
383383
Retry int `json:"retry,omitempty"`
384384
// Attempt contains the total attempt count for the probe

deploy/chaos_crds.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ spec:
338338
items:
339339
type: object
340340
required:
341+
- name
342+
- type
341343
- runProperties
344+
- mode
342345
properties:
343346
name:
344347
type: string
@@ -348,6 +351,11 @@ spec:
348351
pattern: ^(k8sProbe|httpProbe|cmdProbe|promProbe)$
349352
k8sProbe/inputs:
350353
type: object
354+
required:
355+
- group
356+
- version
357+
- resource
358+
- operation
351359
properties:
352360
group:
353361
type: string
@@ -369,12 +377,19 @@ spec:
369377
minLength: 1
370378
cmdProbe/inputs:
371379
type: object
380+
required:
381+
- command
382+
- comparator
372383
properties:
373384
command:
374385
type: string
375386
minLength: 1
376387
comparator:
377388
type: object
389+
required:
390+
- type
391+
- criteria
392+
- value
378393
properties:
379394
type:
380395
type: string
@@ -387,6 +402,8 @@ spec:
387402
source:
388403
description: The external pod where we have to run the
389404
probe commands. It will run the commands inside the experiment pod itself(inline mode) if source contains a nil value
405+
required:
406+
- image
390407
properties:
391408
annotations:
392409
additionalProperties:
@@ -2170,6 +2187,9 @@ spec:
21702187
type: object
21712188
httpProbe/inputs:
21722189
type: object
2190+
required:
2191+
- url
2192+
- method
21732193
properties:
21742194
url:
21752195
type: string
@@ -2182,6 +2202,9 @@ spec:
21822202
properties:
21832203
get:
21842204
type: object
2205+
required:
2206+
- criteria
2207+
- responseCode
21852208
properties:
21862209
criteria:
21872210
type: string
@@ -2191,6 +2214,9 @@ spec:
21912214
minLength: 1
21922215
post:
21932216
type: object
2217+
required:
2218+
- criteria
2219+
- responseCode
21942220
properties:
21952221
contentType:
21962222
type: string
@@ -2207,6 +2233,9 @@ spec:
22072233
minLength: 1
22082234
promProbe/inputs:
22092235
type: object
2236+
required:
2237+
- endpoint
2238+
- comparator
22102239
properties:
22112240
endpoint:
22122241
type: string
@@ -2216,6 +2245,9 @@ spec:
22162245
type: string
22172246
comparator:
22182247
type: object
2248+
required:
2249+
- criteria
2250+
- value
22192251
properties:
22202252
criteria:
22212253
type: string

deploy/crds/chaosengine_crd.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ spec:
336336
items:
337337
type: object
338338
required:
339+
- name
340+
- type
339341
- runProperties
342+
- mode
340343
properties:
341344
name:
342345
type: string
@@ -346,6 +349,11 @@ spec:
346349
pattern: ^(k8sProbe|httpProbe|cmdProbe|promProbe)$
347350
k8sProbe/inputs:
348351
type: object
352+
required:
353+
- group
354+
- version
355+
- resource
356+
- operation
349357
properties:
350358
group:
351359
type: string
@@ -367,12 +375,19 @@ spec:
367375
minLength: 1
368376
cmdProbe/inputs:
369377
type: object
378+
required:
379+
- command
380+
- comparator
370381
properties:
371382
command:
372383
type: string
373384
minLength: 1
374385
comparator:
375386
type: object
387+
required:
388+
- type
389+
- criteria
390+
- value
376391
properties:
377392
type:
378393
type: string
@@ -385,6 +400,8 @@ spec:
385400
source:
386401
description: The external pod where we have to run the
387402
probe commands. It will run the commands inside the experiment pod itself(inline mode) if source contains a nil value
403+
required:
404+
- image
388405
properties:
389406
annotations:
390407
additionalProperties:
@@ -2168,6 +2185,9 @@ spec:
21682185
type: object
21692186
httpProbe/inputs:
21702187
type: object
2188+
required:
2189+
- url
2190+
- method
21712191
properties:
21722192
url:
21732193
type: string
@@ -2180,6 +2200,9 @@ spec:
21802200
properties:
21812201
get:
21822202
type: object
2203+
required:
2204+
- criteria
2205+
- responseCode
21832206
properties:
21842207
criteria:
21852208
type: string
@@ -2189,6 +2212,9 @@ spec:
21892212
minLength: 1
21902213
post:
21912214
type: object
2215+
required:
2216+
- criteria
2217+
- responseCode
21922218
properties:
21932219
contentType:
21942220
type: string
@@ -2205,6 +2231,9 @@ spec:
22052231
minLength: 1
22062232
promProbe/inputs:
22072233
type: object
2234+
required:
2235+
- endpoint
2236+
- comparator
22082237
properties:
22092238
endpoint:
22102239
type: string
@@ -2214,6 +2243,9 @@ spec:
22142243
type: string
22152244
comparator:
22162245
type: object
2246+
required:
2247+
- criteria
2248+
- value
22172249
properties:
22182250
criteria:
22192251
type: string

0 commit comments

Comments
 (0)