mirror of https://github.com/k3s-io/k3s
pkg/proxy/config: clean up file.Run()
parent
93d45c1e71
commit
78cad3fd5e
|
@ -77,14 +77,19 @@ func (impl ConfigSourceFile) Run() {
|
||||||
data, err := ioutil.ReadFile(impl.filename)
|
data, err := ioutil.ReadFile(impl.filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Couldn't read file: %s : %v", impl.filename, err)
|
glog.Errorf("Couldn't read file: %s : %v", impl.filename, err)
|
||||||
} else {
|
continue
|
||||||
var config ConfigFile
|
}
|
||||||
err = json.Unmarshal(data, &config)
|
|
||||||
if err != nil {
|
if bytes.Equal(lastData, data) {
|
||||||
glog.Errorf("Couldn't unmarshal configuration from file : %s %v", data, err)
|
continue
|
||||||
} else {
|
}
|
||||||
if !bytes.Equal(lastData, data) {
|
|
||||||
lastData = data
|
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
|
// Ok, we have a valid configuration, send to channel for
|
||||||
// rejiggering.
|
// rejiggering.
|
||||||
newServices := make([]api.Service, len(config.Services))
|
newServices := make([]api.Service, len(config.Services))
|
||||||
|
@ -103,9 +108,7 @@ func (impl ConfigSourceFile) Run() {
|
||||||
impl.endpointsChannel <- endpointsUpdate
|
impl.endpointsChannel <- endpointsUpdate
|
||||||
lastEndpoints = newEndpoints
|
lastEndpoints = newEndpoints
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue