2

I am trying to create a postgres data container and make it act as a sidekick to a main postgres unit so that the main unit can share the data container's volume. Attempting to start the main unit leads to one of the host disconnecting from my cluster. Here are the unit files:

postgres-db@.service

[Unit]
Description=A postgres database. Uses postgres-db-data@.service as a data container.
Requires=etcd.service
Requires=docker.service
Requires=postgres-db-data@%i.service
After=etcd.service
After=docker.service
Before=postgres-db-data@%i.service


[Service]
TimeoutStartSec=0
KillMode=none
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill postgres%i
ExecStartPre=-/usr/bin/docker rm postgres%i
ExecStartPre=/usr/bin/docker pull ncodes/postgres
ExecStart=/usr/bin/docker run -volumes-from postgres-db-data@%i.service --name postgres%i -e POSTGRES_PASSWORD=mysecretpassword -e DB_NAME=database1 -p ${COREOS_PUBLIC_IPV4}:%i:5432 ncodes/postgres 
ExecStop=/usr/bin/docker stop postgres%i

[X-Fleet]
X-Conflicts=postgres-db@*.service

postgres-db-data@.service

[Unit]
Description=A postgres database
BindsTo=postgres-db@%i.service

# Requirements
Requires=etcd.service
Requires=docker.service
Requires=postgres-db@%i.service

# ordering
After=etcd.service
After=docker.service
After=postgres-db@%i.service

[Service]
TimeoutStartSec=0
KillMode=none
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill postgres-data-%i
ExecStartPre=-/usr/bin/docker rm postgres-data-%i
ExecStartPre=/usr/bin/docker pull ncodes/postgres
ExecStart=/usr/bin/docker run --name postgres-data-%i -e POSTGRES_PASSWORD=mysecretpassword -e DB_NAME=database2 ncodes/postgres 
ExecStop=/usr/bin/docker stop postgres-data-%i

[X-Fleet]
X-ConditionMachineOf=postgres-db@%i.service

Fleet logs: journalctl -u fleet

