gliderlabs / logspout

Log routing for Docker container logs
MIT License
4.66k stars 680 forks source link

Updating logspout image from 3.2.7 to latest - errors with "unterminated quoted string" #474

Closed vmalloc closed 4 years ago

vmalloc commented 4 years ago

I'm running a logspout daemonset on k8s, and recently updated to the latest version. My pods started failing with:

2020/05/04 05:43:00 # logspout v3.2.10 by gliderlabs                                                                                                     │
│ 2020/05/04 05:43:00 # adapters: multiline raw syslog tcp tls udp                                                                                         │
│ 2020/05/04 05:43:00 # options :                                                                                                                          │
│ 2020/05/04 05:43:00 persist:/mnt/routes                                                                                                                  │
│ 2020/05/04 05:43:01 !! template: syslog:1: unterminated quoted string
vmalloc commented 4 years ago

Pinning to 3.2.7 for the time being

michaelshobbs commented 4 years ago

Can you please provide your logspout configuration and any other specifics about how you’re running logspout? (Redacting confidential values of course)

EDIT: this looks like and issue with getting an env value from the OS but I'd need to see what you're passing in for the container environment in order to point you in the right direction. The only change I can see from 3.2.7 to 3.2.10 is around EXCLUDE_LABEL and EXCLUDE_LABELS. See here: https://github.com/gliderlabs/logspout/blob/master/CHANGELOG.md

vmalloc commented 4 years ago

This is my config:

Name:           logspout-papertrail
Selector:       name=logspout-papertrail
Node-Selector:  <none>
Labels:         name=logspout-papertrail
Annotations:    deprecated.daemonset.template.generation: 4
Desired Number of Nodes Scheduled: 6
Current Number of Nodes Scheduled: 6
Number of Nodes Scheduled with Up-to-date Pods: 6
Number of Nodes Scheduled with Available Pods: 6
Number of Nodes Misscheduled: 0
Pods Status:  6 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  name=logspout-papertrail
  Containers:
   logspout:
    Image:      gliderlabs/logspout:v3.2.7
    Port:       <none>
    Host Port:  <none>
    Limits:
      memory:  500Mi
    Requests:
      cpu:  150m
    Environment:
      SYSLOG_TAG:       {{ index .Container.Config.Labels "io.kubernetes.pod.namespace" }}[{{ index .Container.Config.Labels "io.kubernetes.pod.name" }}]
      SYSLOG_HOSTNAME:  {{ index .Container.Config.Labels "io.kubernetes.container.name" }}
      ROUTE_URIS:       <set to the key 'papertrail-destination' in secret 'papertrail-destination'>  Optional: false
    Mounts:
      /var/run/docker.sock from log (rw)
  Volumes:
   log:
    Type:          HostPath (bare host directory volume)
    Path:          /var/run/docker.sock
    HostPathType:
hhromic commented 4 years ago

I think this is because of my recent PR here: https://github.com/gliderlabs/logspout/pull/468

You have a long template in SYSLOG_TAG that gets truncated before it is evaluated. The truncation should happen after evaluation. I just realised my mistake now. Apologies.

Let me find a solution and I will send another PR fixing this issue. Thanks for your patience.

hhromic commented 4 years ago

Quick update: I now have a working proper fix for this issue while keeping RFC fields size limits.

The below example shows a very long SYSLOG_TAG template being used and still being correctly truncated to the maximum 48-characters allowed. The template is first executed in full and then truncated, thus avoiding the parsing error you are experiencing.

I had to do some refactoring to make this work properly because of the way the current implementation is done. I want to do some clean-ups and more testing before submitting a PR. Thanks for your patience and thanks for reporting.

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -e LOGSPOUT=ignore -e SYSLOG_TAG='{{ .ContainerName }}-{{ .ContainerName }}-{{ .ContainerName }}-{{ .ContainerName }}-{{ .ContainerName }}' logspout multiline+syslog+udp://localhost:514
2020/05/05 18:26:28 # logspout v3.2.10 by gliderlabs
2020/05/05 18:26:28 # adapters: syslog tcp tls udp multiline raw
2020/05/05 18:26:28 # options :
2020/05/05 18:26:28 persist:/mnt/routes
#   ADAPTER             ADDRESS         CONTAINERS      SOURCES OPTIONS
#   multiline+syslog+udplocalhost:514                           map[]
2020/05/05 18:26:28 # jobs    : routes http[logs,routes,health]:80 pump
2020/05/05 18:26:28 # routes  :
<14>1 2020-05-05T18:26:37Z 1cee472a01b1 upbeat_chaplygin-upbeat_chaplygin-upbeat_chaplyg 112463 - -  18:26:37 up 18 days,  9:38,  load average: 0.59, 0.39, 0.22
<14>1 2020-05-05T18:26:39Z 15006d94de21 sharp_antonelli-sharp_antonelli-sharp_antonelli- 112533 - -  18:26:39 up 18 days,  9:38,  load average: 0.59, 0.39, 0.22
<14>1 2020-05-05T18:26:43Z bd2d06bb144d suspicious_mclaren-suspicious_mclaren-suspicious 112678 - -  18:26:43 up 18 days,  9:38,  load average: 0.54, 0.39, 0.22
<14>1 2020-05-05T18:26:45Z 83690a84658c focused_kapitsa-focused_kapitsa-focused_kapitsa- 112750 - -  18:26:45 up 18 days,  9:38,  load average: 0.54, 0.39, 0.22
<14>1 2020-05-05T18:26:46Z f0384526fed9 lucid_lewin-lucid_lewin-lucid_lewin-lucid_lewin- 112822 - -  18:26:46 up 18 days,  9:38,  load average: 0.54, 0.39, 0.22
<14>1 2020-05-05T18:26:48Z cb6a4b11acf9 interesting_gould-interesting_gould-interesting_ 112892 - -  18:26:48 up 18 days,  9:38,  load average: 0.50, 0.38, 0.22
<14>1 2020-05-05T18:26:49Z 7c6b9d109819 stoic_matsumoto-stoic_matsumoto-stoic_matsumoto- 112963 - -  18:26:49 up 18 days,  9:39,  load average: 0.50, 0.38, 0.22
<14>1 2020-05-05T18:27:01Z 4670c00e748e optimistic_kalam-optimistic_kalam-optimistic_kal 113054 - -  18:27:01 up 18 days,  9:39,  load average: 0.42, 0.37, 0.22
<14>1 2020-05-05T18:27:12Z b2ae6082c7b5 vibrant_davinci-vibrant_davinci-vibrant_davinci- 113139 - -  18:27:12 up 18 days,  9:39,  load average: 0.35, 0.36, 0.22
hhromic commented 4 years ago

Made a PR now to fix this and other general improvements to the code of adapters/syslog in #477

michaelshobbs commented 4 years ago

@vmalloc the fix will be released in v3.2.11 shortly

vmalloc commented 4 years ago

Thanks!

On Fri, 8 May 2020 at 22:39 Michael Hobbs notifications@github.com wrote:

@vmalloc https://github.com/vmalloc the fix will be released in v3.2.11 shortly

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/gliderlabs/logspout/issues/474#issuecomment-625983800, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHAJRNKBINNJYZ3J3BY7TRQRNVPANCNFSM4MYO7W7Q .

-- Rotem