MOTD markdown_erb format not working after upgrade to 3.1.7?

Hello,

We’ve upgraded from 3.0.3 to 3.1.7 on one of our test systems, but are having an issue with the MOTD when using markdown_erb in /etc/ood/config/apps/dashboard/env

MOTD_PATH='/etc/motd.portal'
MOTD_FORMAT='markdown_erb'
MOTD_TITLE='Announcements and Links'
# cat /etc/motd.portal 
<%= `/bin/next_pm --portal` %>
***

#####Services

- [Atmos Jobs Map](https://atmos-mgmt.hesc.epa.gov/slurm)

When it renders the MOTD text, it’s display the HTML tags, instead of the rendered HTML:

image

I have set motd_render_html: true in the /etc/ood/config/ondemand/ondemand.yml

# grep motd_render_html /etc/ood/config/ondemand.d/ondemand.yml 
motd_render_html: true

And re-ran update_ood_portal with no luck. If I switch MOTD_FORMAT to straight markdown, then I get

image

So, the issue seems to be specific to markdown_erb and rendering HTML, but I don’t see anything else in the MOTD section on the 3.1 manual that would explain what’s going on.

Any idea’s why the MOTD HTML output isn’t actually rendering as HTML in my configuration and what I need to do to correct it?

Thanks!

You can find this config motd_render_html at the bottom of this page. We added this as a safety check for folks that don’t want potentially unsafe html (like script tags) being shown.

https://osc.github.io/ood-documentation/latest/reference/files/ondemand-d-ymls.html?highlight=motd_render_html

Ok, as noted in my opening case notes:

I have set motd_render_html: true in the /etc/ood/config/ondemand/ondemand.yml

# grep motd_render_html /etc/ood/config/ondemand.d/ondemand.yml 
motd_render_html: true

And re-ran update_ood_portal with no luck.

Do I need to put motd_render_html somewhere else or do another step?

Oh sorry! Must not have read it entirely. You shouldn’t need to update_ood_portal or bounce httpd, but you do need to Restart Web Server in the help menu to pick up new configurations.

Yeah, I did all that before opening the ticket. It’s not working.

Any ideas?

There could be a bug. I’ll check it out. Can you provide the output of /bin/next_pm for me to test against.

Sure, it’s just a shell script we wrote that prints out the date of the monthly system PM for that host. It gets run via /etc/profile.d on SSH login:

$ /bin/next_pm

Next preventative maintenance for atmos6 will be on Saturday, August 17, 2024.
This system will be UNAVAILABLE that day between 5:30am and 7:00am.

Or for Open OnDemand MOTD, it does the same but includes some HTML tags to make it look correctly formatted in a web browser:

$ /bin/next_pm --portal
Next preventative maintenance for atmos6 will be on <b>Saturday, August 17, 2024</b>.<br><br>This system will be <b>UNAVAILABLE</b> that day between 5:30am and 7:00am.

This is what it looks like on the 3.0.3 systems we haven’t updated:

image

Let me know if you need anything else.

Thanks!

Wanted to add, yes, I believe it’s a bug. I modified /var/www/ood/apps/sys/dashboard/app/models/motd_formatter/markdown_erb.rb to include the same safe_content code that markdown.rb has:

module MotdFormatter
  # Utility class for rendering Markdown MOTD files after ERB rendering them.
 class MarkdownErb
    attr_reader :content, :title

    def initialize(motd_file)
      motd_file ||= MotdFile.new unless motd_file
      @title = motd_file.title
      @content = safe_content(OodAppkit.markdown.render(ERB.new(motd_file.content).result))
    end

    def to_partial_path
      "dashboard/motd_markdown"
    end

    def safe_content(content)
      if Configuration.motd_render_html?
        content.html_safe
      else
        sanitize(content)
      end
    end

 end
end

And things are now correctly rendering on 3.1.7 using markdown_erb:

image