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

Expose method and expected status code on http checks #122

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gkze
Copy link

@gkze gkze commented Dec 22, 2023

No description provided.

Copy link
Owner

@F1bonacc1 F1bonacc1 left a comment

Choose a reason for hiding this comment

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

Hey @gkze,

Thanks for your PR!!
Look really good!

There are a few minor requests:

  1. The transition from http_get to http breaks backward compatibility. Can we support both? We can say that it will be deprecated later with a code that I shared with you in the comment.
  2. Can you please add tests that validate the new default values GET and 200.
  3. Can you please add the Method to the renderer?
  4. I think this new and shiny functionality deserves documentation.

Cheers!

"net/url"
"strings"
)

type Probe struct {
Exec *ExecProbe `yaml:"exec,omitempty"`
HttpGet *HttpProbe `yaml:"http_get,omitempty"`
Http *HttpProbe `yaml:"http,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

This breaks backward compatibility.
Do you think we can have both http and http_get fields at the same time?
Even nicer would be to use the deprecation warning:
https://github.com/F1bonacc1/process-compose/blob/main/src/types/deprecation.go

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, will do. Can you give an example of how this is done?

Copy link
Owner

Choose a reason for hiding this comment

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

Certainly.
Check out this commit as an example:
45fceb3

I mistakenly used on-failure instead of on_failure, once discovered I kept both of them:

  1. I issued a warning during the first month after deprecation.
  2. Error + 5s sleep during the second month
  3. Exit 1 after that.

I would go ahead and add the deprecationCheck to validators.go and assign the http_get values (if exist) to http (if not defined) in mutators.go.

If that's too many steps, let me know and I will add this content.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the delay just getting back to this. I now realize that leaving both http_get and http we would need to make them mutually exclusive right? What should the behavior be in that case? I'm thinking failing parsing / validation if both of them are set, so that would mean changing the signature of Probe.validateAndSetDefaults(). Let me know your thoughts.

Copy link
Owner

Choose a reason for hiding this comment

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

IMO in case both of them are defined you can fail the loading in loader.validators.go.
Please let me know if you need any help with this feature.

src/health/probe_test.go Show resolved Hide resolved
src/loader/mutators.go Show resolved Hide resolved
Copy link

sonarcloud bot commented Jan 10, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

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.

None yet

2 participants