Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
0675ae69
Commit
0675ae69
authored
Jul 22, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Rework sentRequest to call an upgrade function and wrap any errors returned by it
parent
178d4024
No related branches found
No related tags found
2 merge requests
!510
Release
,
!282
Auth Store Fixes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/store/sentRequest.go
+30
-8
30 additions, 8 deletions
auth/store/sentRequest.go
with
30 additions
and
8 deletions
auth/store/sentRequest.go
+
30
−
8
View file @
0675ae69
...
@@ -78,14 +78,11 @@ func loadSentRequest(kv *versioned.KV, partner *id.ID, grp *cyclic.Group) (*Sent
...
@@ -78,14 +78,11 @@ func loadSentRequest(kv *versioned.KV, partner *id.ID, grp *cyclic.Group) (*Sent
// V0 Upgrade Path
// V0 Upgrade Path
if
!
ekv
.
Exists
(
err
)
{
if
!
ekv
.
Exists
(
err
)
{
obj2
,
err2
:=
kv
.
Get
(
makeOldSentRequestKey
(
partner
),
0
)
upgradeErr
:=
upgradeSentRequestKeyV0
(
kv
,
partner
)
if
err2
!=
nil
{
if
upgradeErr
!=
nil
{
jww
.
DEBUG
.
Printf
(
"v0 loadSentRequest: %+v"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"%+v"
,
upgradeErr
)
}
else
{
obj
=
obj2
err
=
nil
}
}
// Note: uses same encoding, just different keys
obj
,
err
=
kv
.
Get
(
srKey
,
currentSentRequestVersion
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -272,12 +269,37 @@ func (sr *SentRequest) getType() RequestType {
...
@@ -272,12 +269,37 @@ func (sr *SentRequest) getType() RequestType {
return
Sent
return
Sent
}
}
// makeSentRequestKey makes the key string for accessing the
// partners sent request object from the key value store.
func
makeSentRequestKey
(
partner
*
id
.
ID
)
string
{
func
makeSentRequestKey
(
partner
*
id
.
ID
)
string
{
return
"sentRequest:"
+
partner
.
String
()
return
"sentRequest:"
+
partner
.
String
()
}
}
// V0 Utility Functions
// V0 Utility Functions
func
makeOldSentRequestKey
(
partner
*
id
.
ID
)
string
{
// makeSentRequestKeyV0 The old key used the string pattern
// "Partner:PartnerID" instead of "sentRequest:PartnerID".
func
makeSentRequestKeyV0
(
partner
*
id
.
ID
)
string
{
return
fmt
.
Sprintf
(
"Partner:%v"
,
partner
.
String
())
return
fmt
.
Sprintf
(
"Partner:%v"
,
partner
.
String
())
}
}
// upgradeSentRequestKeyV0 upgrads the srKey from version 0 to 1 by
// changing the version number.
func
upgradeSentRequestKeyV0
(
kv
*
versioned
.
KV
,
partner
*
id
.
ID
)
error
{
oldKey
:=
makeSentRequestKeyV0
(
partner
)
obj
,
err
:=
kv
.
Get
(
oldKey
,
0
)
if
err
!=
nil
{
return
err
}
jww
.
INFO
.
Printf
(
"Upgrading legacy srKey for %s"
,
partner
)
// Note: uses same encoding, just different keys
obj
.
Version
=
1
err
=
kv
.
Set
(
makeSentRequestKey
(
partner
),
1
,
obj
)
if
err
!=
nil
{
return
err
}
return
kv
.
Delete
(
oldKey
,
0
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment