New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pecl-redis 3.1.2 and "Could not evaluate: invalid byte sequence in UTF-8" on reprovisioning #2650

Closed
RussianPenguin opened this Issue Apr 21, 2017 · 13 comments

Comments

Projects
None yet
8 participants
@RussianPenguin
Copy link

RussianPenguin commented Apr 21, 2017

Problem:
If redis and php enabled then reprovisioning fails with

Error: /Stage[main]/Puphpet::Redis::Install/Puphpet::Php::Module::Pecl[redis]/Php::Pecl::Module[redis]/Exec[pecl-redis]: Could not evaluate: invalid byte sequence in UTF-8
// some strings
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Steps to reproduce:

  1. create new configuration
  2. Check that actual version pecl-redis is 3.1.2
  3. enable php and redis
  4. run vagrant up (all ok)
  5. run vagrant provision (provision fails)

How to find problem:
Add --debug option puppet agent command and find that this issue caused by command

pecl info redis

2017-04-21 20-31-22

How to fix:
In your local configuration change file

puphpet/puppet/modules/php/manifests/pecl/module.pp

and replace all
"pecl info ${name}"

to
"pecl info ${name} | iconv -c; test \${PIPESTATUS[0]} -eq 0"

test is necessary to save status of pecl info command.

I'm not sure that this solution is acceptable for all distributions and locales. For me it works with en_GB.UTF-8/en_US.UTF-8/ru_RU.UTF-8.

Actual config:

vagrantfile:
    target: local
    vm:
        provider:
            local:
                box: puphpet/centos7-x64
                box_url: 'false'
                box_version: '0'
                chosen_virtualizer: virtualbox
                virtualizers:
                    virtualbox:
                        modifyvm:
                            natdnshostresolver1: false
                        showgui: 0
                    vmware:
                        numvcpus: 1
                    parallels:
                        linked_clone: 0
                        check_guest_tools: 0
                        update_guest_tools: 0
                machines:
                    vflm_d2g8vdulksrz:
                        id: tdd
                        hostname: tdd.dev
                        network:
                            private_network: 192.168.56.101
                        memory: '512'
                        cpus: '1'
        provision:
            puppet:
                manifests_path: puphpet/puppet/manifests
                module_path:
                    - puphpet/puppet/modules
                    - puphpet/puppet/manifests
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
        synced_folder:
            vflsf_zo4up31e348h:
                owner: www-data
                group: www-data
                source: ./
                target: /var/www
                sync_type: default
                smb:
                    smb_host: ''
                    smb_username: ''
                    smb_password: ''
                    mount_options:
                        dir_mode: '0775'
                        file_mode: '0664'
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                        - .git/
                    auto: 'true'
        usable_port_range:
            start: 10200
            stop: 10500
        post_up_message: ''
    ssh:
        host: 'false'
        port: 'false'
        private_key_path: 'false'
        username: vagrant
        guest_port: 'false'
        keep_alive: '1'
        forward_agent: 'false'
        forward_x11: 'false'
        shell: 'bash -l'
        insert_key: 'false'
    vagrant:
        host: detect
    proxy:
        http: ''
        https: ''
        ftp: ''
        no_proxy: ''
server:
    install: '1'
    packages:
        - vim
        - htop
users_groups:
    install: '1'
    groups: {  }
    users: {  }
locale:
    install: '1'
    settings:
        default_locale: ru_RU.UTF-8
        locales:
            - ru_RU.UTF-8
            - en_GB.UTF-8
            - en_US.UTF-8
        timezone: UTC
firewall:
    install: '1'
    rules: {  }
resolv:
    install: '1'
    nameservers:
        - 8.8.8.8
        - 8.8.4.4
    domainname: ''
    searchpath: {  }
cron:
    install: '1'
    jobs: {  }
