Skip to content

Commit ee3ca7d

Browse files
committed
nnsd: gate registration write & delete RPC use on v1.3.0 or greater.
1 parent 1b43418 commit ee3ca7d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

nomad/leader.go

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ var minJobRegisterAtomicEvalVersion = version.Must(version.NewVersion("0.12.1"))
4949

5050
var minOneTimeAuthenticationTokenVersion = version.Must(version.NewVersion("1.1.0"))
5151

52+
// minNomadServiceRegistrationVersion is the Nomad version at which the service
53+
// registrations table was introduced. It forms the minimum version all local
54+
// servers must meet before the feature can be used.
55+
var minNomadServiceRegistrationVersion = version.Must(version.NewVersion("1.3.0"))
56+
5257
// monitorLeadership is used to monitor if we acquire or lose our role
5358
// as the leader in the Raft cluster. There is some work the leader is
5459
// expected to do, so we must react to changes

nomad/service_registration_endpoint.go

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package nomad
22

33
import (
4+
"fmt"
45
"net/http"
56
"sort"
67
"strconv"
@@ -45,6 +46,13 @@ func (s *ServiceRegistration) Upsert(
4546
}
4647
defer metrics.MeasureSince([]string{"nomad", "service_registration", "upsert"}, time.Now())
4748

49+
// Nomad service registrations can only be used once all servers, in the
50+
// local region, have been upgraded to 1.3.0 or greater.
51+
if !ServersMeetMinimumVersion(s.srv.Members(), s.srv.Region(), minNomadServiceRegistrationVersion, false) {
52+
return fmt.Errorf("all servers should be running version %v or later to use the Nomad service provider",
53+
minNomadServiceRegistrationVersion)
54+
}
55+
4856
// This endpoint is only callable by nodes in the cluster. Therefore,
4957
// perform a node lookup using the secret ID to confirm the caller is a
5058
// known node.
@@ -100,6 +108,13 @@ func (s *ServiceRegistration) DeleteByID(
100108
}
101109
defer metrics.MeasureSince([]string{"nomad", "service_registration", "delete_id"}, time.Now())
102110

111+
// Nomad service registrations can only be used once all servers, in the
112+
// local region, have been upgraded to 1.3.0 or greater.
113+
if !ServersMeetMinimumVersion(s.srv.Members(), s.srv.Region(), minNomadServiceRegistrationVersion, false) {
114+
return fmt.Errorf("all servers should be running version %v or later to use the Nomad service provider",
115+
minNomadServiceRegistrationVersion)
116+
}
117+
103118
// Perform the ACL token resolution.
104119
aclObj, err := s.srv.ResolveToken(args.AuthToken)
105120

0 commit comments

Comments
 (0)