Dec 07 10:53:52 coreos01 systemd[1]: Started fleet daemon.
Dec 07 10:53:52 coreos01 fleetd[813]: INFO fleetd.go:64: Starting fleetd version 0.11.5
Dec 07 10:53:52 coreos01 fleetd[813]: INFO fleetd.go:168: No provided or default config file found - proceeding without
Dec 07 10:53:52 coreos01 fleetd[813]: INFO server.go:157: Establishing etcd connectivity
Dec 07 10:55:00 coreos01 fleetd[813]: INFO server.go:168: Starting server components
Dec 07 10:55:00 coreos01 fleetd[813]: INFO engine.go:79: Engine leader is 6fbfd62531ce435ca99ed7aa318b7220
Dec 07 11:09:18 coreos01 fleetd[813]: INFO manager.go:246: Writing systemd unit postgres-db-alone@5433.service (561b)
Dec 07 11:09:18 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 11:09:19 coreos01 fleetd[813]: INFO manager.go:127: Triggered systemd unit postgres-db-alone@5433.service start: job=3192
Dec 07 11:09:19 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=LoadUnit job=postgres-db-alone@5433.service reason="unit scheduled here but not loaded"
Dec 07 11:09:19 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 11:09:19 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StartUnit job=postgres-db-alone@5433.service reason="unit currently loaded but desired state is
Dec 07 11:13:29 coreos01 fleetd[813]: INFO manager.go:138: Triggered systemd unit postgres-db-alone@5433.service stop: job=4131
Dec 07 11:13:29 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StopUnit job=postgres-db-alone@5433.service reason="unit currently launched but desired state i
Dec 07 11:13:49 coreos01 fleetd[813]: INFO manager.go:138: Triggered systemd unit postgres-db-alone@5433.service stop: job=4219
Dec 07 11:13:49 coreos01 fleetd[813]: INFO manager.go:259: Removing systemd unit postgres-db-alone@5433.service
Dec 07 11:13:49 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 11:13:49 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=UnloadUnit job=postgres-db-alone@5433.service reason="unit loaded but not scheduled here"
Dec 07 11:13:49 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 12:08:21 coreos01 fleetd[813]: INFO engine.go:79: Engine leader is 6e0e59c83bd7450e8c8e22c36ee1cf3a
Dec 07 12:08:26 coreos01 fleetd[813]: INFO manager.go:246: Writing systemd unit postgres-db@5433.service (750b)
Dec 07 12:08:26 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 12:08:26 coreos01 fleetd[813]: ERROR manager.go:129: Failed to trigger systemd unit postgres-db@5433.service start: Unit postgres-db-data@5433.service failed to load: No such file or dir
Dec 07 12:08:26 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=LoadUnit job=postgres-db@5433.service reason="unit scheduled here but not loaded"
Dec 07 12:08:26 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 12:08:26 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StartUnit job=postgres-db@5433.service reason="unit currently loaded but desired state is launc
Dec 07 12:08:27 coreos01 fleetd[813]: INFO manager.go:246: Writing systemd unit postgres-db-data@5433.service (676b)
Dec 07 12:08:27 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 12:08:27 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=LoadUnit job=postgres-db-data@5433.service reason="unit scheduled here but not loaded"
Dec 07 12:08:27 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 12:29:37 coreos01 fleetd[813]: INFO manager.go:138: Triggered systemd unit postgres-db@5433.service stop: job=12320
Dec 07 12:29:37 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StopUnit job=postgres-db@5433.service reason="unit currently launched but desired state is load
Dec 07 12:29:48 coreos01 fleetd[813]: INFO manager.go:127: Triggered systemd unit postgres-db@5433.service start: job=12322
Dec 07 12:29:48 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StartUnit job=postgres-db@5433.service reason="unit currently loaded but desired state is launc
Dec 07 12:29:50 coreos01 fleetd[813]: INFO engine.go:159: Updated cluster engine version from 0 to 1
Dec 07 12:29:50 coreos01 fleetd[813]: INFO engine.go:185: Engine leadership acquired
Dec 07 12:29:50 coreos01 fleetd[813]: INFO engine.go:81: Engine leadership changed from 6e0e59c83bd7450e8c8e22c36ee1cf3a to ca376ee32b42401087d3cb6acfd4d6fc
Dec 07 12:29:53 coreos01 fleetd[813]: INFO manager.go:138: Triggered systemd unit postgres-db-data@5433.service stop: job=12499
Dec 07 12:29:53 coreos01 fleetd[813]: INFO manager.go:259: Removing systemd unit postgres-db-data@5433.service
Dec 07 12:29:53 coreos01 fleetd[813]: INFO manager.go:138: Triggered systemd unit postgres-db@5433.service stop: job=12501
Dec 07 12:29:53 coreos01 fleetd[813]: INFO manager.go:259: Removing systemd unit postgres-db@5433.service
Dec 07 12:29:53 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 12:29:53 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=UnloadUnit job=postgres-db-data@5433.service reason="unit loaded but not scheduled here"
Dec 07 12:29:53 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=UnloadUnit job=postgres-db@5433.service reason="unit loaded but not scheduled here"
Dec 07 12:29:53 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 12:30:28 coreos01 fleetd[813]: INFO engine.go:271: Scheduled Unit(postgres-db@5433.service) to Machine(ca376ee32b42401087d3cb6acfd4d6fc)
Dec 07 12:30:28 coreos01 fleetd[813]: INFO reconciler.go:161: EngineReconciler completed task: {Type: AttemptScheduleUnit, JobName: postgres-db@5433.service, MachineID: ca376ee32b42401087d3cb6a
Dec 07 12:30:33 coreos01 fleetd[813]: INFO manager.go:246: Writing systemd unit postgres-db@5433.service (750b)
Dec 07 12:30:33 coreos01 fleetd[813]: INFO manager.go:182: Instructing systemd to reload units
Dec 07 12:30:33 coreos01 fleetd[813]: ERROR manager.go:129: Failed to trigger systemd unit postgres-db@5433.service start: Unit postgres-db-data@5433.service failed to load: No such file or dir
Dec 07 12:30:33 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=LoadUnit job=postgres-db@5433.service reason="unit scheduled here but not loaded"
Dec 07 12:30:33 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=ReloadUnitFiles job=N/A reason="always reload unit files"
Dec 07 12:30:33 coreos01 fleetd[813]: INFO reconcile.go:330: AgentReconciler completed task: type=StartUnit job=postgres-db@5433.service reason="unit currently loaded but desired state is launc
2
  • I don't know why you are trying to start postgres-db@.service before the data container "Before=postgres-db-data@%i.service"
    – c4f4t0r
    Dec 7, 2015 at 14:46
  • You are right, I got the order wrong. After correcting the order, both units loaded properly but still failed when i attempted to start postgres-db@.service. By fail, i mean the node that i used to run fleetctl start was dropped from the cluster.
    – Kennedy
    Dec 7, 2015 at 17:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.