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

chore(env): updated the env getter function & default jobCleanUpPolicy as retain #144

Merged
merged 2 commits into from
Jun 1, 2021

Conversation

ispeakc0de
Copy link
Member

@ispeakc0de ispeakc0de commented May 13, 2021

Signed-off-by: shubhamchaudhary shubham@chaosnative.com

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

  • Marked default jobCleanupPolicy policy as retain
  • updated the env getter function

Checklist:

  • Fixes #
  • Labelled this PR & related issue with documentation tag
  • PR messages has document related information
  • Labelled this PR & related issue with breaking-changes tag
  • PR messages has breaking changes related information
  • Labelled this PR & related issue with requires-upgrade tag
  • PR messages has upgrade related information
  • Commit has unit tests
  • Commit has integration tests

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>
@ksatchit ksatchit requested review from kazukousen and uditgaurav May 17, 2021 04:52
@ksatchit
Copy link
Member

Just added @kazukousen for review - as author of a recent refactor of the same!

@ispeakc0de ispeakc0de changed the title chore(env): updated the env getter function chore(env): updated the env getter function & default jobCleanUpPolicy as retain May 17, 2021
@ispeakc0de ispeakc0de force-pushed the env-updation branch 2 times, most recently from 07b4bd5 to 40c9045 Compare May 17, 2021 16:21
kazukousen
kazukousen previously approved these changes May 19, 2021
Copy link
Contributor

@kazukousen kazukousen left a comment

Choose a reason for hiding this comment

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

updated the env getter function

looks good to me, thanks

@@ -38,6 +38,20 @@ func (engineDetails *EngineDetails) SetEngineUID(clients ClientSets) error {

//SetENV sets ENV values in experimentDetails struct.
func (expDetails *ExperimentDetails) SetENV(engineDetails EngineDetails, clients ClientSets) error {
// Setting envs from engine fields other than env
expDetails.setEnv("CHAOSENGINE", engineDetails.Name).
Copy link
Member

Choose a reason for hiding this comment

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

nit: Do we really need builder for setting ENV's. I would suggest a slice of ENV variables, as in v1.EnvVar, and then we don't have to do same function call again and again.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • Added function to exclude all the envs who contains an empty value
  • as the number of envs increases the slice size increases which can fail bch guidelines(4x lines)

pkg/utils/watchJob.go Outdated Show resolved Hide resolved
pkg/utils/watchJob.go Outdated Show resolved Hide resolved
return "", errors.Errorf("unable to delete ChaosExperiment Job name: %v, in namespace: %v, error: %v", experiment.JobName, experiment.Namespace, err)
}
case v1alpha1.CleanUpPolicyRetain:
log.Infof("[skip]: skipping the job deletion as jobCleanUpPolicy is set to {%v}", expEngine.Spec.JobCleanUpPolicy)
default:
Copy link
Member

Choose a reason for hiding this comment

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

handling for string(expEngine.Spec.JobCleanUpPolicy) == "" is already in default, no need to create new variable for this.

Copy link
Member Author

@ispeakc0de ispeakc0de May 24, 2021

Choose a reason for hiding this comment

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

it is added to handle the cases, if someone added jobCleanUpPolicy to some wrong value other than delete or retain

pkg/utils/watchJob.go Outdated Show resolved Hide resolved
pkg/utils/watchJob.go Outdated Show resolved Hide resolved
pkg/utils/watchJob.go Outdated Show resolved Hide resolved
Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>
@ksatchit ksatchit merged commit 50480d8 into litmuschaos:master Jun 1, 2021
@ispeakc0de ispeakc0de deleted the env-updation branch June 1, 2021 09:36
@ispeakc0de ispeakc0de restored the env-updation branch June 1, 2021 09:36
ksatchit pushed a commit to ksatchit/chaos-runner that referenced this pull request Jun 15, 2021
…y as retain (litmuschaos#144)

* chore(env): improved the env getter function

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* marked default jobCleanupPolicy to retain

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>
ksatchit pushed a commit that referenced this pull request Jun 15, 2021
* rm(vendor): removing the vendor directory from litmus-go (#147)

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* chore(env): updated the env getter function & default jobCleanUpPolicy as retain (#144)

* chore(env): improved the env getter function

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* marked default jobCleanupPolicy to retain

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* chore(chaosresult): updating verdict and status in chaosengine and chaosresult (#148)

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* chore(vendors): updating the target details vendors (#149)

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* Fix: Print error for some error events (#150)

Signed-off-by: udit <udit@chaosnative.com>

Co-authored-by: Shubham Chaudhary <shubham.chaudhary@mayadata.io>
Co-authored-by: Udit Gaurav <35391335+uditgaurav@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants