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

Send an empty payload if a cluster was not found #227

Merged
merged 1 commit into from
May 24, 2023

Conversation

fabriziosestito
Copy link
Member

This PR sends an empty payload if a cluster was not found, instead of returning from the discovery loop.
This is useful in the delta deregistration to remove a host from a cluster if previously it was part of it.

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

A little change request

internal/discovery/cluster.go Outdated Show resolved Hide resolved
@fabriziosestito fabriziosestito force-pushed the send-empty-payload-on-cluster-not-found branch from c5209f5 to 2c3aa2c Compare May 24, 2023 07:09
@fabriziosestito fabriziosestito requested a review from arbulu89 May 24, 2023 07:09
@arbulu89
Copy link
Contributor

@fabriziosestito As talked offline, with the current change this is the payload that is generated:

{"agent_id":"xxx","discovery_type":"ha_cluster_discovery","payload":{"Cib":{"Configuration":{"CrmConfig":{"ClusterProperties":null},"Nodes":null,"Resources":{"Primitives":null,"Masters":null,"Clones":null,"Groups":null},"Constraints":{"RscLocations":null}}},"Crmmon":{"Version":"","Summary":{"Nodes":{"Number":0},"LastChange":{"Time":""},"Resources":{"Number":0,"Disabled":0,"Blocked":0},"ClusterOptions":{"StonithEnabled":false}},"Nodes":null,"NodeAttributes":{"Nodes":null},"NodeHistory":{"Nodes":null},"Resources":null,"Clones":null,"Groups":null},"SBD":{"Devices":null,"Config":null},"Id":"","Name":"cib-bootstrap-options-cluster-name","DC":false,"Provider":""}}

I think the cluster variable is not nil in this case.

@fabriziosestito fabriziosestito force-pushed the send-empty-payload-on-cluster-not-found branch from 2c3aa2c to fd262e4 Compare May 24, 2023 08:42
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Good!
Now we have:

{"agent_id":"xxx","discovery_type":"ha_cluster_discovery","payload":null}

If sending null in the payload is good enough for the backend (you might know more on that than me hehe), the code works as expected

func NewClusterWithDiscoveryTools(discoveryTools *DiscoveryTools) (Cluster, error) {
var cluster = Cluster{
func NewClusterWithDiscoveryTools(discoveryTools *DiscoveryTools) (*Cluster, error) {
commandExecutor := utils.Executor{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have you changed the order of the things here?
Was something wrong?
Or is it simply to avoid the declaration of a not needed var?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or is it simply to avoid the declaration of a not needed var?

this

@fabriziosestito fabriziosestito merged commit d0279a4 into main May 24, 2023
@fabriziosestito fabriziosestito deleted the send-empty-payload-on-cluster-not-found branch May 24, 2023 11:57
@arbulu89 arbulu89 added the enhancement New feature or request label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants