|
|
|
@ -1840,7 +1840,8 @@ func (a *Agent) AddServiceAndReplaceChecks(service *structs.NodeService, chkType
|
|
|
|
|
token: token, |
|
|
|
|
replaceExistingChecks: true, |
|
|
|
|
source: source, |
|
|
|
|
}, a.snapshotCheckState()) |
|
|
|
|
snap: a.snapshotCheckState(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddService is used to add a service entry.
|
|
|
|
@ -1859,12 +1860,13 @@ func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.Che
|
|
|
|
|
token: token, |
|
|
|
|
replaceExistingChecks: false, |
|
|
|
|
source: source, |
|
|
|
|
}, a.snapshotCheckState()) |
|
|
|
|
snap: a.snapshotCheckState(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// addServiceLocked adds a service entry to the service manager if enabled, or directly
|
|
|
|
|
// to the local state if it is not. This function assumes the state lock is already held.
|
|
|
|
|
func (a *Agent) addServiceLocked(req *addServiceRequest, snap map[structs.CheckID]*structs.HealthCheck) error { |
|
|
|
|
func (a *Agent) addServiceLocked(req *addServiceRequest) error { |
|
|
|
|
req.fixupForAddServiceLocked() |
|
|
|
|
|
|
|
|
|
req.service.EnterpriseMeta.Normalize() |
|
|
|
@ -1882,7 +1884,7 @@ func (a *Agent) addServiceLocked(req *addServiceRequest, snap map[structs.CheckI
|
|
|
|
|
req.persistDefaults = nil |
|
|
|
|
req.persistServiceConfig = false |
|
|
|
|
|
|
|
|
|
return a.addServiceInternal(req, snap) |
|
|
|
|
return a.addServiceInternal(req) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// addServiceRequest is the union of arguments for calling both
|
|
|
|
@ -1907,6 +1909,7 @@ type addServiceRequest struct {
|
|
|
|
|
token string |
|
|
|
|
replaceExistingChecks bool |
|
|
|
|
source configSource |
|
|
|
|
snap map[structs.CheckID]*structs.HealthCheck |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r *addServiceRequest) fixupForAddServiceLocked() { |
|
|
|
@ -1920,7 +1923,7 @@ func (r *addServiceRequest) fixupForAddServiceInternal() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// addServiceInternal adds the given service and checks to the local state.
|
|
|
|
|
func (a *Agent) addServiceInternal(req *addServiceRequest, snap map[structs.CheckID]*structs.HealthCheck) error { |
|
|
|
|
func (a *Agent) addServiceInternal(req *addServiceRequest) error { |
|
|
|
|
req.fixupForAddServiceInternal() |
|
|
|
|
var ( |
|
|
|
|
service = req.service |
|
|
|
@ -1932,6 +1935,7 @@ func (a *Agent) addServiceInternal(req *addServiceRequest, snap map[structs.Chec
|
|
|
|
|
token = req.token |
|
|
|
|
replaceExistingChecks = req.replaceExistingChecks |
|
|
|
|
source = req.source |
|
|
|
|
snap = req.snap |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// Pause the service syncs during modification
|
|
|
|
@ -3066,7 +3070,8 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig, snap map[structs.CheckI
|
|
|
|
|
token: service.Token, |
|
|
|
|
replaceExistingChecks: false, // do default behavior
|
|
|
|
|
source: ConfigSourceLocal, |
|
|
|
|
}, snap) |
|
|
|
|
snap: snap, |
|
|
|
|
}) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("Failed to register service %q: %v", service.Name, err) |
|
|
|
|
} |
|
|
|
@ -3084,7 +3089,8 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig, snap map[structs.CheckI
|
|
|
|
|
token: sidecarToken, |
|
|
|
|
replaceExistingChecks: false, // do default behavior
|
|
|
|
|
source: ConfigSourceLocal, |
|
|
|
|
}, snap) |
|
|
|
|
snap: snap, |
|
|
|
|
}) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("Failed to register sidecar for service %q: %v", service.Name, err) |
|
|
|
|
} |
|
|
|
@ -3176,7 +3182,8 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig, snap map[structs.CheckI
|
|
|
|
|
token: p.Token, |
|
|
|
|
replaceExistingChecks: false, // do default behavior
|
|
|
|
|
source: source, |
|
|
|
|
}, snap) |
|
|
|
|
snap: snap, |
|
|
|
|
}) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("failed adding service %q: %s", serviceID, err) |
|
|
|
|
} |
|
|
|
|