mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #426 from claire921/cleanup
pkg/proxy/config: clean up file.Run()
This commit is contained in:
commit
f84a948c9c
@ -77,14 +77,19 @@ 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 ConfigFile
|
||||
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) {
|
||||
continue
|
||||
}
|
||||
|
||||
if bytes.Equal(lastData, data) {
|
||||
continue
|
||||
}
|
||||
lastData = data
|
||||
|
||||
config := new(ConfigFile)
|
||||
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))
|
||||
@ -103,9 +108,7 @@ func (impl ConfigSourceFile) Run() {
|
||||
impl.endpointsChannel <- endpointsUpdate
|
||||
lastEndpoints = newEndpoints
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user