nginx:
    install: '1'
    settings:
        version: present
        default_vhost: 1
        proxy_buffers: '4 256k'
        proxy_buffer_size: 128k
        proxy_connect_timeout: 600s
        proxy_send_timeout: 600s
        proxy_read_timeout: 600s
        names_hash_bucket_size: 128
    upstreams: {  }
    vhosts:
        nxv_q6melujxz7a9:
            server_name: tdd.dev
            server_aliases:
                - www.tdd.dev
            www_root: /var/www/html
            listen_port: '80'
            client_max_body_size: 1m
            ssl: '0'
            locations:
                nxvl_p4ca8c1t0fi4:
                    www_root: /var/www/tdd/web
                    location: /
                    autoindex: 'off'
                    internal: 'false'
                    index_files:
                        - index.html
                        - index.php
                        - app.php
                    try_files:
                        - $uri
                        - $uri/
                        - /index.php$is_args$args
                        - /app.php$is_args$args
                    fastcgi: '127.0.0.1:9000'
                    fastcgi_index: app.php
                    fastcgi_split_path: '^(.+\.php)(.*)$'
                    fast_cgi_params_extra:
                        - 'APP_ENV dev'
                        - 'SCRIPT_FILENAME $document_root$fastcgi_script_name'
                    set:
                        - '$path_info $fastcgi_path_info'
                    proxy: ''
                    proxy_redirect: ''
    proxies: {  }
apache:
    install: '0'
    settings:
        version: 2.4
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - proxy_fcgi
        - rewrite
    vhosts:
        av_zvlpkupndddk:
            servername: awesome.dev
            serveraliases:
                - www.awesome.dev
            docroot: /var/www/awesome/web
            port: '80'
            setenvif:
                - 'Authorization "(.*)" HTTP_AUTHORIZATION=$1'
            custom_fragment: ''
            ssl: '0'
            ssl_cert: LETSENCRYPT
            ssl_key: LETSENCRYPT
            ssl_chain: LETSENCRYPT
            ssl_certs_dir: LETSENCRYPT
            ssl_protocol: ''
            ssl_cipher: ''
            directories:
                avd_yj3w9nnhddxr:
                    path: /var/www/awesome/web
                    directoryindex: 'index.php app.dev'
                    options:
                        - Indexes
                        - FollowSymlinks
                        - MultiViews
                    allow_override:
                        - All
                    require:
                        - 'all granted'
                    custom_fragment: ''
                    provider: directory
            files_match:
                avfm_bo275xmdd3g7:
                    path: (app_dev|config)\.php$
                    sethandler: 'proxy:fcgi://127.0.0.1:9000'
                    setenv:
                        - 'APP_ENV dev'
                    custom_fragment: ''
                    provider: filesmatch
                avfm_82uqqu4wfuii:
                    path: app\.php$
                    sethandler: 'proxy:fcgi://127.0.0.1:9000'
                    setenv:
                        - 'APP_ENV prod'
                    custom_fragment: ''
                    provider: filesmatch
                avfm_trcx0lk0y0ao:
                    path: \.php$
                    sethandler: 'proxy:fcgi://127.0.0.1:9000'
                    custom_fragment: ''
                    provider: filesmatch
letsencrypt:
    install: '1'
    settings:
        email: ''
        webserver_service: ''
    domains: {  }
php:
    install: '1'
    settings:
        version: '7.1'
    modules:
        php:
            - cli
            - intl
            - xml
            - mbstring
            - bz2
            - calendar
            - ctype
        pear: {  }
        pecl: {  }
    ini:
        display_errors: 'On'
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
        date.timezone: UTC
    fpm_ini:
        error_log: /var/log/php-fpm.log
    fpm_pools:
        phpfp_nqnwycyyi3xr:
            ini:
                prefix: www
                listen: '127.0.0.1:9000'
                security.limit_extensions: .php
                user: www-user
                group: www-data
    composer: '1'
    composer_home: ''
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
blackfire:
    install: '0'
    settings:
        server_id: ''
        server_token: ''
        agent:
            http_proxy: ''
            https_proxy: ''
            log_file: stderr
            log_level: '1'
        php:
            agent_timeout: '0.25'
            log_file: ''
            log_level: '1'
