Skip to content

Conversation

@yulunli
Copy link
Contributor

@yulunli yulunli commented Jun 20, 2017

Always reject pings from wrong app name

Copy link
Contributor

@mennopruijssers mennopruijssers left a comment

Choose a reason for hiding this comment

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

As stated before: I strongly suggest implementing some integration tests in ringpop-common as well.

SelfEvict SelfEvictOptions

// If set to true, ping requests without identical app name return error
RequiresAppInPing bool
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of this field doesn't really reflect the behaviour. RequiresIdenticalAppName might make more sense. The fact that this is enforced during pings is an implementation detail

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, it is actually handled as a RequiresAppInPing ping_handler.go:41...
Either change behaviour and name or the comment above

swim/node.go Outdated
PingRatio: .4,
},

RequiresAppInPing: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed: the zero value of a bool is already false.


if req.App == "" {
if node.requiresAppInPing {
node.logger.Warnf("Rejected ping from unknown ringpop app %s", req.App)
Copy link
Contributor

Choose a reason for hiding this comment

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

req.App will always be empty here.

}
} else {
if req.App != node.app {
node.logger.Warnf("Rejected ping from wrong ringpop app %s", req.App)
Copy link
Contributor

Choose a reason for hiding this comment

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

normally we would use something like node.logger.WithField("app", req.App).Warn("Rejected ping from wrong ringpop app"). That way searching in ES is easier because all the messages are the same.

Changes: changes,
Source: node.Address(),
SourceIncarnation: node.Incarnation(),
App: node.app,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the reason why the integration tests are failing due to a json-schema validation error. You only added app to ping-request while also sending in the ping-response here.

Copy link
Contributor

@mennopruijssers mennopruijssers left a comment

Choose a reason for hiding this comment

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

two comments left, but looks good to me (if build passes now ;))

if req.App == "" {
if node.requiresAppInPing {
node.logger.Warnf("Rejected ping from unknown ringpop app %s", req.App)
node.logger.WithFields("req", req).Warnf("Rejected ping from unknown ringpop app")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add the full req. It could be huge (due to Changes). Source might be enough.

} else {
if req.App != node.app {
node.logger.Warnf("Rejected ping from wrong ringpop app %s", req.App)
node.logger.WithFields("req", req).Warn("Rejected ping from wrong ringpop app")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same but also consider adding req.App

Always reject pings from wrong app name
@yulunli yulunli force-pushed the enforce_app branch 2 times, most recently from d82e843 to a2e53a1 Compare June 20, 2017 23:01
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.

3 participants