Skip to content

Commit

Permalink
Reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
talanknight committed Dec 18, 2023
1 parent f0b34a6 commit ecb5c5d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 45 deletions.
24 changes: 8 additions & 16 deletions internal/clientcache/cmd/daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,26 @@ func (c *StartCommand) Flags() *base.FlagSets {
f.DurationVar(&base.DurationVar{
Name: "refresh-interval",
Target: &c.flagRefreshInterval,
Usage: `Specifies the interval between refresh token supported cache refreshes. Default: 5 minutes`,
Usage: `Specifies the interval between refresh token supported cache refreshes.`,
Default: daemon.DefaultRefreshInterval,
})
f.DurationVar(&base.DurationVar{
Name: "recheck-support-interval",
Target: &c.flagRecheckSupportInterval,
Usage: `Specifies the interval between checking if a boundary instances is supported when it previously was not. Default: 1 hour`,
Usage: `Specifies the interval between checking if a boundary instances is supported when it previously was not.`,
Default: daemon.DefaultRecheckSupportInterval,
Hidden: true,
})
f.DurationVar(&base.DurationVar{
Name: "max-search-staleness",
Target: &c.flagMaxSearchStaleness,
Usage: `Specifies the duration of time that can pass since the resource was last updated before performing a search waits for the resources being refreshed first. Default: 1 minute`,
Usage: `Specifies the duration of time that can pass since the resource was last updated before performing a search waits for the resources being refreshed first.`,
Default: daemon.DefaultSearchStaleness,
})
f.DurationVar(&base.DurationVar{
Name: "max-search-refresh-timeout",
Target: &c.flagMaxSearchRefreshTimeout,
Usage: `If a search request triggers a best effort refresh, this specifies how long the refresh should run before timing out. Default: 1 second`,
Usage: `If a search request triggers a best effort refresh, this specifies how long the refresh should run before timing out.`,
Default: daemon.DefaultSearchRefreshTimeout,
})
f.BoolVar(&base.BoolVar{
Expand Down Expand Up @@ -308,6 +308,10 @@ func (c *StartCommand) makeBackground(ctx context.Context, dotDir string) (bool,
env := os.Environ()
env = append(env, fmt.Sprintf("%s=%s", backgroundEnvName, backgroundEnvVal))
args := []string{"daemon", "start"}
args = append(args, "-refresh-interval", c.flagRefreshInterval.String())
args = append(args, "-max-search-staleness", c.flagMaxSearchStaleness.String())
args = append(args, "-max-search-refresh-timeout", c.flagMaxSearchRefreshTimeout.String())
args = append(args, "-recheck-support-interval", c.flagRecheckSupportInterval.String())
if c.flagLogLevel != "" {
args = append(args, "-log-level", c.flagLogLevel)
}
Expand All @@ -317,18 +321,6 @@ func (c *StartCommand) makeBackground(ctx context.Context, dotDir string) (bool,
if c.flagDatabaseUrl != "" {
args = append(args, "-database-url", c.flagDatabaseUrl)
}
if c.flagRefreshInterval > 0 && c.flagRefreshInterval != daemon.DefaultRefreshInterval {
args = append(args, "-refresh-interval", c.flagRefreshInterval.String())
}
if c.flagRecheckSupportInterval > 0 && c.flagRecheckSupportInterval != daemon.DefaultRecheckSupportInterval {
args = append(args, "-full-fetch-interval", c.flagRecheckSupportInterval.String())
}
if c.flagMaxSearchStaleness > 0 && c.flagMaxSearchStaleness != daemon.DefaultSearchStaleness {
args = append(args, "-max-search-staleness", c.flagMaxSearchStaleness.String())
}
if c.flagMaxSearchRefreshTimeout > 0 && c.flagMaxSearchRefreshTimeout != daemon.DefaultSearchRefreshTimeout {
args = append(args, "-max-search-refresh-timeout", c.flagMaxSearchRefreshTimeout.String())
}
if c.flagStoreDebug {
args = append(args, "-store-debug")
}
Expand Down
50 changes: 23 additions & 27 deletions internal/clientcache/internal/cache/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,36 @@ func (s *StatusService) Status(ctx context.Context) (*Status, error) {
Id: u.Id,
}

{
cacheSupported, err := s.repo.cacheSupportState(ctx, u)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
cacheSupported, err := s.repo.cacheSupportState(ctx, u)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}

us.BoundaryStatus = BoundaryStatus{
Address: u.Address,
CachingSupported: cacheSupported.supported,
}
if cacheSupported.lastChecked != nil && !cacheSupported.lastChecked.IsZero() {
us.BoundaryStatus.LastSupportCheck = time.Since(*cacheSupported.lastChecked)
}
us.BoundaryStatus = BoundaryStatus{
Address: u.Address,
CachingSupported: cacheSupported.supported,
}
if cacheSupported.lastChecked != nil && !cacheSupported.lastChecked.IsZero() {
us.BoundaryStatus.LastSupportCheck = time.Since(*cacheSupported.lastChecked)
}

{
toks, err := s.repo.listTokens(ctx, u)
toks, err := s.repo.listTokens(ctx, u)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
for _, t := range toks {
ts := &AuthTokenStatus{
Id: t.Id,
}
kt, err := s.repo.listKeyringTokens(ctx, t)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
for _, t := range toks {
ts := &AuthTokenStatus{
Id: t.Id,
}
kt, err := s.repo.listKeyringTokens(ctx, t)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
ts.KeyringReferences = len(kt)
if _, ok := s.repo.idToKeyringlessAuthToken.Load(t.Id); ok {
ts.KeyringlessReferences = 1
}
us.AuthTokens = append(us.AuthTokens, *ts)
ts.KeyringReferences = len(kt)
if _, ok := s.repo.idToKeyringlessAuthToken.Load(t.Id); ok {
ts.KeyringlessReferences = 1
}
us.AuthTokens = append(us.AuthTokens, *ts)
}

for _, rt := range []resourceType{targetResourceType, sessionResourceType} {
Expand Down
2 changes: 1 addition & 1 deletion internal/clientcache/internal/daemon/search_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func toApiResult(sr *cache.SearchResult) *SearchResult {

var errSearchNotSupported = &api.Error{
Kind: "Unsupported Search Request",
Message: "The requesting user is for a Boundary instance that doesn't support search. The Boundary instance must support refresh tokens for search to be supported.",
Message: "The request is for a Boundary instance that doesn't support search. The Boundary instance must support refresh tokens for search to be supported.",
}

func writeUnsupportedError(w http.ResponseWriter) {
Expand Down
2 changes: 1 addition & 1 deletion internal/clientcache/internal/daemon/status_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type BoundaryStatus struct {
// The boundary address for this user
Address string `json:"address,omitempty"`
// Whether the controller responses are supported by the cache
CacheSupport string `json:"cache_response,omitempty"`
CacheSupport string `json:"cache_support,omitempty"`
// How long ago the Boundary instance was checked for cache compatability
LastSupportCheck time.Duration `json:"last_support_check,omitempty"`
}
Expand Down

0 comments on commit ecb5c5d

Please sign in to comment.