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

feat(environments): Preflight cli changes #246

Merged
merged 23 commits into from
Feb 9, 2022
Merged

Conversation

anna-cross
Copy link
Contributor

@anna-cross anna-cross commented Feb 7, 2022

Description of change

We want to be able to see preflight check information on cli when creating an environment. On 'meroxa env describe' we will lis t full environment information with preflight checks. When creating an environment, we want to log to console if preflight check is successful or errored out.

Fixes #245

Type of change

  • New feature
  • Bug fix
  • Refactor
  • Documentation

How was this tested?

  • Unit Tests
  • Tested in staging

Demo

Before the Changes:

Creating bad environment with not enough permissions

image

Describing bad environment that failed to provision

image

After the Changes :

Creating bad environment with not enough permissions

image

Describing bad environment that failed to provision

image

Repairing environment after giving necessary permissions

image

Additional references

Documentation updated

N/A

@janelletavares janelletavares marked this pull request as ready for review February 8, 2022 00:11
@janelletavares janelletavares requested review from a team, owenthereal and ericcheatham and removed request for a team February 8, 2022 00:12
@dianadoherty
Copy link
Contributor

can you add before and after exampled for each command?

@@ -54,7 +53,7 @@ type Create struct {
Type string `long:"type" usage:"environment type, when not specified"`
Provider string `long:"provider" usage:"environment cloud provider to use"`
Region string `long:"region" usage:"environment region"`
Config []string `short:"c" long:"config" usage:"environment configuration based on type and provider (e.g.: --config aws_access_key_id=my_access_key --config aws_access_secret=my_access_secret)"` // nolint:lll
Config []string `short:"c" long:"config" usage:"environment configuration based on type and provider (e.g.: --config aws_access_key_id=my_access_key --config aws_secret_access_key=my_access_secret)"` // nolint:lll
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch!

Copy link
Contributor

@janelletavares janelletavares left a comment

Choose a reason for hiding this comment

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

i'm biased, but i think these changes are looking pretty good

@anna-cross
Copy link
Contributor Author

can you add before and after exampled for each command?

Added! Let me know if we are good to merge this or anything else needs to be updated :)

@dianadoherty
Copy link
Contributor

dianadoherty commented Feb 9, 2022

There seems to be an inconsistency in spacing Describing bad environment that failed to provision and Repairing environment after giving necessary permissions

I'd also prefer for the output of Creating bad environment with not enough permissions to be in the same format as the describe

Comment on lines 89 to 93
text := fmt.Sprintf("Environment %q could not be repaired because it failed the preflight checks.", name)
details := utils.EnvironmentPreflightTable(rr)
text += fmt.Sprintf("\n%s\n", details)

r.logger.Errorf(ctx, text)
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend staying consistent between all operations. This is an operation code taken from create that seems a little neater

Suggested change
text := fmt.Sprintf("Environment %q could not be repaired because it failed the preflight checks.", name)
details := utils.EnvironmentPreflightTable(rr)
text += fmt.Sprintf("\n%s\n", details)
r.logger.Errorf(ctx, text)
details := utils.EnvironmentPreflightTable(rr)
c.logger.Errorf(ctx,
"Environment %q could not be repaired because it failed the preflight checks\n%s\n",
environment.Name,
details)

environment.Name,
details)
} else {
environment.Status.PreflightDetails = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's necessary to clear out preflight check details. Customers might want to see this info in the --json command

Suggested change
environment.Status.PreflightDetails = nil

Comment on lines 94 to 104
} else if state == meroxa.EnvironmentStateRepairing || state == meroxa.EnvironmentStatePreflightSuccess {
r.logger.Infof(ctx, `The repairment of your environment %q is now in progress and your environment will be up and running soon.`, r.args.NameOrUUID) // nolint:lll
} else if state == meroxa.EnvironmentStateRepairingError || state == meroxa.EnvironmentStateUpdatingError ||
state == meroxa.EnvironmentStateProvisioningError || state == meroxa.EnvironmentStateDeprovisioningError {
text := fmt.Sprintf("Environment %q could not be repaired.", r.args.NameOrUUID)
if details, err := utils.PrettyString(rr.Status.Details); err == nil {
text += fmt.Sprintf("\n%s\n", details)
}
r.logger.Infof(ctx, text)
}
r.logger.Infof(ctx, `Run "meroxa env describe %s" for status.`, r.args.NameOrUUID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} else if state == meroxa.EnvironmentStateRepairing || state == meroxa.EnvironmentStatePreflightSuccess {
r.logger.Infof(ctx, `The repairment of your environment %q is now in progress and your environment will be up and running soon.`, r.args.NameOrUUID) // nolint:lll
} else if state == meroxa.EnvironmentStateRepairingError || state == meroxa.EnvironmentStateUpdatingError ||
state == meroxa.EnvironmentStateProvisioningError || state == meroxa.EnvironmentStateDeprovisioningError {
text := fmt.Sprintf("Environment %q could not be repaired.", r.args.NameOrUUID)
if details, err := utils.PrettyString(rr.Status.Details); err == nil {
text += fmt.Sprintf("\n%s\n", details)
}
r.logger.Infof(ctx, text)
}
r.logger.Infof(ctx, `Run "meroxa env describe %s" for status.`, r.args.NameOrUUID)
} else {
c.logger.Infof(ctx,
"Preflight checks have passed. Environment %q is being repaired. Run `meroxa env describe %s` for status",
environment.Name,
environment.Name)
}

Comment on lines 116 to 128
text := fmt.Sprintf("Environment %q could not be updated.", c.args.NameOrUUID)
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)
} else if state == meroxa.EnvironmentStatePreflightError {
text := fmt.Sprintf("Environment %q could not be updated because it failed the preflight checks.", c.args.NameOrUUID)
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)

} else {
c.logger.Infof(ctx, "Environment %q has been updated. Run `meroxa env describe %s` for status", environment.Name, environment.Name)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
text := fmt.Sprintf("Environment %q could not be updated.", c.args.NameOrUUID)
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)
} else if state == meroxa.EnvironmentStatePreflightError {
text := fmt.Sprintf("Environment %q could not be updated because it failed the preflight checks.", c.args.NameOrUUID)
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)
} else {
c.logger.Infof(ctx, "Environment %q has been updated. Run `meroxa env describe %s` for status", environment.Name, environment.Name)
}
details := utils.EnvironmentPreflightTable(rr)
c.logger.Errorf(ctx,
"Environment %q could not be updated because it failed the preflight checks\n%s\n",
environment.Name,
details)
} else {
c.logger.Infof(ctx,
"Preflight checks have passed. Environment %q is being updated. Run `meroxa env describe %s` for status",
environment.Name,
environment.Name)
}

@janelletavares janelletavares changed the title Preflight cli changes feat(environments): Preflight cli changes Feb 9, 2022
@anna-cross anna-cross merged commit 75e2e88 into master Feb 9, 2022
@anna-cross anna-cross deleted the preflight_cli_changes branch February 9, 2022 23:45
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.

[Stage 2: CLI] Display Preflight checks on create & update
3 participants