@@ -1476,12 +1476,13 @@ func (ch *ClickHouse) GetPreprocessedConfigPath(ctx context.Context) (string, er
14761476 return path .Join ("/" , path .Join (paths [:len (paths )- 1 ]... ), "preprocessed_configs" ), nil
14771477}
14781478
1479- func (ch * ClickHouse ) ParseXML (ctx context.Context , configName string ) (configFile string , doc * xmlquery.Node , parseErr error ) {
1479+ func (ch * ClickHouse ) ParseXML (ctx context.Context , configName string ) (string , * xmlquery.Node , error ) {
14801480 preprocessedConfigPath , err := ch .GetPreprocessedConfigPath (ctx )
14811481 if err != nil {
14821482 return "" , nil , errors .Wrap (err , "ch.GetPreprocessedConfigPath error" )
14831483 }
1484- configFile = path .Join (preprocessedConfigPath , configName )
1484+ var doc * xmlquery.Node
1485+ configFile := path .Join (preprocessedConfigPath , configName )
14851486 //to avoid race-condition, cause preprocessed_configs rewrites every second
14861487 retry := retrier .New (retrier .ConstantBackoff (5 , time .Millisecond * 100 ), nil )
14871488 retryErr := retry .RunCtx (ctx , func (ctx context.Context ) error {
@@ -1494,15 +1495,18 @@ func (ch *ClickHouse) ParseXML(ctx context.Context, configName string) (configFi
14941495 log .Error ().Msgf ("can't close %s error: %v" , configFile , closeErr )
14951496 }
14961497 }()
1498+ var parseErr error
14971499 doc , parseErr = xmlquery .Parse (f )
14981500 return parseErr
14991501 })
15001502 if retryErr != nil {
15011503 xmlContent , readErr := os .ReadFile (configFile )
1502- parseErr = errors .Wrapf (parseErr , "xmlquery.Parse(%s) error" , configFile )
1503- log .Error ().Err (readErr ).Str ("xmlContent" , string (xmlContent )).Send ()
1504- log .Error ().Msg (parseErr .Error ())
1505- return configFile , nil , parseErr
1504+ if readErr != nil {
1505+ log .Error ().Err (readErr ).Str ("xmlContent" , string (xmlContent )).Send ()
1506+ return configFile , nil , readErr
1507+ }
1508+ retryErr = errors .Wrapf (retryErr , "xmlquery.Parse(%s) error" , configFile )
1509+ return configFile , nil , retryErr
15061510 }
15071511 return configFile , doc , nil
15081512}
0 commit comments