Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
829584e6
Unverified
Commit
829584e6
authored
2 years ago
by
James Rasell
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
nnsd: gate registration write & delete RPC use on v1.3.0 or greater. (#14924)
parent
2f234e3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.changelog/14924.txt
+4
-0
.changelog/14924.txt
nomad/leader.go
+5
-0
nomad/leader.go
nomad/service_registration_endpoint.go
+15
-0
nomad/service_registration_endpoint.go
with
24 additions
and
0 deletions
+24
-0
.changelog/14924.txt
0 → 100644
+
4
-
0
View file @
829584e6
```release-note:bug
nomad native service discovery: Ensure all local servers meet v.1.3.0 minimum before service registrations can be written
```
This diff is collapsed.
Click to expand it.
nomad/leader.go
+
5
-
0
View file @
829584e6
...
...
@@ -49,6 +49,11 @@ var minJobRegisterAtomicEvalVersion = version.Must(version.NewVersion("0.12.1"))
var
minOneTimeAuthenticationTokenVersion
=
version
.
Must
(
version
.
NewVersion
(
"1.1.0"
))
// minNomadServiceRegistrationVersion is the Nomad version at which the service
// registrations table was introduced. It forms the minimum version all local
// servers must meet before the feature can be used.
var
minNomadServiceRegistrationVersion
=
version
.
Must
(
version
.
NewVersion
(
"1.3.0"
))
// monitorLeadership is used to monitor if we acquire or lose our role
// as the leader in the Raft cluster. There is some work the leader is
// expected to do, so we must react to changes
...
...
This diff is collapsed.
Click to expand it.
nomad/service_registration_endpoint.go
+
15
-
0
View file @
829584e6
package
nomad
import
(
"fmt"
"net/http"
"sort"
"strconv"
...
...
@@ -45,6 +46,13 @@ func (s *ServiceRegistration) Upsert(
}
defer
metrics
.
MeasureSince
([]
string
{
"nomad"
,
"service_registration"
,
"upsert"
},
time
.
Now
())
// Nomad service registrations can only be used once all servers, in the
// local region, have been upgraded to 1.3.0 or greater.
if
!
ServersMeetMinimumVersion
(
s
.
srv
.
Members
(),
s
.
srv
.
Region
(),
minNomadServiceRegistrationVersion
,
false
)
{
return
fmt
.
Errorf
(
"all servers should be running version %v or later to use the Nomad service provider"
,
minNomadServiceRegistrationVersion
)
}
// This endpoint is only callable by nodes in the cluster. Therefore,
// perform a node lookup using the secret ID to confirm the caller is a
// known node.
...
...
@@ -100,6 +108,13 @@ func (s *ServiceRegistration) DeleteByID(
}
defer
metrics
.
MeasureSince
([]
string
{
"nomad"
,
"service_registration"
,
"delete_id"
},
time
.
Now
())
// Nomad service registrations can only be used once all servers, in the
// local region, have been upgraded to 1.3.0 or greater.
if
!
ServersMeetMinimumVersion
(
s
.
srv
.
Members
(),
s
.
srv
.
Region
(),
minNomadServiceRegistrationVersion
,
false
)
{
return
fmt
.
Errorf
(
"all servers should be running version %v or later to use the Nomad service provider"
,
minNomadServiceRegistrationVersion
)
}
// Perform the ACL token resolution.
aclObj
,
err
:=
s
.
srv
.
ResolveToken
(
args
.
AuthToken
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help