xhprof:
    install: '0'
wpcli:
    install: '0'
    version: v1.1.0
drush:
    install: '0'
    version: 8.0.5
ruby:
    install: '1'
    versions:
        rv_05obv4f6evxy:
            default: '1'
            bundler: '1'
            version: 2.3.1
            gems:
                - deep_merge@1.0.1
                - activesupport@4.2.6
                - vine@0.2
python:
    install: '1'
    packages: {  }
    versions: {  }
nodejs:
    install: '0'
    settings:
        version: '6'
    npm_packages: {  }
mariadb:
    install: '1'
    settings:
        version: '10.1'
        root_password: '123'
        override_options: {  }
    users:
        mariadbnu_xkx59wg4wydn:
            name: tdd
            password: tdd
    databases:
        mariadbnd_sqk4zqizvb7o:
            name: tdd
            sql: ''
    grants:
        mariadbng_7q3dy03w0syg:
            user: tdd
            table: '*.*'
            privileges:
                - USAGE
        mariadbng_ztv2jrn7y9is:
            user: tdd
            table: 'tdd.*'
            privileges:
                - ALL
mysql:
    install: '0'
    settings:
        version: '5.7'
        root_password: '123'
        override_options: {  }
    users:
        mysqlnu_k3siovetkbtf:
            name: dbuser
            password: '123'
    databases:
        mysqlnd_s1dnc2datotg:
            name: dbname
            sql: ''
    grants:
        mysqlng_3nj1umkb3e75:
            user: dbuser
            table: '*.*'
            privileges:
                - ALL
postgresql:
    install: '0'
    settings:
        global:
            encoding: UTF8
            version: '9.6'
        server:
            postgres_password: '123'
    databases: {  }
    users: {  }
    grants: {  }
mongodb:
    install: '0'
    settings:
        bind_ip: 127.0.0.1
        port: '27017'
    globals:
        version: 2.6.0
    databases: {  }
redis:
    install: '1'
    settings:
        port: '6379'
sqlite:
    install: '0'
    databases: {  }
mailhog:
    install: '0'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '8025'
        path: /usr/local/bin/mailhog
beanstalkd:
    install: '0'
    settings:
        listenaddress: 0.0.0.0
        listenport: '11300'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: 0
rabbitmq:
    install: '0'
    settings:
        port: '5672'
    users: {  }
    vhosts: {  }
    plugins: {  }
elastic_search:
    install: '0'
    settings:
        version: 2.3.1
        java_install: true
    instances:
        esi_8rk43s60kzo5:
            name: es-01
solr:
    install: '0'
    settings:
        version: 5.5.2
        port: '8984'
@kkarkus

This comment has been minimized.

Copy link

kkarkus commented Apr 24, 2017

Your solution doesn't work for me.

@RussianPenguin

This comment has been minimized.

Copy link

RussianPenguin commented Apr 24, 2017

@kkarkus, can you provide config file?

@jimilinuxguy

This comment has been minimized.

Copy link

jimilinuxguy commented Apr 27, 2017

I tested this solution and it worked for me. thanks!

@piratadelfuturo

This comment has been minimized.

Copy link

piratadelfuturo commented May 4, 2017

Worked for me!

@lvillanne

This comment has been minimized.

Copy link

lvillanne commented May 7, 2017

Your solution doesn't work for me, I've got a new error in my trace :

Error: printf "\n" | pecl -d preferred_state=stable install redis && pecl info redis returned 1 instead of one of [0]
Error: /Stage[main]/Puphpet::Redis::Install/Puphpet::Php::Module::Pecl[redis]/Php::Pecl::Module[redis]/Exec[pecl-redis]/returns: change from notrun to 0 failed: printf "\n" | pecl -d preferred_state=stable install redis && pecl info redis returned 1 instead of one of [0]
// some strings
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

For information, my local :

