Error on attempting services logs on TTY container
| ... | ... |
@@ -397,6 +397,12 @@ func (c *containerAdapter) deactivateServiceBinding() error {
|
| 397 | 397 |
} |
| 398 | 398 |
|
| 399 | 399 |
func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscriptionOptions) (io.ReadCloser, error) {
|
| 400 |
+ // we can't handle the peculiarities of a TTY-attached container yet |
|
| 401 |
+ conf := c.container.config() |
|
| 402 |
+ if conf != nil && conf.Tty {
|
|
| 403 |
+ return nil, errors.New("logs not supported on containers with a TTY attached")
|
|
| 404 |
+ } |
|
| 405 |
+ |
|
| 400 | 406 |
reader, writer := io.Pipe() |
| 401 | 407 |
|
| 402 | 408 |
apiOptions := &backend.ContainerLogsConfig{
|
| ... | ... |
@@ -262,6 +262,13 @@ func (c *Cluster) ServiceLogs(ctx context.Context, input string, config *backend |
| 262 | 262 |
c.mu.RUnlock() |
| 263 | 263 |
return err |
| 264 | 264 |
} |
| 265 |
+ container := service.Spec.Task.GetContainer() |
|
| 266 |
+ if container == nil {
|
|
| 267 |
+ return errors.New("service logs only supported for container tasks")
|
|
| 268 |
+ } |
|
| 269 |
+ if container.TTY {
|
|
| 270 |
+ return errors.New("service logs not supported on tasks with a TTY attached")
|
|
| 271 |
+ } |
|
| 265 | 272 |
|
| 266 | 273 |
// set the streams we'll use |
| 267 | 274 |
stdStreams := []swarmapi.LogStream{}
|