Service profile gb2312 encoding, using Saltstack to manage errors

Source: Internet
Author: User
Tags ustring saltstack

Salt released 2014.7.0, the timely update, testing down, in the previous version of the operation, the version of the error. Many of the company's services for historical reasons, the configuration file continues to use the gb2312 encoding, which also has Chinese comments. When using salt for management, unicodedecodeerror errors are reported on the master side.

Perform a configuration file update and restart the service operation:

Salt ' zhaogb-202 ' State.sls Update_conf.manager

Manager.sls is the template for updating the Manager service profile:

Ma_watch:service:-Name:managerserverd-running-reload:true-watch:-File:/home/managerserve R/config.xml/home/managerserver/config.xml:file.managed:-source:salt://dzh_store/conf_file/managerserver/ Config.xml-user:root-group:root-mode:644-backup:minion

After you perform the update operation, the following error is reported:

[Error   ] an un-handled exception was caught by salt ' s  global exception handler:UnicodeDecodeError:  ' UTF8 '  codec can ' t decode  byte 0xca in position 18: invalid continuation byteTraceback  ( Most recent call last):  file  "/usr/bin/salt", line 10, in  <module>    salt_main ()   File  "/usr/lib/python2.6/site-packages/salt/ Scripts.py ",  line 240, in salt_main    client.run ()   File   "/usr/lib/python2.6/site-packages/salt/cli/__init__.py", line 189, in run     self._output_ret (ret_, out)   File  "/usr/lib/python2.6/site-packages/salt /cli/__init__.py ",  line 243, in _output_ret    salt.output.display_ Output (RET,&NBSP;OUT,&NBSP;SELF.COnfig)   File  "/usr/lib/python2.6/site-packages/salt/output/__init__.py",  line 44,  in display_output    display_data = get_printout (out, opts) (data ). Rstrip ()   File  "/usr/lib/python2.6/site-packages/salt/output/highstate.py",  line 74 ,  in output    return _format_host (host, hostdata) [0]  File   "/usr/lib/python2.6/site-packages/salt/output/highstate.py",  line 118, in _format_ Host    schanged, ctext = _format_changes (ret[' changes ')   File   "/usr/lib/python2.6/site-packages/salt/output/highstate.py",  line 340, in _format_ changes    __opts__)   File  "/usr/lib/python2.6/site-packages/salt/output/__ Init__.py ",  line 121, in out_format    return get_printout (out,  opts) (data). RstriP ()   File  "/usr/lib/python2.6/site-packages/salt/output/nested.py",  line 124, in  output    return nest.display (Ret, __opts__.get (' nested_indent ',  0),   ',  ')   File  "/usr/lib/python2.6/site-packages/salt/output/nested.py",  line  115, in display    out = self.display (val, indent +  4,  ",  out)   File "/usr/lib/python2.6/site-packages/salt/output/nested.py ",  line 90, in display    prefix=prefix)   File  "/usr/lib/ python2.6/site-packages/salt/output/nested.py ", line 59, in ustring     indent, color, prefix, msg.decode (encoding),  endc, suffix)   File   "/usr/lib64/python2.6/encodings/utf_8.py", line 16, in decode     return codecs.utf_8_decodE (input, errors, true) unicodedecodeerror:  ' UTF8 '  codec can ' t decode byte  0xca in position 18: invalid continuation byteTraceback  (most  Recent call last):  file  "/usr/bin/salt",  line 10, in <module >    salt_main ()   File  "/usr/lib/python2.6/site-packages/salt/scripts.py ",  line 240, in salt_main    client.run ()   File "/usr/ lib/python2.6/site-packages/salt/cli/__init__.py ", line 189, in run     self._output_ret (ret_, out)   File  "/usr/lib/python2.6/site-packages/salt/cli/__init_ _.py ",  line 243, in _output_ret    salt.output.display_output (ret,  out, self.config)   File  "/usr/lib/python2.6/site-packages/salt/output/__init__.py",  line 44, in display_output    display_data = get_printout (out, opts) (data). Rstrip ()   File  "/usr/lib/python2.6/site-packages/salt/output/highstate.py", line 74,  In output    return _format_host (Host, hostdata) [0]  File  "/ usr/lib/python2.6/site-packages/salt/output/highstate.py ", line 118, in _format_host     schanged, ctext = _format_changes (ret[' changes ')   File  "/usr/ lib/python2.6/site-packages/salt/output/highstate.py ", line 340, in _format_changes     __opts__)   File  "/usr/lib/python2.6/site-packages/salt/output/__init__.py",  line 121, in out_format    return get_printout (out, opts) ( Data). Rstrip ()   File  "/usr/lib/python2.6/site-packages/salt/output/nested.py", line  124, in&nbsP;output    return nest.display (Ret, __opts__.get (' nested_indent ',  0),   ',  ')   File  "/usr/lib/python2.6/site-packages/salt/output/nested.py",  line  115, in display    out = self.display (val, indent +  4,  ",  out)   File "/usr/lib/python2.6/site-packages/salt/output/nested.py ",  line 90, in display    prefix=prefix)   File  "/usr/lib/ python2.6/site-packages/salt/output/nested.py ", line 59, in ustring     indent, color, prefix, msg.decode (encoding),  endc, suffix)   File   "/usr/lib64/python2.6/encodings/utf_8.py", line 16, in decode     return codecs.utf_8_decode (input, errors, true) unicodedecodeerror:  ' UTF8 '  codec  can ' t decode byte 0Xca in position 18: invalid continuation byte 

Execution returned an error, but the Minion configuration file was updated and the service restart loaded the new configuration file. In other words, this error is generated on the master side and has no effect on minion. All operations were verified in the previous version (2014.1.0), and there was no problem. Troubleshoot and find

/usr/lib/python2.6/site-packages/salt/output/nested.py

This file, compared to the previous version, adds a ustring method that defines a encoding= ' utf-8 ' parameter with a default value, which is where the problem occurs.

2014.7.0 nested.py

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/57/8A/wKioL1SdJwLQjhcFAAIa31scCRk348.jpg "title=" Qq20141226171041.png "alt=" Wkiol1sdjwlqjhcfaaia31sccrk348.jpg "/>

Because my configuration file is gb2312 encoded, so the use of MSG decode operation Utf-8 Error, and then add a try,except debugging to solve the problem, the modified code is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/57/8D/wKiom1SdKOGCM4KcAAKiDo4CeQQ397.jpg "title=" 20141226171950.png "alt=" Wkiom1sdkogcm4kcaakido4ceqq397.jpg "/>

That is, modify the except, and then make a judgment.

At this point, this issue is temporarily resolved, whether it is the Utf-8 configuration file, or the gb2312 configuration file, passed, unsure whether it will affect the functionality of the salt itself.


This article is from the "Guibin blog" blog, make sure to keep this source http://guibin.blog.51cto.com/8909901/1596296

Service profile gb2312 encoding, using Saltstack to manage errors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.