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

Ability to specify the value of the hostname an app task is running on. #2679

Closed
bradleyreeves opened this issue Nov 19, 2015 · 21 comments
Closed

Comments

@bradleyreeves
Copy link

Perhaps I am mistaken, but it seems there is currently no way to dynamically reference the hostname of a task and use it as an env variable value. I'm sure the use cases for this are obvious and many.

Edit:
To be specific: currently, the json usage
"env": {
"CASSANDRA_BROADCAST_ADDRESS":"$HOSTNAME"
}
will set CASSANDRA_BROADCAST_ADDRESS to the value "$HOSTNAME", instead of trying to resolve it to a valid hostname based on the machine the task is then run on.
/Edit

This is exceptionally useful when working with docker apps that will use the conatiner's hostname as a default for some env variable, and it needs to be overridden to the actual machine's hostname.

A good example: https://hub.docker.com/_/cassandra/
Edit:
Using the value "CASSANDRA_BROADCAST_ADDRESS":"auto" would set the value to the container hostname, instead of the machine hostname.

@jeromegn
Copy link

+1

We also need a similar feature for logging purposes, we would need to be able to set parameters on our docker containers like: { "key": "log-opt", "value": "tag=$MESOS_TASK_ID" }. That's for syslog, it's much easier to find logs for specific containers that way.

@kolloch
Copy link
Contributor

kolloch commented Nov 23, 2015

Have a look at the wild discussions here: #1828

@jeromegn: It probably makes sense to use separate issues for substituting variables (which have to be known to Marathon BEFORE the task launch) in the env variables and in other places.

I can completely understand the usefulness of this. It is hard to do right and might not be worked on soon by us. In the meantime, you can work around most of these issues by creating your own docker images which set the desired environment variables before starting the main process.

@jeromegn
Copy link

Thanks @kolloch.

It so happens that you can specify some variables to be interpolated in the parameters (like the short container ID via "your-app/{{.ID}}".) For now that satisfies our needs.

@cookandy
Copy link

+1

A valid use case would be setting the hostname of a container to the hostname of the machine it is started on. For example:

 "parameters": [
                { "key": "hostname", "value": "$HOSTNAME" }
            ]

@adkhare
Copy link

adkhare commented Feb 2, 2016

Do we have any plans on this issue?

@alaa
Copy link

alaa commented Mar 23, 2016

+1

2 similar comments
@MattFriedman
Copy link

+1

@erSitzt
Copy link

erSitzt commented Apr 15, 2016

+1

@nicbet
Copy link

nicbet commented Apr 15, 2016

+1

Having the docker host, that a container was placed on by Marathon, available in an ENV variable to the container would significantly simplify some of our routing and service discovery mechanisms, without the need to build custom base images with customized logic for discovering that very information before the main application in the container executes.

@jrrickard
Copy link

+1

9 similar comments
@endzyme
Copy link

endzyme commented Jul 18, 2016

+1

@elan100cs
Copy link

+1

@sdouglasnelson
Copy link

+1

@JianTangAxa
Copy link

+1

@raghu999
Copy link

raghu999 commented Oct 1, 2016

+1

@arnoldcano
Copy link

+1

@raveeolee
Copy link

+1

@marcosdotps
Copy link

+1

@willyhoang
Copy link

+1

@jdef
Copy link
Contributor

jdef commented Feb 15, 2017

@jasongilanfarr indirectly related to template discussion

@meichstedt
Copy link
Contributor

Note: This issue has been migrated to https://jira.mesosphere.com/browse/MARATHON-4203. For more information see https://groups.google.com/forum/#!topic/marathon-framework/khtvf-ifnp8.

@mesosphere mesosphere locked and limited conversation to collaborators Mar 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests