mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
nnsd: gate registration write & delete RPC use on v1.3.0 or greater. (#14924)
This commit is contained in:
4
.changelog/14924.txt
Normal file
4
.changelog/14924.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
```release-note:bug
|
||||||
|
nomad native service discovery: Ensure all local servers meet v.1.3.0 minimum before service registrations can be written
|
||||||
|
```
|
||||||
|
|
||||||
@@ -49,6 +49,11 @@ var minJobRegisterAtomicEvalVersion = version.Must(version.NewVersion("0.12.1"))
|
|||||||
|
|
||||||
var minOneTimeAuthenticationTokenVersion = version.Must(version.NewVersion("1.1.0"))
|
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
|
// 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
|
// as the leader in the Raft cluster. There is some work the leader is
|
||||||
// expected to do, so we must react to changes
|
// expected to do, so we must react to changes
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nomad
|
package nomad
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -45,6 +46,13 @@ func (s *ServiceRegistration) Upsert(
|
|||||||
}
|
}
|
||||||
defer metrics.MeasureSince([]string{"nomad", "service_registration", "upsert"}, time.Now())
|
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,
|
// 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
|
// perform a node lookup using the secret ID to confirm the caller is a
|
||||||
// known node.
|
// known node.
|
||||||
@@ -100,6 +108,13 @@ func (s *ServiceRegistration) DeleteByID(
|
|||||||
}
|
}
|
||||||
defer metrics.MeasureSince([]string{"nomad", "service_registration", "delete_id"}, time.Now())
|
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.
|
// Perform the ACL token resolution.
|
||||||
aclObj, err := s.srv.ResolveToken(args.AuthToken)
|
aclObj, err := s.srv.ResolveToken(args.AuthToken)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user