Resiliency Feature Draft (krknctl)#82
Conversation
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
|
Hii @tsebastiani, I have added the env flag for the krkn-mode, let me know if its the right approach? |
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
|
In my last commit I have updated the Scenario struct, and added ResiliencyConfig into it which is essentially will be a String containing the path of that specific scenario resiliency config. |
| } | ||
| }, | ||
| { | ||
| "name": "krkn-run-mode", |
There was a problem hiding this comment.
unfortunately that's the wrong place, this is the dummy scenario containerfile, you have to open a PR in the krkn source repo from where the image is built:
https://github.com/krkn-chaos/krkn/blob/main/containers/krknctl-input.json
…ge Scenario struct to recieve weight and config Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
| var resiliencyWeights []float64 | ||
| runStartTime := time.Now().UTC() | ||
|
|
||
| reportRegex := regexp.MustCompile(`^KRKN_RESILIENCY_REPORT_JSON:(.*)$`) |
There was a problem hiding this comment.
please move the regex in the config.json as all the other regex and const strings.
| // inject resiliency config as env variable if provided (Use Case: Resiliency Config is provided via env variable) | ||
| if scenario.ResiliencyConfigPath != "" { | ||
| if content, err := os.ReadFile(scenario.ResiliencyConfigPath); err == nil { | ||
| env["RESILIENCY_CONFIG"] = string(content) |
There was a problem hiding this comment.
are you sure that passing the file content as it is will work in any condition? don't you think that serializing the file content in base64 for example might ensure that the file structure (including indentation, spacing quotes etc.) is safely kept?
There was a problem hiding this comment.
Yes, I should be serializing the file, and I’ll make that update.
For the custom resiliency config, we could mount the entire file via a volume, but if the environment-variable approach I used doesn’t introduce any edge cases, I think the current method should be fine. Let me know if you see any problems with this.
| } | ||
| } | ||
| runEndTime := time.Now().UTC() | ||
| _ = runStartTime |
There was a problem hiding this comment.
What's the point of these void initializations?
214d70a to
98be58e
Compare
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
…dd the env variable Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
…_ALERTS_YAML_CONTENT, remove ResiliencyConfig from Scenario, serialize ResiliencyConfig YAML file to base64 and inject it as env variable Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
|
Hi everyone, Following up on the krkn PR.... Summary of changes:
In krknctl you have to provide the prometheus url in the env, it will enable the resiliency feature automatically. Let me know what you think about its working! |
cmd/run.go
Outdated
| return cerr | ||
| } | ||
| defer file.Close() | ||
| mw := io.MultiWriter(os.Stdout, file) |
There was a problem hiding this comment.
@abhinavs1920 please add a comment here to explain how the thing works because might be confusing. Explain that you're multiplexing a file and stdout to with a multiwriter and that the container stdout and stderr will written in the machine stdout and in the file. Thanks!
| if prom, ok := env["PROMETHEUS_URL"]; ok { | ||
| promURL = prom | ||
| } | ||
| env["RESILIENCY_ENABLED_MODE"] = resiliency.ComputeResiliencyMode(promURL, config) |
There was a problem hiding this comment.
Please add these string constraints like RESILIENCY_ENABLED_MODE KRKN_ALERTS_YAML_CONTENT etc. to the config.
pkg/resiliency/resiliency.go
Outdated
|
|
||
| func PrintHumanSummary(report FinalReport) { | ||
| if data, err := json.MarshalIndent(report, "", " "); err == nil { | ||
| fmt.Printf("Overall Resiliency Report Summary:\n%s\n", string(data)) |
There was a problem hiding this comment.
logs must be lowercased (except for acronyms)
pkg/resiliency/resiliency.go
Outdated
| } | ||
|
|
||
| // 2. Nested under telemetry.overall_resiliency_report. | ||
| type root2 struct { |
There was a problem hiding this comment.
do not use numbers in types and variable names
cmd/utils.go
Outdated
| promURL = prom.value | ||
| } | ||
| mode := resiliency.ComputeResiliencyMode(promURL, cfg) | ||
| environment["RESILIENCY_ENABLED_MODE"] = ParsedField{value: mode, secret: false} |
There was a problem hiding this comment.
RESILIENCY_ENABLED_MODE must be in the config file
cmd/run.go
Outdated
|
|
||
| if !runDetached { | ||
| // capture stdout/stderr to both terminal and a log file for parsing | ||
| filename := fmt.Sprintf("%s.log", containerName) |
There was a problem hiding this comment.
bytes.Buffer, not in a file.
pkg/resiliency/resiliency.go
Outdated
| Overall OverallResiliencyReport `json:"overall_resiliency_report"` | ||
| } `json:"telemetry"` | ||
| } | ||
| var r2 root2 |
There was a problem hiding this comment.
please do not use numbers in variables and package aliases
pkg/resiliency/resiliency.go
Outdated
| } | ||
|
|
||
| // 3. As a map of scenario scores at root with optional aggregate values. | ||
| type root3 struct { |
There was a problem hiding this comment.
please do not use numbers in variables and package aliases
pkg/resiliency/resiliency.go
Outdated
| PassedSlos int `json:"passed_slos"` | ||
| TotalSlos int `json:"total_slos"` | ||
| } | ||
| var r3 root3 |
There was a problem hiding this comment.
please do not use numbers in variables and package aliases
pkg/resiliency/resiliency.go
Outdated
| Failed int `json:"failed"` | ||
| } `json:"breakdown"` | ||
| } | ||
| type root4 struct { |
There was a problem hiding this comment.
please do not use numbers in variables and package aliases
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
…ruct names Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Description
Documentation
If checked, a documentation PR must be created and merged in the website repository.
Related Documentation PR (if applicable)