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

upgrade service preflights api #4693

Merged
merged 34 commits into from
Jun 18, 2024

Conversation

cbodonnell
Copy link
Contributor

What this PR does / why we need it:

This PR adds two endpoints POST /preflight/run and GET /preflight/result to support running preflights and fetching preflight results, respectively.

Which issue(s) this PR fixes:

https://app.shortcut.com/replicated/story/105495/upgrade-service-api-side-of-the-preflights-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 17, 2024
@cbodonnell cbodonnell changed the base branch from main to kots-upgrader June 17, 2024 20:03
Comment on lines +176 to +186
func hasFailingStrictPreflights(results *types.PreflightResults) bool {
// convert to troubleshoot type so we can use the existing function
uploadResults := &troubleshootpreflight.UploadPreflightResults{}
uploadResults.Results = results.Results
for _, e := range results.Errors {
uploadResults.Errors = append(uploadResults.Errors, &troubleshootpreflight.UploadPreflightError{
Error: e.Error,
})
}
return troubleshootpreflight.HasStrictAnalyzersFailed(uploadResults)
}
Copy link
Contributor Author

@cbodonnell cbodonnell Jun 17, 2024

Choose a reason for hiding this comment

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

This function felt weird to write, but there are two types that are nearly identical PreflightResults and UploadPreflightResults, the latter of which is from troubleshoot. I wanted to keep using the same check for failing strict preflights, but if there's a better way to do this, I'm all ears.

Copy link
Member

Choose a reason for hiding this comment

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

it's fine for now.

Comment on lines +28 to +29
Progress string `json:"progress,omitempty"`
Result *types.PreflightResult `json:"result"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified this type to match more closely with what we store in the database


func ResetPreflightData() error {
if err := os.RemoveAll(PreflightDataFilepath); err != nil {
return errors.Wrap(err, "failed to remove preflight data")
Copy link
Member

Choose a reason for hiding this comment

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

maybe don't fail if it doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe os.RemoveAll will do this. Just switched it in dbd8cd0 for this same reason.

HasFailingStrictPreflights: hasFailingStrictPreflights(results),
}
// clear the progress once the results are set
preflightData.Progress = ""
Copy link
Member

Choose a reason for hiding this comment

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

nit pick: can this be inside the struct above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a change in 7a4d7bb to address this one

@sgalsaleh sgalsaleh force-pushed the kots-upgrader branch 2 times, most recently from a34f374 to a8058b1 Compare June 17, 2024 22:10
@cbodonnell cbodonnell merged commit daec943 into kots-upgrader Jun 18, 2024
94 of 104 checks passed
@cbodonnell cbodonnell deleted the cbo/sc-105495/upgrade-service-preflights-api branch June 18, 2024 13:49
sgalsaleh pushed a commit that referenced this pull request Jun 21, 2024
sgalsaleh pushed a commit that referenced this pull request Jun 23, 2024
sgalsaleh pushed a commit that referenced this pull request Jun 26, 2024
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.

3 participants