Compare commits

...

3 Commits

Author SHA1 Message Date
Vaibhav Kamra
4c1a6caabf Log deadlines 2023-03-17 12:11:49 -07:00
ryanfkeepers
78f109758c add changelog 2023-03-17 12:35:32 -06:00
ryanfkeepers
0066f0c4ef add 10 day deadline to cli context 2023-03-17 12:32:48 -06:00
5 changed files with 33 additions and 1 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix repo connect not working without a config file - Fix repo connect not working without a config file
- Fix item re-download on expired links silently being skipped - Fix item re-download on expired links silently being skipped
- Improved permissions backup and restore for OneDrive - Improved permissions backup and restore for OneDrive
- CLI calls default to a 10-day context deadline to avoid letting graph api restrict requests to a 100 second deadline.
### Known Issues ### Known Issues
- Owner (Full control) or empty (Restricted View) roles cannot be restored for OneDrive - Owner (Full control) or empty (Restricted View) roles cannot be restored for OneDrive

View File

@ -5,6 +5,7 @@ import (
"os" "os"
"regexp" "regexp"
"strings" "strings"
"time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
@ -147,7 +148,10 @@ func BuildCommandTree(cmd *cobra.Command) {
// Handle builds and executes the cli processor. // Handle builds and executes the cli processor.
func Handle() { func Handle() {
//nolint:forbidigo //nolint:forbidigo
ctx := config.Seed(context.Background()) ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Hour*24*10))
defer cancel()
ctx = config.Seed(ctx)
ctx = print.SetRootCmd(ctx, corsoCmd) ctx = print.SetRootCmd(ctx, corsoCmd)
observe.SeedWriter(ctx, print.StderrWriter(ctx), observe.PreloadFlags()) observe.SeedWriter(ctx, print.StderrWriter(ctx), observe.PreloadFlags())

View File

@ -103,6 +103,12 @@ func (c Events) GetItem(
event models.Eventable event models.Eventable
) )
if d, ok := ctx.Deadline(); ok {
logger.Ctx(ctx).Infof("GetItem Context is %s\n", d.String())
} else {
logger.Ctx(ctx).Info("GetItem Context has no deadline")
}
event, err = c.stable.Client().UsersById(user).EventsById(itemID).Get(ctx, nil) event, err = c.stable.Client().UsersById(user).EventsById(itemID).Get(ctx, nil)
if err != nil { if err != nil {
return nil, nil, graph.Stack(ctx, err) return nil, nil, graph.Stack(ctx, err)

View File

@ -162,6 +162,8 @@ func (col Collection) DoNotMergeItems() bool {
// Items() channel controller // Items() channel controller
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
var global = 1
// streamItems is a utility function that uses col.collectionType to be able to serialize // streamItems is a utility function that uses col.collectionType to be able to serialize
// all the M365IDs defined in the added field. data channel is closed by this function // all the M365IDs defined in the added field. data channel is closed by this function
func (col *Collection) streamItems(ctx context.Context, errs *fault.Bus) { func (col *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
@ -239,6 +241,18 @@ func (col *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
defer wg.Done() defer wg.Done()
defer func() { <-semaphoreCh }() defer func() { <-semaphoreCh }()
if global == 0 {
log.Infow("Sleeping for 100 seconds")
time.Sleep(110 * time.Second)
global = 1
}
if d, ok := ctx.Deadline(); ok {
log.Infof("Corso Context is %s\n", d.String())
} else {
log.Info("Corso Context has no deadline")
}
item, info, err := getItemWithRetries( item, info, err := getItemWithRetries(
ctx, ctx,
user, user,

View File

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/alcionai/corso/src/pkg/logger"
backoff "github.com/cenkalti/backoff/v4" backoff "github.com/cenkalti/backoff/v4"
khttp "github.com/microsoft/kiota-http-go" khttp "github.com/microsoft/kiota-http-go"
) )
@ -67,6 +68,12 @@ func (middleware RetryHandler) retryRequest(
return nil, Stack(ctx, respErr).With("retry_count", executionCount) return nil, Stack(ctx, respErr).With("retry_count", executionCount)
} }
if d, ok := ctx.Deadline(); ok {
logger.Ctx(ctx).Infof("Context is %s\n", d.String())
} else {
logger.Ctx(ctx).Infow("Context has no deadline")
}
return resp, nil return resp, nil
} }