kdebisschop / rundeck-rancher-node-plugin

Manage Rancher-controlled Docker containers in Rundeck
Apache License 2.0
5 stars 0 forks source link

Capture container upgrade logs #22

Open kdebisschop opened 4 years ago

kdebisschop commented 4 years ago

Is your feature request related to a problem? Please describe.

Capture logs output from a container when upgrading it ? Currently, I have to found the container, the host and make a docker logs against it and I was wondering if there would be a way to get this through the api ?

mashwino commented 4 years ago

Hi, logs are also available thrue websocket websocket, could be a way ..

kdebisschop commented 4 years ago

I use websocket to capture command output. I'm not sure if there will be any differences in an upgrade. I won't have time to try for several days.

kdebisschop commented 4 years ago

This will be harder than you might expect. Remember that "upgrade" is an action on a service. You are asking for container logs. So logging an upgrade would require these steps:

  1. Identify all of the containers in the service
  2. Attach loggers to each of them via web sockets and show their console - both as they shut down and as connected containers cause changes to the system during upgrade (imagine the upgrade causes a schema change in a backing database - we'd want to capture any resulting errors in the still-running old containers).
  3. Identify new containers as they appear in the service. (I am not sure there is a way to do this except periodically polling the service.)
  4. Attach a web socket logger to each of these containers and capture their console output.
  5. Somehow render this in an organized way (remembering that the upgraded containers are not the nodes we acted on - they are new. So we cannot use RunDeck's ability to track nodes)

All of this would need to work both when start-before-stop is enabled and when it is not.

I am not even sure this is feasible at all. If it is feasible, it would be a large undertaking.

kdebisschop commented 4 years ago

A smaller possible approach might be to show recent messages logged to console on each container in the service at the end of the upgrade step. I expect the rancher API provides a means to do that, but I'm not sure...

yes...

https://rancher.com/docs/rancher/v1.6/en/api/v2-beta/api-resources/container/#logs