Skip to content

Commit 5144426

Browse files
authored
feat: add a 1ms delta to --until (#1088)
1 parent cc409e7 commit 5144426

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/pkg/cli/debug.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,22 @@ func DebugDeployment(ctx context.Context, client client.FabricClient, debugConfi
126126
return ErrDryRun
127127
}
128128

129-
var sinceTime, untilTime *timestamppb.Timestamp
129+
var sinceTs, untilTs *timestamppb.Timestamp
130130
if pkg.IsValidTime(debugConfig.Since) {
131-
sinceTime = timestamppb.New(debugConfig.Since)
131+
sinceTs = timestamppb.New(debugConfig.Since)
132132
}
133133
if pkg.IsValidTime(debugConfig.Until) {
134-
untilTime = timestamppb.New(debugConfig.Until)
134+
until := debugConfig.Until.Add(time.Millisecond) // add a millisecond to make it inclusive
135+
untilTs = timestamppb.New(until)
135136
}
136137
req := defangv1.DebugRequest{
137138
Etag: debugConfig.Etag,
138139
Files: files,
139140
ModelId: debugConfig.ModelId,
140141
Project: debugConfig.Project.Name,
141142
Services: debugConfig.FailedServices,
142-
Since: sinceTime,
143-
Until: untilTime,
143+
Since: sinceTs,
144+
Until: untilTs,
144145
}
145146
err := debugConfig.Provider.QueryForDebug(ctx, &req)
146147
if err != nil {

src/pkg/cli/tail.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,19 @@ func isTransientError(err error) bool {
198198
}
199199

200200
func tail(ctx context.Context, provider client.Provider, projectName string, options TailOptions) error {
201-
var since, until *timestamppb.Timestamp
201+
var sinceTs, untilTs *timestamppb.Timestamp
202202
if pkg.IsValidTime(options.Since) {
203-
since = timestamppb.New(options.Since)
203+
sinceTs = timestamppb.New(options.Since)
204204
} else {
205205
options.Since = time.Now() // this is used to continue from the last timestamp
206206
}
207207
if pkg.IsValidTime(options.Until) {
208-
until = timestamppb.New(options.Until)
208+
until := options.Until.Add(time.Millisecond) // add a millisecond to make it inclusive
209+
untilTs = timestamppb.New(until)
209210
// If the user specifies a deadline in the future, we should respect it
210-
if options.Until.After(time.Now()) {
211+
if until.After(time.Now()) {
211212
var cancel context.CancelFunc
212-
ctx, cancel = context.WithDeadline(ctx, options.Until)
213+
ctx, cancel = context.WithDeadline(ctx, until)
213214
defer cancel()
214215
}
215216
}
@@ -220,8 +221,8 @@ func tail(ctx context.Context, provider client.Provider, projectName string, opt
220221
Pattern: options.Filter,
221222
Project: projectName,
222223
Services: options.Services,
223-
Since: since, // this is also used to continue from the last timestamp
224-
Until: until,
224+
Since: sinceTs, // this is also used to continue from the last timestamp
225+
Until: untilTs,
225226
}
226227

227228
serverStream, err := provider.QueryLogs(ctx, tailRequest)

0 commit comments

Comments
 (0)