Skip to content

Commit

Permalink
Add watcher option logs_timestamps to store taskrun logs with timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascube authored and u233658 committed Aug 21, 2024
1 parent 8243bb2 commit fa57bf3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
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", true, "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 @@ -108,6 +109,7 @@ func main() {
UpdateLogTimeout: updateLogTimeout,
DynamicReconcileTimeout: dynamicReconcileTimeout,
StoreEvent: *storeEvent,
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
2 changes: 2 additions & 0 deletions pkg/watcher/reconciler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Config struct {
DynamicReconcileTimeout *time.Duration
// Whether to Store Events related to Taskrun and Pipelineruns
StoreEvent bool
// 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

0 comments on commit fa57bf3

Please sign in to comment.