locale:
    install: '1'
    settings:
        default_locale: fr_FR.UTF-8
        locales:
            - fr_FR.UTF-8
        timezone: Europe/Paris
@RussianPenguin

This comment has been minimized.

Copy link

RussianPenguin commented May 7, 2017

@lvillanne, can you provide full config.yaml?

@lvillanne

This comment has been minimized.

Copy link

lvillanne commented May 8, 2017

Hi, I've tested with your file.

I've made a lot of test and it's not the local.
Perhaps it's the OS.

With your file it's ok, but if I deactivate nginx and if I replace centos 7 by ubuntu 16.04, it doesn't work.

The config.yaml with these two modifications :
config.yaml.txt

@RussianPenguin

This comment has been minimized.

Copy link

RussianPenguin commented May 8, 2017

@lvillanne, thank you.
I've tested solution for centos and ubuntu with different locales. Drop invalid chars from output is not good idea.
Correct solution is dropping output to /dev/null.

For example

$ [ 1 == 2 ]
$ echo $?
1
$ [ 1 == 2 ] &> /dev/null
$ echo $?
1

Drop output to /dev/null does not change status of command.

Correct solution for redis below.

$ rgrep "pecl info"
puphpet/puppet/modules/php/manifests/pecl/module.pp:        present => "printf \"${auto_answer}\" | pecl -d preferred_state=${preferred_state} install ${name}${new_version} && pecl info ${name} &> /dev/null",
puphpet/puppet/modules/php/manifests/pecl/module.pp:        present => "pecl info ${name} &> /dev/null",
puphpet/puppet/modules/php/manifests/pecl/module.pp:        absent  => "pecl info ${name} &> /dev/null",
@lvillanne

This comment has been minimized.

Copy link

lvillanne commented May 8, 2017

@RussianPenguin, thank you.
Your solution work very fine.

Thanks for your help.

Edit : I've got an other problem with this solution.
There is no error in vagrant up/vagrant provision, but in the VM, when I would make a composer install I've got this error :

composer install
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/redis.so' - /usr/lib/php/20151012/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0

When I look in the directory /usr/lib/php/20151012/ the file redis.so doesn't exit.
I revert the modification to test, and without your proposition of modification, the file exist.

Edit 2 : I think I finally found the solution.
Correct solution for redis is :

rgrep "pecl info"
puphpet/puppet
puphpet/puppet/modules/php/manifests/pecl/module.pp:        present => "printf \"${auto_answer}\" | pecl -d preferred_state=${preferred_state} install ${name}${new_version} && pecl info ${name}",
puphpet/puppet/modules/php/manifests/pecl/module.pp:        present => "pecl info ${name} > /dev/null && if [ $? -eq 0 ]; then echo 'OK'; fi",
puphpet/puppet/modules/php/manifests/pecl/module.pp:        absent  => "pecl info ${name} > /dev/null && if [ $? -eq 0 ]; then echo 'OK'; fi",
@litzinger

This comment has been minimized.

Copy link

litzinger commented May 9, 2017

I tried to update my config to install SOAP and was getting similar errors as mentioned in the original comment. Adding "&> /dev/null" as mentioned by @RussianPenguin fixed my issue.

@tecnom1k3

This comment has been minimized.

Copy link

tecnom1k3 commented May 13, 2017

worked for me, thanks @RussianPenguin!

@RussianPenguin

This comment has been minimized.

Copy link

RussianPenguin commented May 21, 2017

Hi, @lvillanne, you are right. I made some tests and found that puppet do not use result value (it's may be mistake) if command does not provide any output value.
Adding output only if command return $? == 0 is good idea.

&> /dev/null && if [ $? -eq 0 ]; then echo 'OK'; fi

This solution works for centos and ubuntu.

@jtreminio

This comment has been minimized.

Copy link
Member

jtreminio commented Jan 31, 2018

The php-redis package is now installed for Ubuntu, vs the pecl package.

@jtreminio jtreminio closed this Jan 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment