Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Log the difference in taupage.yaml on startup #207

Merged
merged 1 commit into from
May 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# vi: ts=4 expandtab

import shutil
import subprocess

from cloudinit import handlers
from cloudinit import log as logging
from cloudinit import util
Expand All @@ -12,6 +15,7 @@
TAUPAGE_AMI_CONFIG_MIME_TYPE = handlers.type_from_starts_with(TAUPAGE_AMI_CONFIG_PREFIX)

TAUPAGE_CONFIG = "/meta/taupage.yaml"
TMP_TAUPAGE_CONFIG = "/tmp/taupage.yaml"


class ZalandoAMIConfigPartHandler(handlers.Handler):
Expand All @@ -37,4 +41,10 @@ def handle_part(self, _data, ctype, filename, payload, frequency):

LOG.debug("Storing merged configuration...")
config_yaml = util.yaml_dumps(config_merged)
util.write_file(TAUPAGE_CONFIG, config_yaml, 0o444)
util.write_file(TMP_TAUPAGE_CONFIG, config_yaml, 0o444)

LOG.debug("Comparing current configuration with the old one...")
subprocess.call(['diff', '-u0', TAUPAGE_CONFIG, TMP_TAUPAGE_CONFIG])
Copy link
Contributor

Choose a reason for hiding this comment

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

this will fail the first time (/meta/taupage.yaml not there yet)? would be annoying to see an error in the logs..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, good point. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, should it not be throwing an error earlier when it tries to read the config with:

            LOG.debug("Loading existing configuration...")
            config_yaml = util.read_file_or_url(TAUPAGE_CONFIG)

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, we always have a /meta/taupage.yaml containing default values (created during Taupage AMI build).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good, then there's nothing to change at this line. :-)


LOG.debug("Moving the new configuration into place...")
shutil.move(TMP_TAUPAGE_CONFIG, TAUPAGE_CONFIG)