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(kumactl) validate that the control plane is running #309

Merged
merged 3 commits into from
Oct 10, 2019

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

Validation before the control plane is added that it is valid running API Server of Kuma.

Full changelog

  • Implement validation that the control plane is running

Issues resolved

Fix #181

@@ -1,5 +1,13 @@
package v1alpha1

import (
"encoding/json"
api_server "github.com/Kong/kuma/pkg/api-server"
Copy link
Contributor

Choose a reason for hiding this comment

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

client dependency on the entire api-server package doesn't look right.

Let's move IndexResponse into pkg/api-server/types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved

return nil
}

func validateCpCoordinates(cp *ControlPlane) error {
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 expect this kind of logic inside pkg/config/...

Let's move it either to app/kumactl/cmd/config/ or to app/kumactl/pkg/config/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to app/kumactl/pkg/config/

}

func validateCpCoordinates(cp *ControlPlane) error {
resp, err := http.Get(cp.Coordinates.ApiServer.Url)
Copy link
Contributor

Choose a reason for hiding this comment

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

No connection timeout ?

Copy link
Contributor Author

@jakubdyszkiewicz jakubdyszkiewicz Oct 8, 2019

Choose a reason for hiding this comment

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

Good point, went with timeout with context, so we fail on connection timeout as well as read/socket timeout. (it was also easier to test)

@@ -56,13 +60,14 @@ func (cfg *Configuration) GetControlPlane(name string) (int, *ControlPlane) {
return -1, nil
}

func (cfg *Configuration) AddControlPlane(cp *ControlPlane) bool {
func (cfg *Configuration) AddControlPlane(cp *ControlPlane) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we revert to the original version with bool return type ?

So that all methods inside config_helpers.go consistently return bool

Copy link
Contributor Author

@jakubdyszkiewicz jakubdyszkiewicz Oct 10, 2019

Choose a reason for hiding this comment

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

Reverted

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.

kumactl: verify the API server is valid and responsive
2 participants