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

save config api for upgrade service #4681

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

cbodonnell
Copy link
Contributor

@cbodonnell cbodonnell commented Jun 13, 2024

What this PR does / why we need it:

This PR adds an API endpoint to the upgrade service for saving config. The handler will trigger preflights to run in the background after successfully saving the config and rendering the base archive.

Which issue(s) this PR fixes:

https://app.shortcut.com/replicated/story/105494/upgrade-service-api-side-of-the-config-page-in-the-deployment-wizard

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?


Does this PR require documentation?

@cbodonnell cbodonnell added the type::feature New feature or request label Jun 13, 2024
@cbodonnell cbodonnell changed the title Cbo/sc 105494/kots upgrader config api kots upgrader config api Jun 13, 2024
@cbodonnell cbodonnell changed the base branch from main to kots-upgrader June 13, 2024 17:30
@cbodonnell cbodonnell force-pushed the cbo/sc-105494/kots-upgrader-config-api branch 3 times, most recently from f86b6a3 to 500848e Compare June 13, 2024 21:39
@cbodonnell cbodonnell changed the title kots upgrader config api save config api for upgrade service Jun 14, 2024
@cbodonnell cbodonnell force-pushed the cbo/sc-105494/kots-upgrader-config-api branch 2 times, most recently from c71219c to 0912496 Compare June 14, 2024 17:18
@cbodonnell cbodonnell force-pushed the cbo/sc-105494/kots-upgrader-config-api branch from 3c4353d to e759d7f Compare June 14, 2024 18:36
@cbodonnell cbodonnell marked this pull request as ready for review June 14, 2024 18:36
@@ -141,8 +142,23 @@ func Run(appID string, appSlug string, sequence int64, isAirgap bool, archiveDir
var preflightErr error
defer func() {
if preflightErr != nil {
err := setPreflightResult(appID, sequence, &types.PreflightResults{}, preflightErr)
preflightResults := &types.PreflightResults{
Copy link
Member

Choose a reason for hiding this comment

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

how about combining this with the setResults function below? it can also be defined outside of entire function to make it smaller. same for setProgress.

@@ -18,7 +18,7 @@ import (

// Execute will Execute the preflights using spec in preflightSpec.
// This spec should be rendered, no template functions remaining
func Execute(preflightSpec *troubleshootv1beta2.Preflight, ignorePermissionErrors bool, setProgress func(progress map[string]interface{}) error, setResults func(results *types.PreflightResults) error) (*types.PreflightResults, error) {
func Execute(preflightSpec *troubleshootv1beta2.Preflight, ignorePermissionErrors bool, setProgress func(progress map[string]interface{}) error, setResults func(results *types.PreflightResults, runError error) error) (*types.PreflightResults, error) {
Copy link
Member

Choose a reason for hiding this comment

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

why is runError param needed here?

preflightData, err := getPreflightData()
if err != nil {
return errors.Wrap(err, "failed to get preflight data")
}
preflightData.Results = results
if runError != nil {
if preflightData.Results.Errors == nil {
Copy link
Member

Choose a reason for hiding this comment

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

sorry to be nit picky, but to be consistent with the other implementation, let's update results before updating preflightData.Results. would probably look cleaner.

@cbodonnell cbodonnell merged commit b4deb57 into kots-upgrader Jun 14, 2024
95 of 104 checks passed
@cbodonnell cbodonnell deleted the cbo/sc-105494/kots-upgrader-config-api branch June 14, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants