Browse Source

add first post

master
Cian Butler 3 years ago
parent
commit
619d3b218c
Signed by untrusted user: butlerx GPG Key ID: B37CA765BAA89170
7 changed files with 419 additions and 119 deletions
  1. +1
    -1
      archetypes/default.md
  2. +1
    -0
      config.toml
  3. +87
    -0
      content/post/2018-04-02.md
  4. +9
    -4
      layouts/partials/article-list-item.html
  5. +9
    -4
      layouts/partials/article.html
  6. +312
    -109
      static/css/style.css
  7. +0
    -1
      static/css/style.css.map

+ 1
- 1
archetypes/default.md View File

@@ -1,6 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
author: {{ .Site.Author }}
draft: true
---


+ 1
- 0
config.toml View File

@@ -1,3 +1,4 @@
baseURL = "https://admin.redbrick.dcu.ie/"
languageCode = "en-us"
title = "Redbrick Admin Blog"
author = "Redbrick Admin"

+ 87
- 0
content/post/2018-04-02.md View File

@@ -1,6 +1,93 @@
---
title: Accidental updates
date: 2018-04-02T21:11:41+01:00
author: butlerx
tags:
- Docker
- Postgres
---

# Why you need to lock a version

## The Preamble

Redbrick runs a service called [Hackmd](https://md.redbrick.dcu.ie). It is web
based markdown editor. At the start of the year Hackmd version one came out and
in early February we decided to update it.

Unlike most updates in Redbrick this isn't really a big thing as it runs inside
Docker container, with its only external dependency being Postgres 9. We don't
actually have a central a central Postgres database in Redbrick, a problem for
another day, just a mysql. So inside another container we run Postgres.

The update process was meant to be simple update the `Dockerfile`, run
`docker-compose up --build`, and wait....

## What Actually Went Wrong

And we waited but hackmd didn't come back. One tail of the logs later and the
problem was obvious Postgres had restarted. But not only that it was trying and
failing to upgrade itself to postgres 10.

The Problem was Docker had pulled the latest version of postgres. This was fine
when hackmd was first installed the year earlier when all the docker tags
pointed to postgres 9, but wasn't so great after.

## The Fix

The fix was pretty simple add a version tag to for the database image to the
`docker-compose.yml`. A quick `vim` and `docker-compose up` later and hackmd was
back with lots of new bells and whistles.

So we went through and changed all the other compose files to have tagged
versions of dependencies.

Problem Solved. Clean our hands and move on. Well unfortunately not.

## The Solution

Over the next couple of months couple problems were mentioned with hackmd but no
one really looked in to them. That was until it affected an admin. We couldn't
publish our roadmap for in coming admins.

So back to the logs and yep database issue. Seems that Postgres cant find some
of the keys. Initial thought was that we missed a database migration way back
when we upgraded. So we execed in to the container ran the migrations script and
.... nothing, there wasn't any.

Back to the drawing board. We start reviewing configs and double checking
against the repo. But everything seems right. Next we decide to go to the heart
of the problem the database itself. One docker run and we have a postgresql
shell. Start digging though tables, trying to find the missing key when we get a
duplicate key error and an alias.

BINGO

Odd thing was when you looked up the alias there was only one entry for it. We
couldn't delete the duplicate entry as it didn't exist and couldn't modify the
table entries as we got duplicate key errors.

Bit of googling later and we had a solution. Copy the table, delete it and
restore. Is this the Database version of turn it off and on again?

```sql
hackmd=# SELECT DISTINCT * INTO notes from "Notes";
SELECT 268
hackmd=# DROP TABLE "Notes";
DROP TABLE
hackmd=# ALTER TABLE notes rename to "Notes";
ALTER TABLE
hackmd=# REINDEX DATABASE hackmd;
REINDEX
hackmd=# VACUUM(FULL, ANALYZE, VERBOSE);
```

What it turns out is the tables index was wrong. While Postgres' attempt to
update itself to 10 had failed it had modified the indexes for some of the
tables and reverting the container didn't magically fix the database inside.

So the tl;dr.

* Always lock your container version
* containers don't magically fix things
* And validate your database after modifying it

+ 9
- 4
layouts/partials/article-list-item.html View File

@@ -1,10 +1,15 @@
<article class="list-item" itemscope itemtype="http://schema.org/Blog">
<h2 class="headline" itemprop="headline"><a href="{{ .RelPermalink }}">{{ .Title }}{{ if .Draft }} (Draft){{ end }}</a></h2>
<div class="meta">
{{ if not .Date.IsZero }}
<span class="key">published on</span>
<span class="val"><time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 02, 2006" }}</time></span>
{{ end }}
{{ if not .Date.IsZero }}
<span class="key">published on</span>
<span class="val"><time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 02, 2006" }}</time></span>
{{ end }}
{{ with .Params.author }}
<br>
<span class="key">author:</span>
<span class="val">{{ . }}</span>
{{ end }}
</div>
<section class="summary">
{{ .Summary }} {{ if .Truncated }} <a href="{{ .RelPermalink }}">Read More...</a>{{ end }}


+ 9
- 4
layouts/partials/article.html View File

@@ -5,21 +5,26 @@
<span class="key">published on</span>
<span class="val"><time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 02, 2006" }}</time></span>
{{ end }}
{{ with .Params.author }}
<br>
<span class="key">author:</span>
<span class="val">{{ . }}</span>
{{ end }}
{{ with .Params.categories }}
<span class="key">{{ if $page.Date.IsZero }}published {{ end }}in</span>
<span class="val">
{{ range . }}
{{ range . }}
<a href="{{ . | printf "categories/%s" | relURL }}">{{ . }}</a>
{{ end }}
{{ end }}
</span>
{{ end }}
{{ with .Params.tags }}
<br>
<span class="key">tags:</span>
<span class="val">
{{ range . }}
{{ range . }}
<a href="{{ . | printf "tags/%s" | relURL }}">{{ . }}</a>
{{ end }}
{{ end }}
</span>
{{ end }}
</div>


+ 312
- 109
static/css/style.css View File

@@ -1,21 +1,53 @@
/* Base16 Eighties Colorscheme by Chris Kempson (http://chriskempson.com) */

.base00 { color: #2d2d2d; }
.base01 { color: #393939; }
.base02 { color: #515151; }
.base03 { color: #747369; }
.base04 { color: #a09f93; }
.base05 { color: #d3d0c8; }
.base06 { color: #e8e6df; }
.base07 { color: #f2f0ec; }
.base08 { color: #f2777a; }
.base09 { color: #f99157; }
.base0a { color: #ffcc66; }
.base0b { color: #99cc99; }
.base0c { color: #66cccc; }
.base0d { color: #6699cc; }
.base0e { color: #cc99cc; }
.base0f { color: #d27b53; }
.base00 {
color: #2d2d2d;
}
.base01 {
color: #393939;
}
.base02 {
color: #515151;
}
.base03 {
color: #747369;
}
.base04 {
color: #a09f93;
}
.base05 {
color: #d3d0c8;
}
.base06 {
color: #e8e6df;
}
.base07 {
color: #f2f0ec;
}
.base08 {
color: #f2777a;
}
.base09 {
color: #f99157;
}
.base0a {
color: #ffcc66;
}
.base0b {
color: #99cc99;
}
.base0c {
color: #66cccc;
}
.base0d {
color: #6699cc;
}
.base0e {
color: #cc99cc;
}
.base0f {
color: #d27b53;
}

/* General Page Layout */

@@ -35,7 +67,7 @@ body {
}

div.right {
float:right;
float: right;
}

div.clearfix {
@@ -66,7 +98,8 @@ article.single section,
}
}

header, footer {
header,
footer {
background-color: #393939;
padding-top: 1rem;
padding-bottom: 1rem;
@@ -102,11 +135,16 @@ footer {

/* Typography */

h1, h2, h3, h4, h5, h6 {
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: bold;
line-height: 1.25;
margin-top: 1em;
margin-bottom: .5em;
margin-bottom: 0.5em;
}

p {
@@ -114,14 +152,27 @@ p {
margin-bottom: 1rem;
}

h1 { font-size: 2rem }
h2 { font-size: 1.5rem }
h3 { font-size: 1.25rem }
h4 { font-size: 1rem }
h5 { font-size: .875rem }
h6 { font-size: .75rem }
h1 {
font-size: 2rem;
}
h2 {
font-size: 1.5rem;
}
h3 {
font-size: 1.25rem;
}
h4 {
font-size: 1rem;
}
h5 {
font-size: 0.875rem;
}
h6 {
font-size: 0.75rem;
}

pre, code {
pre,
code {
font-family: inherit;
font-size: inherit;
}
@@ -252,8 +303,9 @@ footer a {
color: #cc99cc;
}

.article-list article section.summary a { color: #d27b53; }

.article-list article section.summary a {
color: #d27b53;
}

/* Single Post Layout */

@@ -266,7 +318,8 @@ article.single .meta .key {
color: #747369;
}

article.single .meta .val, article.single .meta .val a {
article.single .meta .val,
article.single .meta .val a {
color: #cc99cc;
}

@@ -304,14 +357,28 @@ article.single section.body {

/* Highlight Colors */

article.single section.body h1 { color: #6699cc; }
article.single section.body h2 { color: #99cc99; }
article.single section.body h3 { color: #f99157; }
article.single section.body h4 { color: #f2777a; }
article.single section.body h5 { color: #515151; }
article.single section.body h6 { color: #747369; }
article.single section.body h1 {
color: #6699cc;
}
article.single section.body h2 {
color: #99cc99;
}
article.single section.body h3 {
color: #f99157;
}
article.single section.body h4 {
color: #f2777a;
}
article.single section.body h5 {
color: #515151;
}
article.single section.body h6 {
color: #747369;
}

article.single section.body a { color: #d27b53; }
article.single section.body a {
color: #d27b53;
}

/* Article Elements */

@@ -334,7 +401,8 @@ article.single p code {
color: #f2f0ec;
}

article.single figure, article.single div.highlight {
article.single figure,
article.single div.highlight {
box-sizing: border-box;
max-width: 52rem;
width: 52rem;
@@ -346,7 +414,8 @@ article.single figure, article.single div.highlight {
}

@media (max-width: 52em) {
article.single figure, article.single div.highlight {
article.single figure,
article.single div.highlight {
width: 100%;
margin-left: 0;
margin-right: 0;
@@ -381,7 +450,7 @@ article.single table {

article.single th,
article.single td {
padding: .25rem 1rem;
padding: 0.25rem 1rem;
line-height: inherit;
border-bottom-width: 1px;
border-bottom-style: solid;
@@ -398,7 +467,9 @@ article.single th {
vertical-align: bottom;
}

article.single td { vertical-align: top }
article.single td {
vertical-align: top;
}

article.single blockquote {
margin-left: 2rem;
@@ -416,71 +487,203 @@ article.single hr {

/* Pygments template by Jan T. Sott (https://github.com/idleberg) */

pre { background: #2d2d2d; color: #f2f0ec }

.highlight .hll { background-color: #515151 }
.highlight .c { color: #747369 } /* Comment */
.highlight .err { color: #f2777a } /* Error */
.highlight .k { color: #cc99cc } /* Keyword */
.highlight .l { color: #f99157 } /* Literal */
.highlight .n { color: #f2f0ec } /* Name */
.highlight .o { color: #66cccc } /* Operator */
.highlight .p { color: #f2f0ec } /* Punctuation */
.highlight .cm { color: #747369 } /* Comment.Multiline */
.highlight .cp { color: #747369 } /* Comment.Preproc */
.highlight .c1 { color: #747369 } /* Comment.Single */
.highlight .cs { color: #747369 } /* Comment.Special */
.highlight .gd { color: #f2777a } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gh { color: #f2f0ec; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #99cc99 } /* Generic.Inserted */
.highlight .gp { color: #747369; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #66cccc; font-weight: bold } /* Generic.Subheading */
.highlight .kc { color: #cc99cc } /* Keyword.Constant */
.highlight .kd { color: #cc99cc } /* Keyword.Declaration */
.highlight .kn { color: #66cccc } /* Keyword.Namespace */
.highlight .kp { color: #cc99cc } /* Keyword.Pseudo */
.highlight .kr { color: #cc99cc } /* Keyword.Reserved */
.highlight .kt { color: #ffcc66 } /* Keyword.Type */
.highlight .ld { color: #99cc99 } /* Literal.Date */
.highlight .m { color: #f99157 } /* Literal.Number */
.highlight .s { color: #99cc99 } /* Literal.String */
.highlight .na { color: #6699cc } /* Name.Attribute */
.highlight .nb { color: #f2f0ec } /* Name.Builtin */
.highlight .nc { color: #ffcc66 } /* Name.Class */
.highlight .no { color: #f2777a } /* Name.Constant */
.highlight .nd { color: #66cccc } /* Name.Decorator */
.highlight .ni { color: #f2f0ec } /* Name.Entity */
.highlight .ne { color: #f2777a } /* Name.Exception */
.highlight .nf { color: #6699cc } /* Name.Function */
.highlight .nl { color: #f2f0ec } /* Name.Label */
.highlight .nn { color: #ffcc66 } /* Name.Namespace */
.highlight .nx { color: #6699cc } /* Name.Other */
.highlight .py { color: #f2f0ec } /* Name.Property */
.highlight .nt { color: #66cccc } /* Name.Tag */
.highlight .nv { color: #f2777a } /* Name.Variable */
.highlight .ow { color: #66cccc } /* Operator.Word */
.highlight .w { color: #f2f0ec } /* Text.Whitespace */
.highlight .mf { color: #f99157 } /* Literal.Number.Float */
.highlight .mh { color: #f99157 } /* Literal.Number.Hex */
.highlight .mi { color: #f99157 } /* Literal.Number.Integer */
.highlight .mo { color: #f99157 } /* Literal.Number.Oct */
.highlight .sb { color: #99cc99 } /* Literal.String.Backtick */
.highlight .sc { color: #f2f0ec } /* Literal.String.Char */
.highlight .sd { color: #747369 } /* Literal.String.Doc */
.highlight .s2 { color: #99cc99 } /* Literal.String.Double */
.highlight .se { color: #f99157 } /* Literal.String.Escape */
.highlight .sh { color: #99cc99 } /* Literal.String.Heredoc */
.highlight .si { color: #f99157 } /* Literal.String.Interpol */
.highlight .sx { color: #99cc99 } /* Literal.String.Other */
.highlight .sr { color: #99cc99 } /* Literal.String.Regex */
.highlight .s1 { color: #99cc99 } /* Literal.String.Single */
.highlight .ss { color: #99cc99 } /* Literal.String.Symbol */
.highlight .bp { color: #f2f0ec } /* Name.Builtin.Pseudo */
.highlight .vc { color: #f2777a } /* Name.Variable.Class */
.highlight .vg { color: #f2777a } /* Name.Variable.Global */
.highlight .vi { color: #f2777a } /* Name.Variable.Instance */
.highlight .il { color: #f99157 } /* Literal.Number.Integer.Long */

/*# sourceMappingURL=style.css.map */
pre {
background: #2d2d2d;
color: #f2f0ec;
}

.highlight .hll {
background-color: #515151;
}
.highlight .c {
color: #747369;
} /* Comment */
.highlight .err {
color: #f2777a;
} /* Error */
.highlight .k {
color: #cc99cc;
} /* Keyword */
.highlight .l {
color: #f99157;
} /* Literal */
.highlight .n {
color: #f2f0ec;
} /* Name */
.highlight .o {
color: #66cccc;
} /* Operator */
.highlight .p {
color: #f2f0ec;
} /* Punctuation */
.highlight .cm {
color: #747369;
} /* Comment.Multiline */
.highlight .cp {
color: #747369;
} /* Comment.Preproc */
.highlight .c1 {
color: #747369;
} /* Comment.Single */
.highlight .cs {
color: #747369;
} /* Comment.Special */
.highlight .gd {
color: #f2777a;
} /* Generic.Deleted */
.highlight .ge {
font-style: italic;
} /* Generic.Emph */
.highlight .gh {
color: #f2f0ec;
font-weight: bold;
} /* Generic.Heading */
.highlight .gi {
color: #99cc99;
} /* Generic.Inserted */
.highlight .gp {
color: #747369;
font-weight: bold;
} /* Generic.Prompt */
.highlight .gs {
font-weight: bold;
} /* Generic.Strong */
.highlight .gu {
color: #66cccc;
font-weight: bold;
} /* Generic.Subheading */
.highlight .kc {
color: #cc99cc;
} /* Keyword.Constant */
.highlight .kd {
color: #cc99cc;
} /* Keyword.Declaration */
.highlight .kn {
color: #66cccc;
} /* Keyword.Namespace */
.highlight .kp {
color: #cc99cc;
} /* Keyword.Pseudo */
.highlight .kr {
color: #cc99cc;
} /* Keyword.Reserved */
.highlight .kt {
color: #ffcc66;
} /* Keyword.Type */
.highlight .ld {
color: #99cc99;
} /* Literal.Date */
.highlight .m {
color: #f99157;
} /* Literal.Number */
.highlight .s {
color: #99cc99;
} /* Literal.String */
.highlight .na {
color: #6699cc;
} /* Name.Attribute */
.highlight .nb {
color: #f2f0ec;
} /* Name.Builtin */
.highlight .nc {
color: #ffcc66;
} /* Name.Class */
.highlight .no {
color: #f2777a;
} /* Name.Constant */
.highlight .nd {
color: #66cccc;
} /* Name.Decorator */
.highlight .ni {
color: #f2f0ec;
} /* Name.Entity */
.highlight .ne {
color: #f2777a;
} /* Name.Exception */
.highlight .nf {
color: #6699cc;
} /* Name.Function */
.highlight .nl {
color: #f2f0ec;
} /* Name.Label */
.highlight .nn {
color: #ffcc66;
} /* Name.Namespace */
.highlight .nx {
color: #6699cc;
} /* Name.Other */
.highlight .py {
color: #f2f0ec;
} /* Name.Property */
.highlight .nt {
color: #66cccc;
} /* Name.Tag */
.highlight .nv {
color: #f2777a;
} /* Name.Variable */
.highlight .ow {
color: #66cccc;
} /* Operator.Word */
.highlight .w {
color: #f2f0ec;
} /* Text.Whitespace */
.highlight .mf {
color: #f99157;
} /* Literal.Number.Float */
.highlight .mh {
color: #f99157;
} /* Literal.Number.Hex */
.highlight .mi {
color: #f99157;
} /* Literal.Number.Integer */
.highlight .mo {
color: #f99157;
} /* Literal.Number.Oct */
.highlight .sb {
color: #99cc99;
} /* Literal.String.Backtick */
.highlight .sc {
color: #f2f0ec;
} /* Literal.String.Char */
.highlight .sd {
color: #747369;
} /* Literal.String.Doc */
.highlight .s2 {
color: #99cc99;
} /* Literal.String.Double */
.highlight .se {
color: #f99157;
} /* Literal.String.Escape */
.highlight .sh {
color: #99cc99;
} /* Literal.String.Heredoc */
.highlight .si {
color: #f99157;
} /* Literal.String.Interpol */
.highlight .sx {
color: #99cc99;
} /* Literal.String.Other */
.highlight .sr {
color: #99cc99;
} /* Literal.String.Regex */
.highlight .s1 {
color: #99cc99;
} /* Literal.String.Single */
.highlight .ss {
color: #99cc99;
} /* Literal.String.Symbol */
.highlight .bp {
color: #f2f0ec;
} /* Name.Builtin.Pseudo */
.highlight .vc {
color: #f2777a;
} /* Name.Variable.Class */
.highlight .vg {
color: #f2777a;
} /* Name.Variable.Global */
.highlight .vi {
color: #f2777a;
} /* Name.Variable.Instance */
.highlight .il {
color: #f99157;
}

+ 0
- 1
static/css/style.css.map
File diff suppressed because it is too large
View File


Loading…
Cancel
Save