mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 21:25:09 +00:00
Merge branch 'master' into fix/golint
Conflicts: pkg/master/master.go pkg/master/pod_cache.go pkg/proxy/config/file.go pkg/proxy/proxier.go pkg/proxy/roundrobbin.go pkg/scheduler/randomfit.go pkg/scheduler/randomfit_test.go
This commit is contained in:
@@ -81,35 +81,38 @@ func (impl ConfigSourceFile) Run() {
|
||||
data, err := ioutil.ReadFile(impl.filename)
|
||||
if err != nil {
|
||||
glog.Errorf("Couldn't read file: %s : %v", impl.filename, err)
|
||||
} else {
|
||||
var config serviceConfig
|
||||
err = json.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
glog.Errorf("Couldn't unmarshal configuration from file : %s %v", data, err)
|
||||
} else {
|
||||
if !bytes.Equal(lastData, data) {
|
||||
lastData = data
|
||||
// Ok, we have a valid configuration, send to channel for
|
||||
// rejiggering.
|
||||
newServices := make([]api.Service, len(config.Services))
|
||||
newEndpoints := make([]api.Endpoints, len(config.Services))
|
||||
for i, service := range config.Services {
|
||||
newServices[i] = api.Service{JSONBase: api.JSONBase{ID: service.Name}, Port: service.Port}
|
||||
newEndpoints[i] = api.Endpoints{Name: service.Name, Endpoints: service.Endpoints}
|
||||
}
|
||||
if !reflect.DeepEqual(lastServices, newServices) {
|
||||
serviceUpdate := ServiceUpdate{Op: SET, Services: newServices}
|
||||
impl.serviceChannel <- serviceUpdate
|
||||
lastServices = newServices
|
||||
}
|
||||
if !reflect.DeepEqual(lastEndpoints, newEndpoints) {
|
||||
endpointsUpdate := EndpointsUpdate{Op: SET, Endpoints: newEndpoints}
|
||||
impl.endpointsChannel <- endpointsUpdate
|
||||
lastEndpoints = newEndpoints
|
||||
}
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if bytes.Equal(lastData, data) {
|
||||
continue
|
||||
}
|
||||
lastData = data
|
||||
|
||||
config := &serviceConfig{}
|
||||
if err = json.Unmarshal(data, config); err != nil {
|
||||
glog.Errorf("Couldn't unmarshal configuration from file : %s %v", data, err)
|
||||
continue
|
||||
}
|
||||
// Ok, we have a valid configuration, send to channel for
|
||||
// rejiggering.
|
||||
newServices := make([]api.Service, len(config.Services))
|
||||
newEndpoints := make([]api.Endpoints, len(config.Services))
|
||||
for i, service := range config.Services {
|
||||
newServices[i] = api.Service{JSONBase: api.JSONBase{ID: service.Name}, Port: service.Port}
|
||||
newEndpoints[i] = api.Endpoints{Name: service.Name, Endpoints: service.Endpoints}
|
||||
}
|
||||
if !reflect.DeepEqual(lastServices, newServices) {
|
||||
serviceUpdate := ServiceUpdate{Op: SET, Services: newServices}
|
||||
impl.serviceChannel <- serviceUpdate
|
||||
lastServices = newServices
|
||||
}
|
||||
if !reflect.DeepEqual(lastEndpoints, newEndpoints) {
|
||||
endpointsUpdate := EndpointsUpdate{Op: SET, Endpoints: newEndpoints}
|
||||
impl.endpointsChannel <- endpointsUpdate
|
||||
lastEndpoints = newEndpoints
|
||||
}
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user