Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Redeploy unit in place #760

Closed
jcderr opened this issue Aug 12, 2014 · 24 comments · Fixed by #1509
Closed

Redeploy unit in place #760

jcderr opened this issue Aug 12, 2014 · 24 comments · Fixed by #1509

Comments

@jcderr
Copy link

jcderr commented Aug 12, 2014

It would be quite nice to be able to replace an existing unit in one go, if a change must be made, preserving its location.

  • fleetctl submit some.unit.service
  • fleetctl run some.unit.service
  • edit some.unit.service
  • fleetctl reload some.unit.service

Fleet should replace the unit conf in-place, stop the running unit, and restart it using the new conf.

@bcwaldon
Copy link
Contributor

@jcderr How do we handle changes in [X-Fleet] parameters? The new version of the unit file may not be able to run on the same machine.

@jcderr
Copy link
Author

jcderr commented Aug 12, 2014

I would say to re-evaluate it. If required, go ahead and reschedule it to another machine, but prefer to stay on the same machine if necessary.

@bcwaldon
Copy link
Contributor

I think we can distill this down to a scheduling optimization. When the engine reconciler runs, it needs to identify when the contents of a given unit have changed and prefer the currently-scheduled host (if one exists).

@bcwaldon bcwaldon changed the title Ability to Reload Unit Redeploy unit in place Aug 12, 2014
@nnnnathann
Copy link

I would love to see reload, or even just restart features of systemctl make their way up into fleetctl. In my case, I would use it for reloading a docker image from the repository in place similar to the following example unit:

[Unit]
Description=hello

[Service]
EnvironmentFile=/etc/environment

# Pull the image from the repository
ExecStartPre=/usr/bin/docker pull localhost:5000/hello
ExecStartPre=-/usr/bin/docker kill hello
ExecStartPre=-/usr/bin/docker rm hello

ExecStart=/usr/bin/docker run --name="hello" -p 80:80 -e HOST_IP=${COREOS_PUBLIC_IPV4} localhost:5000/hello

ExecStop=/usr/bin/docker stop hello

# ExecReload could run on fleetctl restart,
# in this case it would pull the repository again
# and restart with updated image

ExecReload=/usr/bin/docker pull localhost:5000/hello
ExecReload=-/usr/bin/docker kill hello
ExecReload=-/usr/bin/docker rm hello
ExecReload=/usr/bin/docker run --name="hello" -p 80:80 -e HOST_IP=${COREOS_PUBLIC_IPV4} localhost:5000/hello

[X-Fleet]
X-Conflicts=hello.service

This particular unit is kind of awkward because there are so many repeated commands, but the way this works is if you call systemctl restart hello.service on the host machine, it will re-pull, and re-deploy the docker image with minimal downtime between the kill and run

I'm new to this whole thing, so I might be missing something obvious too.

Thanks for the great work on coreos to everyone involved.

ryandub pushed a commit to ryandub/fleet that referenced this issue Sep 30, 2014
Starts and stops a unit in one command.

refs coreos#760
ryandub pushed a commit to ryandub/fleet that referenced this issue Sep 30, 2014
Starts and stops a unit in one command.

refs coreos#760
ryandub pushed a commit to ryandub/fleet that referenced this issue Oct 9, 2014
Starts and stops a unit in one command.
Adds support to specify SSH port for SSH based commands:
* journal
* status
* ssh
* restart

refs coreos#760
ryandub pushed a commit to ryandub/fleet that referenced this issue Oct 9, 2014
Starts and stops a unit in one command.
Adds support to specify SSH port for SSH based commands:
* journal
* status
* ssh
* restart

refs coreos#760
ryandub pushed a commit to ryandub/fleet that referenced this issue Oct 9, 2014
Starts and stops a unit in one command.
Adds support to specify SSH port for SSH based commands:
* journal
* status
* ssh
* restart

refs coreos#760
ryandub pushed a commit to ryandub/fleet that referenced this issue Oct 17, 2014
Starts and stops a unit in one command.
Adds support to specify SSH port for SSH based commands:
* journal
* status
* ssh
* restart

refs coreos#760
@bcwaldon
Copy link
Contributor

bcwaldon commented May 1, 2015

This should be easy to do now. We could accept a new unit file using something like fleetctl --overwrite start foo.service, which would trigger the reconciler on a given machine to tear down the existing unit based on a hash mismatch.

@ernado
Copy link

ernado commented May 1, 2015

👍

@Vishant0031
Copy link

which fleet version has the --overwrite option?

@Vishant0031
Copy link

Hi Brian,

Is this fix available now?

On Fri, May 1, 2015 at 9:48 AM, Brian Waldon [email protected]
wrote:

This should be easy to do now. We could accept a new unit file using
something like fleetctl --overwrite start foo.service, which would
trigger the reconciler on a given machine to tear down the existing unit
based on a hash mismatch.


Reply to this email directly or view it on GitHub
#760 (comment).

@bcwaldon
Copy link
Contributor

@vish0007 no code has been written to support this

@klausenbusk
Copy link

+1

6 similar comments
@jotsif
Copy link

jotsif commented Sep 14, 2015

+1

@lukebarton
Copy link

+1

@ghaering
Copy link

ghaering commented Nov 5, 2015

+1

@thuey
Copy link

thuey commented Dec 3, 2015

+1

@NeMO84
Copy link

NeMO84 commented Dec 8, 2015

+1

@pcross616
Copy link

+1

@maticmeznar
Copy link

+1 @bcwaldon Whats the ETA for this?

@cookandy
Copy link

+1

1 similar comment
@tylerFowler
Copy link

+1

@h0tbird
Copy link

h0tbird commented Jan 20, 2016

+1 And what about a rolling update of Global=true units?

@kayrus
Copy link
Contributor

kayrus commented Feb 5, 2016

dup #1295

@tixxdz
Copy link
Contributor

tixxdz commented Mar 17, 2016

Hi new replace functionality is in this new PR #1509 which needs testing... there are many corner cases... if you guys are still on it.

@kayrus kayrus closed this as completed Mar 22, 2016
@antrik
Copy link
Contributor

antrik commented Mar 22, 2016

@kayrus why have you closed this issue? The PR is not in yet...

@dradtke
Copy link

dradtke commented Nov 11, 2016

Here's a possible workaround for reloading a service across the fleet. Note that this isn't really tested, so it's more theoretical than anything:

# Get the IP address of each host running <name>.service, then ssh into each one
# and reload it using systemctl.
for ADDR in $(fleetctl list-units --no-legend | grep <name>.service | awk '{ print $2 }' | awk --field-separator '/' '{ print $2 }'); do
  ssh $ADDR systemctl reload <name>.service
done

Another approach:

# Same idea, but using machine id instead of IP address. Not sure if it supports
# the same syntax as bare `ssh` for running a command on the server and exiting.
for MACHINE in $(fleetctl list-units --full --no-legend | grep website.service | awk '{ print $2 }' | awk --field-separator '/' '{ print $1 }'); do
  fleetctl ssh $MACHINE systemctl reload <name>.service
done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.