mantl / mesos-consul

Mesos to Consul bridge for service discovery
Apache License 2.0
338 stars 95 forks source link

Question: mesos-consul interaction with marathon folder #63

Open kamaradclimber opened 8 years ago

kamaradclimber commented 8 years ago

Marathon framework recently introduced folders to group application.

The effect on mesos task is to prefix the task name by the name of the prefix and an underscore. For instance:

/my/group/application

will have tasks named:

my_group_application.16836b3f-d40e-11e5-b006-c4346bb5c9dc 

Consul recommends to use dns compatible names which does not include underscores.

What would be you recommendation to cope with those names? Could we consider a way to rewrite task names to replace underscores ?

ChrisAubuchon commented 8 years ago

mesos-consul currently strips '_'s from the task name.

my_group_application.16836b3f-d40e-11e5-b006-c4346bb5c9dc

would be registered as

mygroupapplication.16836b3f-d40e-11e5-b006-c4346bb5c9dc

I'm not sure what else we can do. It would be nice to register it as /my/group/application in Consul but the service API doesn't support grouping.

kamaradclimber commented 8 years ago

thanks for your response.

I think service name would make more sense if the underscore was replaced by an hyphen. It would reflect the hierarchy that marathon users are trying to define.

What do you think?

Maybe we could have this as an option?

kamaradclimber commented 8 years ago

@ChrisAubuchon would you accept a PR to replace _ by - instead of blank ?

Would you prefer to have the replacement character passed as an option and default to blank ?

ChrisAubuchon commented 8 years ago

Sure. I don't have a preference to be honest. It'd be nice if consul had service groups though.

kamaradclimber commented 8 years ago

Sadly, I thought mesos-consul uses the task ID to name the service and just discovered it uses the tasks name.

In the case of marathon, task name are completely different when using a folder The application /my_group/application in marathon will be named application.my_group.

I need to find another patch.

kamaradclimber commented 8 years ago

The behavior is challenged in mesosphere/marathon#3163

kamaradclimber commented 8 years ago

I've implemented a patch to use the taskID instead of the taskName to name services. https://github.com/criteo-forks/mesos-consul/commit/1ff7a6b1f5aac637d46a526e1fd1a1fdb45c11da

However I thinks this is very specific (will help only marathon users and might break other frameworks users).

@ChrisAubuchon coudl you reopen this issue ? I would be glad to take your input on a way to solve the issue.