Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watcher option logs_timestamps to store taskrun logs with timestamps #789

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
| LOGS_TYPE | Determine Logs storage backend type | File (default) |
| LOGS_BUFFER_SIZE | Buffer for streaming logs | 32768 (default) |
| LOGS_PATH | Logs storage path | logs (default) |
| LOGS_TIMESTAMPS | Collect logs with timestamps | false (default) |
| S3_BUCKET_NAME | S3 Bucket name | <S3 Bucket Name> |
| S3_ENDPOINT | S3 Endpoint | https://s3.ap-south-1.amazonaws.com |
| S3_HOSTNAME_IMMUTABLE | S3 Hostname immutable | false (default) |
Expand Down
2 changes: 2 additions & 0 deletions cmd/watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var (
qps = flag.Float64("qps", float64(rest.DefaultQPS), "Kubernetes client QPS setting")
burst = flag.Int("burst", rest.DefaultBurst, "Kubernetes client Burst setting")
logsAPI = flag.Bool("logs_api", false, "Disable sending logs. If not set, the logs will be sent only if server support API for it")
logsTimestamps = flag.Bool("logs_timestamps", false, "Collect logs with timestamps")
labelSelector = flag.String("label_selector", "", "Selector (label query) to filter objects to be deleted. Matching objects must satisfy all labels requirements to be eligible for deletion")
requeueInterval = flag.Duration("requeue_interval", 10*time.Minute, "How long the Watcher waits to reprocess keys on certain events (e.g. an object doesn't match the provided selectors)")
namespace = flag.String("namespace", corev1.NamespaceAll, "Should the Watcher only watch a single namespace, then this value needs to be set to the namespace name otherwise leave it empty.")
Expand Down Expand Up @@ -114,6 +115,7 @@ func main() {
StoreEvent: *storeEvent,
StoreDeadline: storeDeadline,
ForwardBuffer: forwardBuffer,
LogsTimestamps: *logsTimestamps,
}

log.Printf("dynamic reconcile timeout %s and update log timeout is %s", cfg.DynamicReconcileTimeout.String(), cfg.UpdateLogTimeout.String())
Expand Down
1 change: 1 addition & 0 deletions config/base/env/config
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ LOGS_API=false
LOGS_TYPE=File
LOGS_BUFFER_SIZE=32768
LOGS_PATH=/logs
LOGS_TIMESTAMPS=false
S3_BUCKET_NAME=
S3_ENDPOINT=
S3_HOSTNAME_IMMUTABLE=false
Expand Down
1 change: 1 addition & 0 deletions pkg/api/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
LOGS_TYPE string `mapstructure:"LOGS_TYPE"`
LOGS_BUFFER_SIZE int `mapstructure:"LOGS_BUFFER_SIZE"`
LOGS_PATH string `mapstructure:"LOGS_PATH"`
LOGS_TIMESTAMPS bool `mapstructure:"LOGS_TIMESTAMPS"`

PROFILING bool `mapstructure:"PROFILING"`
PROFILING_PORT string `mapstructure:"PROFILING_PORT"`
Expand Down
3 changes: 3 additions & 0 deletions pkg/watcher/reconciler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type Config struct {
// by a forwarder. Since there's no way to check if log has been streamed, we
// always wait for this much amount of duration
ForwardBuffer *time.Duration

// Collect logs with timestamps
LogsTimestamps bool
}

// GetDisableAnnotationUpdate returns whether annotation updates should be
Expand Down
1 change: 1 addition & 0 deletions pkg/watcher/reconciler/dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ func (r *Reconciler) streamLogs(ctx context.Context, o results.Object, logType,
Params: tknParams,
PipelineRunName: o.GetName(),
TaskrunName: o.GetName(),
Timestamps: r.cfg.LogsTimestamps,
Stream: &cli.Stream{
Out: inMemWriteBufferStdout,
Err: inMemWriteBufferStderr,
Expand Down