mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #76875 from JieJhih/proxy/file
handle file close error
This commit is contained in:
commit
b9fbed1324
@ -341,7 +341,7 @@ func (o *Options) runLoop() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Options) writeConfigFile() error {
|
func (o *Options) writeConfigFile() (err error) {
|
||||||
const mediaType = runtime.ContentTypeYAML
|
const mediaType = runtime.ContentTypeYAML
|
||||||
info, ok := runtime.SerializerInfoForMediaType(o.codecs.SupportedMediaTypes(), mediaType)
|
info, ok := runtime.SerializerInfoForMediaType(o.codecs.SupportedMediaTypes(), mediaType)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -354,10 +354,15 @@ func (o *Options) writeConfigFile() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO handle error
|
|
||||||
defer configFile.Close()
|
|
||||||
|
|
||||||
if err := encoder.Encode(o.config, configFile); err != nil {
|
defer func() {
|
||||||
|
ferr := configFile.Close()
|
||||||
|
if ferr != nil && err == nil {
|
||||||
|
err = ferr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err = encoder.Encode(o.config, configFile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user