Skip to content
Merged
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
3 changes: 2 additions & 1 deletion api/v1/challenge/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (store *Store) QueryChallenge(_ *emptypb.Empty, server ChallengeStore_Query
LastRenew: timestamppb.New(fsist.LastRenew),
Until: until,
ConnectionInfo: fsist.ConnectionInfo,
Flag: func() *string { // kept for retrocompatibility enough time for public migration
//nolint:staticcheck // SA1019: kept for retrocompatibility through public migration
Flag: func() *string {
if len(fsist.Flags) == 1 {
return &fsist.Flags[0]
}
Expand Down
3 changes: 2 additions & 1 deletion api/v1/challenge/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func (store *Store) RetrieveChallenge(ctx context.Context, req *RetrieveChalleng
LastRenew: timestamppb.New(fsist.LastRenew),
Until: until,
ConnectionInfo: fsist.ConnectionInfo,
Flag: func() *string { // kept for retrocompatibility enough time for public migration
//nolint:staticcheck // SA1019: kept for retrocompatibility through public migration
Flag: func() *string {
if len(fsist.Flags) == 1 {
return &fsist.Flags[0]
}
Expand Down
3 changes: 2 additions & 1 deletion api/v1/challenge/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ func (store *Store) UpdateChallenge(ctx context.Context, req *UpdateChallengeReq
LastRenew: timestamppb.New(fsist.LastRenew),
Until: until,
ConnectionInfo: fsist.ConnectionInfo,
Flag: func() *string { // kept for retrocompatibility enough time for public migration
//nolint:staticcheck // SA1019: kept for retrocompatibility through public migration
Flag: func() *string {
if len(fsist.Flags) == 1 {
return &fsist.Flags[0]
}
Expand Down
13 changes: 11 additions & 2 deletions api/v1/instance/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ func (man *Manager) CreateInstance(ctx context.Context, req *CreateInstanceReque
if err != nil {
// If challenge not found
if _, ok := err.(*errs.ChallengeExist); ok {
if err := clock.RUnlock(context.WithoutCancel(ctx)); err != nil {
logger.Error(ctx, "unlocking R challenge", zap.Error(err))
}
return nil, err
}
// Else deal with it as an internal server error
logger.Error(ctx, "loading challenge",
zap.Error(err),
zap.Error(multierr.Combine(
clock.RUnlock(context.WithoutCancel(ctx)),
err,
)),
)
return nil, errs.ErrInternalNoSub
}
Expand Down Expand Up @@ -175,7 +181,10 @@ func (man *Manager) CreateInstance(ctx context.Context, req *CreateInstanceReque
}
if err != nil {
logger.Error(ctx, "looking up for claim",
zap.Error(err),
zap.Error(multierr.Combine(
clock.RUnlock(context.WithoutCancel(ctx)),
err,
)),
)
return nil, errs.ErrInternalNoSub
}
Expand Down
29 changes: 18 additions & 11 deletions api/v1/instance/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ func (man *Manager) DeleteInstance(ctx context.Context, req *DeleteInstanceReque
// 4. If challenge does not exist, return error
fschall, err := fs.LoadChallenge(req.GetChallengeId())
if err != nil {
if err := clock.RUnlock(context.WithoutCancel(ctx)); err != nil {
logger.Error(ctx, "unlocking R challenge", zap.Error(err))
}

// If challenge not found
if _, ok := err.(*errs.ChallengeExist); ok {
if err := clock.RUnlock(context.WithoutCancel(ctx)); err != nil {
logger.Error(ctx, "unlocking R challenge", zap.Error(err))
}
return nil, err
}
// Else deal with it as an internal server error
logger.Error(ctx, "loading challenge",
zap.Error(err),
zap.Error(multierr.Combine(
clock.RUnlock(context.WithoutCancel(ctx)),
err,
)),
)
return nil, errs.ErrInternalNoSub
}
Expand All @@ -108,16 +110,18 @@ func (man *Manager) DeleteInstance(ctx context.Context, req *DeleteInstanceReque
ctx = global.WithSourceID(ctx, req.GetSourceId())
id, err := fs.FindInstance(req.GetChallengeId(), req.GetSourceId())
if err != nil {
if err := clock.RUnlock(context.WithoutCancel(ctx)); err != nil {
logger.Error(ctx, "unlocking R challenge", zap.Error(err))
}

if _, ok := err.(*errs.InstanceExist); ok {
if err := clock.RUnlock(context.WithoutCancel(ctx)); err != nil {
logger.Error(ctx, "unlocking R challenge", zap.Error(err))
}
return nil, err
}

logger.Error(ctx, "finding instance",
zap.Error(err),
zap.Error(multierr.Combine(
clock.RUnlock(context.WithoutCancel(ctx)),
err,
)),
)
return nil, errs.ErrInternalNoSub
}
Expand Down Expand Up @@ -184,7 +188,10 @@ func (man *Manager) DeleteInstance(ctx context.Context, req *DeleteInstanceReque
}
if err != nil {
logger.Error(ctx, "looking up for claim",
zap.Error(err),
zap.Error(multierr.Combine(
clock.RUnlock(context.WithoutCancel(ctx)),
err,
)),
)
return nil, errs.ErrInternalNoSub
}
Expand Down
Loading