-
Notifications
You must be signed in to change notification settings - Fork 706
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
feat: Probes/Added backend implementation for probes as resource #4116
feat: Probes/Added backend implementation for probes as resource #4116
Conversation
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, PTAL
""" | ||
Types of AzureDataDiskCachingModes | ||
""" | ||
enum AzureDataDiskCachingMode { | ||
None | ||
ReadOnly | ||
ReadWrite | ||
} | ||
|
||
""" | ||
Types of AzureDataDiskKind | ||
""" | ||
enum AzureDataDiskKind { | ||
Shared | ||
Dedicated | ||
Managed | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be removed
""" | ||
Type for HostPath Volume | ||
""" | ||
enum HostPathType { | ||
DirectoryOrCreate | ||
Directory | ||
FileOrCreate | ||
File | ||
Socket | ||
CharDevice | ||
BlockDevice | ||
} | ||
|
||
""" | ||
StorageMedium defines ways that storage can be allocated to a volume. | ||
""" | ||
enum StorageMedium { | ||
Memory | ||
HugePages | ||
} | ||
|
||
""" | ||
MountPropagationMode describes mount propagation. | ||
""" | ||
enum MountPropagationMode { | ||
None | ||
HostToContainer | ||
Bidirectional | ||
} | ||
|
||
""" | ||
Quantity is a fixed-point representation of a number. | ||
It provides convenient marshaling/unmarshaling in JSON and YAML, | ||
""" | ||
enum Quantity { | ||
i | ||
d | ||
s | ||
DecimalExponent | ||
BinarySI | ||
DecimalSI | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These types can be removed too
""" | ||
EvaluationWindow is the time period for which the SLO probe will work | ||
""" | ||
type EvaluationWindow { | ||
""" | ||
Start time of evaluation | ||
""" | ||
evaluationStartTime: Int | ||
""" | ||
End time of evaluation | ||
""" | ||
evaluationEndTime: Int | ||
} | ||
|
||
""" | ||
Defines the input properties of EvaluationWindow | ||
""" | ||
input EvaluationWindowInput { | ||
""" | ||
Start time of evaluation | ||
""" | ||
evaluationStartTime: Int | ||
""" | ||
End time of evaluation | ||
""" | ||
evaluationEndTime: Int | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are SLO properties and can be removed
""" | ||
User who has updated the experiment | ||
""" | ||
updatedBy: UserDetails! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updatedBy
would be optional for ExecutedByExperiment
updatedBy: UserDetails
Otherwise it would throw error like Probe must not be null
if the updatedBy is set to "" by any other component
logrus.WithFields(logFields).Info("request received to get probe YAML") | ||
|
||
err := authorization.ValidateRole(ctx, projectID, | ||
authorization.MutationRbacRules[authorization.AddProbe], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is GetProbeYAML this permission could be mapped to GetProbe
authorization permission
// CmdProbeInputs contains all the inputs required for cmd probe | ||
// Duplicate type of v1alpha1.CmdProbeInputs because of extra nil pointer reference to Source object | ||
// as it is optional for CMD Probe Input | ||
type CmdProbeInputs struct { | ||
// Command need to be executed for the probe | ||
Command string `json:"command,omitempty"` | ||
// Comparator check for the correctness of the probe output | ||
Comparator v1alpha1.ComparatorInfo `json:"comparator,omitempty"` | ||
// The source where we have to run the command | ||
// It will run in inline(inside experiment itself) mode if source is nil | ||
Source *v1alpha1.SourceDetails `json:"source,omitempty"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed and type CMDProbeAttributes struct
can have this instead
CmdProbeInputs v1alpha1.CmdProbeInputs `json:"cmdProbe/inputs,omitempty"`
// HTTPProbeInputs contains all the inputs required for http probe | ||
type HTTPProbeInputs struct { | ||
// URL which needs to curl, to check the status | ||
URL string `json:"url,omitempty"` | ||
// InsecureSkipVerify flag to skip certificate checks | ||
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` | ||
// Method define the http method, it can be get or post | ||
Method v1alpha1.HTTPMethod `json:"method,omitempty"` | ||
// ResponseTimeout Flag to hold the flag to response timeout for the httpProbe | ||
ResponseTimeout int `json:"responseTimeout,omitempty"` | ||
} | ||
|
||
// HTTPMethod define the http method details | ||
type HTTPMethod struct { | ||
Get *v1alpha1.GetMethod `json:"get,omitempty"` | ||
Post *v1alpha1.PostMethod `json:"post,omitempty"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two types can be removed and type HTTPProbeAttributes struct
can have this instead
HTTPProbeInputs v1alpha1.HTTPProbeInputs `json:"httpProbe/inputs,omitempty"`
This was done since operator was old and didn't support the correct omitempty fields. Since its synced now we can directly reference the type as a single source of truth
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
} | ||
|
||
p := probe.NewProbeRepository(projectID) | ||
response, err := p.UpdateProbe(ctx, request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs same probe validity checks as done in addProbe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are still missing the part where we validate the probe type and the probe properties set match, for eg. if a user updates the probe but removes the probe properties that will be a problem and should be caught.
@@ -1548,6 +1573,8 @@ func (c *ChaosExperimentHandler) RunChaosWorkFlow(ctx context.Context, projectID | |||
Completed: false, | |||
ResiliencyScore: &resScore, | |||
ExecutionData: string(parsedData), | |||
Probes: probes, | |||
//TODO add probes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale comment? I see probe is already there. If it's something else needs a better descriptive comment
@Saranya-jena as external maintainers don't have the full context of the feature might be good to add some PR description that gives the full context or create public issues that describe the need for the feature and its goals. Without the full context, it will be difficult to do a proper review. |
Hey @gdsoumya thanks for suggestion, I have updated the description! |
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
} | ||
|
||
p := probe.NewProbeRepository(projectID) | ||
response, err := p.UpdateProbe(ctx, request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are still missing the part where we validate the probe type and the probe properties set match, for eg. if a user updates the probe but removes the probe properties that will be a problem and should be caught.
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Added nil checks for probe properties, PTAL @gdsoumya @S-ayanide |
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
…muschaos#4116) * Added probes graphql schema in backend Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added mongo schema for probes and updated experiment schema Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added handler functions for probes Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Updated operator version in subscriber Signed-off-by: Saranya-jena <saranya.jena@harness.io> * removed redundant types in GQL n mongo schema Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added checks for updateProbe Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added nil checks for update probe Signed-off-by: Saranya-jena <saranya.jena@harness.io> * fixed imports Signed-off-by: Saranya-jena <saranya.jena@harness.io> * resolved conflicts and errors Signed-off-by: Saranya-jena <saranya.jena@harness.io> --------- Signed-off-by: Saranya-jena <saranya.jena@harness.io>
Proposed changes
Added Resilience Probes as resource:
Resilience Probes are reusable pluggable checks that could be used with any chaos experiment, this features promotes minification of YAML by generating all probe metadata in the backend and only providing a reference in chaos engine annotations. Adhering to the 'Write once, Use anywhere' paradigm, this approach promotes the reuse of the same/new probe instead of creating a brand new one each time a chaos experiment is executed/edited. Currently, it supports HTTP, CMD, Kubernetes and Prometheus Probes.
Summarize your changes here to communicate with the maintainers and make sure to put the link to that issue
Types of changes
What types of changes does your code introduce to Litmus? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Dependency
Special notes for your reviewer: