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

roll out reporting #1559

Merged
merged 6 commits into from
Jan 25, 2021
Merged

roll out reporting #1559

merged 6 commits into from
Jan 25, 2021

Conversation

mudash
Copy link
Contributor

@mudash mudash commented Nov 25, 2020

Signed-off-by: Mudassar Shafique 15931574+mudash@users.noreply.github.com

Description

This includes set of changes that:

  • add the chef-automate-collect call after the Chef Policy call in the main wrapper if the environment variables are set appropriately
  • retries the http request in case of internal server error
  • refactors a little bit for chef cli wrapper flow

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

Signed-off-by: Mudassar Shafique <15931574+mudash@users.noreply.github.com>
@netlify
Copy link

netlify bot commented Nov 25, 2020

Deploy preview for chef-workstation processing.

Building with commit b41211e

https://app.netlify.com/sites/chef-workstation/deploys/600f10a511ba500007e5234a

@marcparadise
Copy link
Member

In report_new_rollout.go, the messaging for error codes 500 and 501 is incorrect - could you update that to let those pass through to the default error handler in the case?

@@ -47,6 +49,21 @@ func main() {
case "report", "capture":
cmd = exec.Command(dist.AnalyzeExec, allArgs...)

case "push", "push-archive":
cmd = exec.Command(dist.WorkstationExec, allArgs...)
Copy link
Member

Choose a reason for hiding this comment

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

Let's update this so that if Rollouts are enabled but not configured correctly in validateRolloutSetup, we fail with the error message before we perform the push. When CHEF_AC_ROLLOUT_ENABLED is set, the operator intent of using Rollouts is clear - so if it's not possible to use them, it should be an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good. I have addressed it so we will error out and will not do the policy push if the required setup isn't complete.

runCmd(cmd)
if validateRolloutSetup() {
policyGroup := fmt.Sprintf("-g%s", allArgs[1])
policyLockFile := fmt.Sprintf("-l%s", allArgs[2])
Copy link
Member

Choose a reason for hiding this comment

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

formatted strings should probably be quoted in output, in case of something like a filename with spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used a different approach in the updates now.

Signed-off-by: Mudassar Shafique <15931574+mudash@users.noreply.github.com>
@mudash
Copy link
Contributor Author

mudash commented Jan 25, 2021

In report_new_rollout.go, the messaging for error codes 500 and 501 is incorrect - could you update that to let those pass through to the default error handler in the case?

This mechanism was sitting there from original version, I have changed it to route to the default case.

Signed-off-by: Mudassar Shafique <15931574+mudash@users.noreply.github.com>
@mudash mudash marked this pull request as ready for review January 25, 2021 16:11
@mudash mudash requested review from a team as code owners January 25, 2021 16:11
runCmd(cmd)
allArgs = []string{"report-new-rollout", "-g", allArgs[1], "-l", allArgs[2],
"-s", os.Getenv("CHEF_AC_SERVER_URL"), "-u", os.Getenv("CHEF_AC_SERVER_USER")}
cmd = exec.Command(dist.AutomateCollectExec, allArgs...)
Copy link
Member

Choose a reason for hiding this comment

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

For future iterations, I wonder if we can do this more transactionally - first, create the rollout record successfully in automate, then update the results after we execute the command. This way even if the final update fails, we're guaranteed to have some record of the rollout before we proceed to push the policy.

@@ -0,0 +1,69 @@
//
// Copyright 2019 Chef Software, Inc.
Copy link
Member

@marcparadise marcparadise Jan 25, 2021

Choose a reason for hiding this comment

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

Copyright © 2021 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Good reminder :)


func Test_validateRolloutSetup_Invalid(t *testing.T) {

os.Setenv("CHEF_AC_SERVER_URL", "http://testhost")
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd test for each var being recognized as required, and not just the one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, more is better, updated.

Copy link
Member

@marcparadise marcparadise left a comment

Choose a reason for hiding this comment

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

Thanks @mudash . This looks like a good place from which to build. I've left a couple of minor comments inline.

Signed-off-by: Mudassar Shafique <15931574+mudash@users.noreply.github.com>
@mudash mudash merged commit 8af7aca into master Jan 25, 2021
@mudash mudash deleted the mshafique/rollout-reporting branch January 25, 2021 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants