Join vnet as a part of NC publish (#451)

Join vnet before publishing NC. This is required as nmagent may be
restarted which causes the NC publishing to fail.
This commit is contained in:
Ashvin Deodhar 2019-12-04 10:35:49 -08:00 коммит произвёл GitHub
Родитель 6ca873ce05
Коммит 02cec02390
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 18 удалений

Просмотреть файл

@ -113,6 +113,7 @@ func NewHTTPRestService(config *common.ServiceConfig) (HTTPService, error) {
serviceState := &httpRestServiceState{}
serviceState.Networks = make(map[string]*networkInfo)
serviceState.joinedNetworks = make(map[string]struct{})
return &HTTPRestService{
Service: service,
@ -124,7 +125,6 @@ func NewHTTPRestService(config *common.ServiceConfig) (HTTPService, error) {
routingTable: routingTable,
state: serviceState,
}, nil
}
// Start starts the CNS listener.
@ -1757,10 +1757,6 @@ func (service *HTTPRestService) isNetworkJoined(networkID string) bool {
namedLock.LockAcquire(stateJoinedNetworks)
defer namedLock.LockRelease(stateJoinedNetworks)
if service.state.joinedNetworks == nil {
service.state.joinedNetworks = make(map[string]struct{})
}
_, exists := service.state.joinedNetworks[networkID]
return exists
@ -1819,9 +1815,7 @@ func (service *HTTPRestService) publishNetworkContainer(w http.ResponseWriter, r
switch r.Method {
case "POST":
// Join Network if not joined already
isNetworkJoined = service.isNetworkJoined(req.NetworkID)
if !isNetworkJoined {
// Join the network
publishResponse, publishError, err = service.joinNetwork(req.NetworkID, req.JoinNetworkURL)
if err == nil {
isNetworkJoined = true
@ -1829,7 +1823,6 @@ func (service *HTTPRestService) publishNetworkContainer(w http.ResponseWriter, r
returnMessage = err.Error()
returnCode = NetworkJoinFailed
}
}
if isNetworkJoined {
// Publish Network Container