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

Implement a synchronous purge endpoint #711

Merged

Conversation

loicalbertin
Copy link
Member

Pull Request description

Description of the change

What I did

  • Added a new API endpoint POST /deployments/<id>/purge[?force]
  • Added a purge command on CLI
  • Added a PURGE_FAILED deployment status

How to verify it

  1. Deploy an application
  2. ensure that alien is not running as it may auto-purge the application using the old way
  3. use the CLI to try to purge the deployed application => you should not be able to do it as deployment is not in undeployed state
  4. undeploy the deployment using the CLI without the purge option
  5. change the owner of the work/deployments/<depid> folder in order to generate an error when purging the deployment
  6. use the CLI to try to purge the deployed application => Yorc should failed
  7. use the CLI to force purge the deployed application => deployment should be purged (do not appear anymore in yorc d list) but with an error
  8. change back the owner in order to allow Yorc to remove the work/deployments/<depid> folder
  9. use the CLI to force purge the deployed application => purge should be OK and the work/deployments/<depid> folder should not exist anymore

Description for the changelog

  • Add a new synchronous purge API endpoint (GH-707)

Applicable Issues

Fixes #707

- Added a new API endpoint `POST /deployments/<id>/purge[?force]`
- Added a purge command on CLI
- Added a PURGE_FAILED deployment status
}
if len(errs.Errors) > 0 {
w.WriteHeader(http.StatusInternalServerError)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

set the status in case of success ?
} else {
w.WriteHeader(http.StatusOK)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not necessary:

// If WriteHeader has not yet been called, Write calls
// WriteHeader(http.StatusOK) before writing the data.
https://pkg.go.dev/net/http#ResponseWriter

Copy link
Member Author

Choose a reason for hiding this comment

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

But you are right if we do not set it we do not record it in the telemetry handler

Copy link
Contributor

@laurentganne laurentganne left a comment

Choose a reason for hiding this comment

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

Looks good!

@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
@ystia ystia deleted a comment from codeclimate bot Jan 8, 2021
even in nominal mode.
In case of error then the deployment status is set to PURGE_FAILED
@sonarcloud
Copy link

sonarcloud bot commented Jan 27, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

86.0% 86.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_151) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 11.
Read more here

@sonarcloud
Copy link

sonarcloud bot commented Mar 29, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

86.0% 86.0% Coverage
0.0% 0.0% Duplication

@laurentganne laurentganne merged commit 4a7538e into develop Mar 29, 2021
@laurentganne laurentganne deleted the feature/GH-707_Add_a_new_synchronous_purge_API_endpoint branch March 29, 2021 15:04
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.

Add a new synchronous purge API endpoint
2 participants