Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Paas 1164 fix onAfterClone's haproxy behaviour #126

Merged
merged 4 commits into from
Sep 1, 2020
Merged

Conversation

maxenceA
Copy link
Contributor

JIRA issue: https://jira.jahia.org/browse/PAAS-1164

Short description: onAfterClone event now refresh the proc node haproxy backend.

onAfterClone.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@laurentfufu laurentfufu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrong but for what I understand, don't like this part sorry :(

actions:
  resetHaproxyBackends:
    - cmd[bl]: |-
        sed -ie "/$server.*:80 check cookie/d" /etc/haproxy/haproxy.cfg.d/10-jahia.cfg
    - forEach(nodes.cp):
        cmd[${this}]: |-
          echo "    server ${env.appid}-${@i.id} ${@i.intIP}:80 check cookie s${@i.id}" >> /etc/haproxy/haproxy.cfg.d/10-jahia.cfg
    - cmd[bl]: |-
        sed -ie 's/^.*server.*:80 check cookie.*$/\    server ${env.appid}-${nodes.proc.first.id} ${nodes.proc.first.intIP}:80 check cookie s${nodes.proc.first.id}/' /etc/haproxy/haproxy.cfg.d/11-proc.cfg
        sed -ie 's/^.*use_backend proc if { cook(JSESSIONID),lower -m beg.*$/\    use_backend proc if { cook(JSESSIONID),lower -m beg s${nodes.proc.first.id} }/' /etc/haproxy/haproxy.cfg.d/00-global.cfg
        sudo service haproxy reload
      user: haproxy

sed lines are too long and not visual at all to me.

IMHO, something like this will be smoother to read and understand:

actions:
  resetHaproxyBackends:
    - cmd[bl]: |-
        sed -e "/$server.*:80 check cookie/d" \
            -e '/^.*use_backend proc if { cook(JSESSIONID),lower -m beg.*$/d' \
            -i /etc/haproxy/haproxy.cfg.d/{00-global,10-jahia,11-proc}.cfg
        echo "    server ${env.appid}-${nodes.proc.first.id} ${nodes.proc.first.intIP}:80 check cookie s${nodes.proc.first.id}" \
            >> /etc/haproxy/haproxy.cfg.d/11-proc.cfg
        echo "    use_backend proc if { cook(JSESSIONID),lower -m beg s${nodes.proc.first.id} }" \
            >> /etc/haproxy/haproxy.cfg.d/00-global.cfg
    - forEach(nodes.cp):
        cmd[${this}]: |-
          echo "    server ${env.appid}-${@i.id} ${@i.intIP}:80 check cookie s${@i.id}" >> /etc/haproxy/haproxy.cfg.d/10-jahia.cfg
          sudo service haproxy reload
        user: haproxy

@maxenceA
Copy link
Contributor Author

maxenceA commented Sep 1, 2020

I tried to make these lines more readable.
I kept a sed for 00-global.cfg because i didn't want the use_backend condition to be at the end of the file.

actions:
  resetHaproxyBackends:
    - cmd[bl]: |-
        sed -e "/$server.*:80 check cookie/d" \
            -i /etc/haproxy/haproxy.cfg.d/{10-jahia,11-proc}.cfg
        echo "    server ${env.appid}-${nodes.proc.first.id} ${nodes.proc.first.intIP}:80 check cookie s${nodes.proc.first.id}" \
            >> /etc/haproxy/haproxy.cfg.d/11-proc.cfg
        sed -e 's/cook(JSESSIONID),lower -m beg s.*/cook(JSESSIONID),lower -m beg s${nodes.proc.first.id} }/' \
            -i /etc/haproxy/haproxy.cfg.d/00-global.cfg
    - forEach(nodes.cp):
        cmd[${this}]: |-
          echo "    server ${env.appid}-${@i.id} ${@i.intIP}:80 check cookie s${@i.id}" >> /etc/haproxy/haproxy.cfg.d/10-jahia.cfg
          sudo service haproxy reload
        user: haproxy

@laurentfufu laurentfufu merged commit bf02002 into master Sep 1, 2020
@laurentfufu laurentfufu deleted the PAAS-1164 branch September 1, 2020 13:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants