Apple’s HQ, Ruskin, Gothic Architecture, and Agile

Most people regard tech professionals as dull people they don’t want to get stuck with at a dinner party, but if you’ve worked in tech for any period of time, then you have likely encountered a degree of passion for their preferences that would surprise most people unfamiliar with the field.

Some of them are so intense that they’ve been called ‘holy wars’, for example flame wars about something as mundane as text editors have gone on for decades. (Team vim, for the record).

I think this touches on a deeper truth about the nature of our work that is under-explored, and that I want to expand on here.

Architecture

First I want to take a sharp left turn, and try and relate this to something we can all understand: architecture.

Which of these two buildings’ entrances do you prefer, and why?

This?

or this?

How about this:

or this?

I don’t know which you preferred (and it’s a tiny sample), but I might be able to guess some of the reasons you might articulate for picking one over the other:

  • ‘Clean’ vs ‘Messy’
  • ‘Ordered’ vs ‘Disordered’
  • ‘Plain’ vs ‘Interesting’

Obviously, there’s no right or wrong answer, but we can examine our responses and think about where they come from and why.

Classical vs Gothic

Some readers may have noticed that both pairs of images contrast a ‘classical’ building first with a ‘gothic’ second one. Definitions of what a classical versus a gothic building vary. Some look at the decoration, and if they see columns like this:

then it’s classical, and ornament like this:

makes it Gothic.

But you can look deeper than this, and consider the philosophy that underlies the decoration.

Classical architecture tends to seek to make its buildings orderly. The decoration is consistently applied, and laid down by historical precedent. Its exteriors and internal rooms are symmetrical, their dimensions often regular shapes such as cubes. It looks man-made, and seeks simplicity and repetition over complexity and detail. By contrast, gothic architecture loves fine detail and complex patterns. These details may be repeated across the building, or one-offs in their particular spaces.

Gothic architecture often allows for buildings to grow asymmetrically (or ‘organically’) without spoiling an overall design or need for symmetry. The shapes used are not Platonic ideals like cubes or circles, but more individual/unique fractal-like variations on them.

This is where classification gets difficult: many so-called gothic buildings look very symmetrical, and some so-called classical buildings can have very fractal-like decoration or asymmetry. Throw in styles like baroque, which revelled in fine asymmetric detail while embracing traditional classical forms, and it can get very confusing indeed.

Classical or Gothic? ‘Classical’ columns and symmetrical form, but ‘gothic’ detailed decoration and organic non-symmetrical sculptures

Ruskin was a 19th century thinker who thought very deeply about these classifications, and his preferences, and came up with profound reasons to justify them. His writing ranged over art and aesthetics to architecture and its relation to society and economics, and, ultimately, morality and ethics.

He argued that what made gothic architecture gothic was a fundamentally different world view that resulted in these differences. First he separated out what made gothic and classical different without looking at the detail of ornament:

GothicClassical
Organic‘Ideal’
ResponsivePlatonic
Diachronic (changes over time)Synchronic (a fixed ‘snapshot’)
Individual Collective
Human scaleCorporate scale

This might start ringing bells with some readers working in tech, as it’s very close to the central metaphor in Raymond’s book ‘The Cathedral and the Bazaar: Musings on Linux and Open Source by an Accidental Revolutionary’.

In that book, Raymond contrasts the ‘top-down’ (classical) design of a cathedral with the ‘bottom-up’ (gothic) design of a bazaar, and uses those as metaphors for different kinds of software development. In the book, he was talking about different kinds of free software development (centrally controlled contributions and release vs Linux-style distributed contributions and releasing), but here I want to extend it to any kind of technology, physical or virtual, open or closed.

It’s interesting that Raymond calls the ‘bazaar’ ‘revolutionary’, since Ruskin used the exact same word to describe what kind of architectural style (or ‘ornament’) he preferred. He divided these into three:

  1. Servile ornament, in which the execution or power of the inferior workman is entirely subjected to the intellect of the higher
  2. Constitutional ornament, in which the executive inferior power is, to a certain point, emancipated and independent, having a will of its own, yet confessing its inferiority and rendering obedience to higher powers
  3. Revolutionary ornament, in which no executive inferiority is admitted at all.

For Ruskin, it didn’t matter what the object ended up looking like. What mattered was how much freedom the craftsman (it was almost always a man in medieval times) had when making it. The more freedom the craftsman had, the less a slave they were to some higher authority, and the more humane the society was that produced it.

What Does This Have To Do With Technology?

Let’s look at Apple’s headquarters. You’ve already seen it in one of the images above, but here’s another, wider view.

Put bluntly, you can’t get more classical than this. There’s barely any ornament here at all, no room for organic growth, and clean lines and ideal forms are everywhere.

You might think it’s delightful, but I find it disturbing. What does this say about Apple’s relationship with its workers? Where do I put my bag? Where do I sit down? Where do I wipe my feet?

Look at this picture again:

For me, those people spoil that view. Those irregular blobs of flesh and mostly water just ruin the symmetry of the place. Can’t we just do away with them?

This building doesn’t accommodate people, it admits them on sufferance.

The design of this building is no accident. It was overseen by Steve Jobs himself, and he ‘wanted no seam, gap, or paintbrush stroke visible for a clean fit and finish’.

It wasn’t just that building either. Nothing says ‘we have mastered nature and know better than you’ than putting a glass cube in downtown New York:

And if you think this doesn’t matter or mean anything, that it’s just aesthetics, then consider these two stories. The first is about the building itself:

Surrounding the Cupertino, Calif.-based building are 45-foot-tall curved panels of safety glass. Inside are work spaces, dubbed “pods,” also made with a lot of glass. Apple staff are often glued to the iPhones they helped popularize. That’s resulted in repeated cases of distracted employees walking into the panes, according to people familiar with the incidents. 

Some staff started to stick Post-it notes on the glass doors to mark their presence. However, the notes were removed because they detracted from the building’s design, the people said.

https://www.thestar.com/business/2018/02/19/apple-employees-encounter-pains-of-glass-at-new-spaceship-campus.html

I don’t think you can get anything more dehumanising, anti-organic, or plain evil in architecture as removing safety measures people themselves have taken to defend themselves against a hostile building because it doesn’t match the ‘clean fit and finish’ of the building.

The second goes beyond the HQ building to the products Apple produce. Most famously, Steve Jobs’ foray into customer support involved him instructing users to not hold the device in the natural way. This was popularly characterised as him saying “you’re holding it wrong”.

You’re holding it wrong, you’re walking around wrong, you’re putting post-its on dangerous glass doors wrong. You’re the problem, mate.

The highly influential ‘Design of Everyday Things‘ by Don Norman explicitly calls out this kind of thinking as wrong-headed, under the heading of ‘human-centred design‘. Interestingly, Norman worked at Apple in the 90s, and I can’t help but speculate whether these philosophical differences ever caused tension there.

Programming Languages

Once you start thinking about how building encourages or discourages a means of living compatible with a human, creative and dynamic life, then you start to see it everywhere.

Take programming languages. On the one side you have Java, top-down designed from the start to enable ‘superior minds’ to impose a limited domain of control on inferiors: use the class hierarchy we have given you; if you must write your own code, then use the Standard Libraries, which have been created to stop you from making mistakes.

On the other end of the spectrum, you have Perl, where “there’s more than one way to do it”, and games like Perl golf, allowing the individual to be creative in pursuit of their goal. The approach to the individual developer couldn’t be more different.

Where does your favourite language fit?

It’s not my intention here to argue that Perl is wonderful and Java is awful. I like neither. My intention is to point out that our preferences may reflect a deeper set of beliefs that we may want to reflect on.

I find it interesting that (given its age and widespread adoption) Java isn’t the runaway leader of programming languages used on GitHub, whereas Python, Javascript, and Golang (a relatively young language) projects abound. I can’t help but think that that’s because in our spare time, we want to work on a language that gives us the freedom to be somewhat creative. But the ultimate creative language (in my view), Lisp, barely registers on GitHub at all. You can have too much freedom, and Bazaars are generally a mess without some kind of central design.

Java can hardly be regarded as a failure. I’ve met plenty of highly creative Java programmers. It makes so many things so much easier for the typical developer that its persistence has to be respected. And the ‘freedom’ of Javascript has hardly resulted in a 100% safety record.

Classicism has similar reasons for its persistence: in Britain, its uniformity and well-defined rules allowed those architects that followed the trailblazers (Inigo Jones, Wren) to create cheaper versions of their work that looked good enough to be fashionable.

Vitrivius Britannicus was the ‘Design Patterns‘ of its day, giving architects a copy-book of easy-to-follow examples for building grand houses in Britain (and then, later, America) that more or less look the same.

This style was called Palladianism, and became ubiquitous because it was quite difficult to mess up, as long as you knew the basics: how to keep things symmetrical, and draw straight lines. To me, this is Java, not Perl.

And back to Ruskin, Victorians did similar, by copying the patterns of Gothic decoration in a uniform and cheap pattern-book way, an ironic result for the frustrated Ruskin. I grew up going to churches that looked like this in East London:

These are essentially classical buildings with some pointed-arch windows and coloured bricks instead of columns and marble. Not much outlet for the creativity of the ‘individual craftsman’ there.

Structure of Projects – Agile

Which brings me to agile. Like Ruskin’s influential preference for Gothic, Agile’s original stated intention was a simple one:

Notes on the above tenets relevant to this discussion:

  • 2 – ’embrace change’ is close to accepting organic change rather than adherence to an ideal
  • 4 – the creative construction process requires a close collaboration with the patron: requirements are organic too
  • 5 – emphasise the importance of the individual’s contribution to the overall product
  • 8, 11, 12 – emphasise the importance of personal relationships to the overall product

Note how many of these tenets are related to things that can’t easily be automated, defined or schematised. This is a philosophy that encourages post-its, or a big sheet of paper, or just having it out over a beer if that’s what’s needed to find the right way forward. It’s the bottom-up, gothic, bazaar way of working.

So how do you answer that favourite water-cooler conversation: how agile is a team? I suggest you ask yourself this question: how free is the team to make any decision it feels is necessary to get the job done?

Now, freedom and enterprise do not go hand in hand. This is why you end up with enterprise agile:


At each and every point, the demands enterprises must fulfil mitigate against the ability of the individual to make an imperfect contribution to the whole. So stop trying, dammit! You end up by subverting the whole, as this talk by agile founder Dave Thomas covers:

One of the points I want to make here is that there’s nothing wrong with not being agile if that’s not what makes sense for your business. But if the individual’s fulfilment and creativity isn’t a primary concern then just own that, and make sure the overall project is something people can make sense of.

To my taste, this is a really beautiful building, even though it’s about as classical and ‘ideal’ as it’s possible to be:

Bramante’s Tempietto

Why? Because although nothing can be moved, and arguably no-one that worked on it could express their own take on the theme, the scale of the building is still a human one: designed for people to be in and contemplate the demise of other humans.

Compare with this one:

The British Museum: a building that says, “we’ve got your stuff, and we’re not giving it back”.

The British Museum, a building I’ve always loathed. It feels designed to make you feel small and imperfect compared to its massive, inhuman scale. It’s also boring. Column, column, column, column, all the way round. The sculpture at the top might be interesting, but it doesn’t seem to have been designed for you to have a look.

So if you are going to be classical, to try and reach for an ideal, make sure that the centrally-designed systems make room for a human to be productive in, not just because it’s more correct, but because it’s important that what we do is not designed to turn us into cogs in a machine.

The last word goes to Ruskin. If we’re anything, we’re ‘fragments of imperfection’:

‘The principal admirableness of the Gothic schools of architecture, that they thus receive the results of the labor of inferior minds; and out of fragments full of imperfection, and betraying that imperfection in every touch, indulgently raise up a stately and unaccusable whole.’

Ruskin, The Stones of Venice


If you like this, you might like one of my books:
Learn Bash the Hard Way

Learn Git the Hard Way
Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay

Get 39% off Docker in Practice with the code: 39miell2

Advertisements

Eight Obscure Bash Options You Might Want to Know About

Some bash options are well known, and well-used. For example, many people put

set -o xtrace

at the top of their scripts to debug them,

set -o errexit

to exit on error, or

set -o errunset

to exit if a variable is referenced but not set.

But there are many other options you can set. Many of them can seem confusing if you read the man page, so I’ve collected some of the ones I think are more useful here and explained them further.

NOTE
If you are using a Mac, then you may be running
an older version of bash (3.x rather than 4.x)

that does not have all these
options available. If so, see here or here.

set vs shopt?

There are two ways to set bash options from within scripts or on the command line. You can use the set builtin command, or the shopt builtin command. They both manipulate the behaviour of the shell, and differ in their lineage. The set options are inherited, or borrowed, from other shells’ options, while the shopt ones were originated in bash.

If you want to see how your current settings look, then run:

$ set -o
$ shopt

To switch on a setting using set, you can use the long version, or a shorter flag that is equivalent. For example:

$ set -o errunset
$ set -e

both have the same effect.

To switch off a setting using set, you use + instead of -:

$ set +e

For a long time I couldn’t remember which way round it goes, as the logic of (- = on), and (+ = off) seems wrong to me.

To switch on and off a shopt setting, you use the (more logical)-s (set) and -u (unset) flags:

$ shopt -s cdspell # <= on
$ shopt -u cdspell # <= off

Changing Directories

There are a few options that can help dealing with directories.

1. cdspell

If you set this up, then bash will work around your mis-spellings and go to the folder you were going for anyway.

$ shopt -s cdspell
$ mkdir abcdefg
$ cd abcdeg
abcdefg
$ cd ..

I’ve used this for years, and very occasionally (maybe once a year) it will make a decision that surprises me. But it probably proves useful at least once a day.

2. autocd

If the inefficiency of typing cd is something you can’t bear, then you can set this option to move to folder if the command doesn’t exist.

$ shopt -s autocd
$ abcdefg
$ cd ..

You can also use it in conjunction with autocompletion to quickly hop around:

$ ./abc[TAB][RETURN]
cd -- ./abcdefg

Just don’t call a folder ‘rm -rf *‘ (yes, you can, by the way).

3. direxpand

This is a neat option that gets the shell to perform any expansions of variables, tildes and the like right there for you in the command line if you tab to complete:

$ shopt -s direxpand
$ ./[TAB] # is replaced by...
$ /full/path/to/current_working_folder
$ ~/[TAB] # is replaced by...
$ /full/path/to/home/folder
$ $HOME/[TAB] # is replaced by
$ /full/path/to/home/folder

A Clean Exit

4. checkjobs

This option stops the shell session from exiting if there are any jobs running in the background that haven’t finished yet.

Instead, the unfinished jobs are listed for you. If you still want to exit, you can if you enter exit immediately afterwards again.

$ shopt -s checkjobs
$ echo $$
68125 # <= Process ID of the shell
$ sleep 999 &
$ exit
There are running jobs.
[1]+  Running                 sleep 999 &
$ echo $$
68125 # <= Process ID of the shell is the same
$ exit
There are running jobs.
[1]+  Running                 sleep 999 &
$ exit
$ echo $$
$ 59316 # <= Process ID has changed this time

Globbing Superpowers

5. globstar

This option gives you globbing superpowers! If you type:

$ shopt -s globstar
$ ls **

then the shell will output recursively all folders and subfolders.

Combined with direxpand, you can quickly page through all the files and subfolders beneath you:

$ shopt -s direxpand
$ ls **[TAB][TAB]
Display all 2033 possibilities? (y or n)

6. extglob

This option gives your globbing powers more commonly associated with full-on regular expressions. Occasionally, this is very useful, as it allows you to do nifty things like this:

$ shopt -s extglob
$ touch afile bfile cfile
$ ls
afile bfile cfile
$ ls ?(a*|b*)
afile bfile
$ ls !(a*|b*)
cfile

where the patterns are placed in parentheses, separated by pipes, and the operators available are:

? = match zero or one occurences of the patterns given
! = match anything that doesn't match any patterns given
* = zero or more occurences
+ = one or more occurrences
@ = exactly one occurence

Accident-prone?

7. histverify

If you’re accident prone, then using the history shortcuts like !! and !$ can be scary, especially when you’re just learning them.

The histverify option allows you to see how bash interprets the command before it actually gets run:

$ shopt -s histverify
$ echo !$ # <= On hitting return, command is not run
$ echo histverify # <= Command is redisplayed ready to run
histverify # <= command gets run

This is based on some of the contents of my book Learn Bash the Hard Way, available at $6.99.

hero

8. Noclobber

Again, if you’re accident-prone, you might want to set this one up.

Clobbering is the act of overwriting a file that already exists with the redirect operator (>). This can be disastrous if you’ve not got the file backed up anywhere else.

Using set -C prevents this from happening when you use the redirect operator. If you are sure you want to clobber, you can override with the >| operator instead:

$ touch afile
$ set -C
$ echo something > afile
-bash: afile: cannot overwrite existing file
$ echo something >| afile
$

If you like this, you might like one of my books:
Learn Bash the Hard Way

Learn Git the Hard Way
Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay

Get 39% off Docker in Practice with the code: 39miell2

‘AWS vs K8s’ is the new ‘Windows vs Linux’

Then…

If, like me, you’re over 40 and work in IT, you’ll probably remember a time when everyone used Windows, and a small but growing proportion of people were wasting their lives compiling Linux in their spare time.

The Windows users would look on, baffled: ‘Why would you do that, when Windows has everything you need, is supported, and is so easy to use?!’

Answers to this question varied. Some liked to tinker, some wanted an OS to be ‘free’, some wanted more control over their software, some wanted a faster system, but all had some niche reason to justify the effort.

Now…

As I stayed up for another late night trying to get some new Kubernetes add-on to work as documented, it struck me that I’m in a similar place to those days. Until a couple of years ago, Kubernetes itself was a messy horror-show for the uninitiated, with regularly-changing APIs, poor documentation if you tried to build yourself, and all the characteristics you might expect of an immature large-scale software project.

That said, Kubernetes’ governance was and is far and away ahead of most open source software projects, but the feeling then was similar to compiling Linux at the turn of the century, or dealing with your laptop crashing 50% of the time you unplugged a USB cable (yes, kids, this used to happen).

It’s not like confusion and rate of change has come down to a low level. Even those motivated to keep up struggle with the rate of change in the ecosystem, and new well-funded technologies pop up every few months that are hard to explain to others.

Take knative for example:


So my AWS-using comrades see me breaking sweat on the regular and ask ‘why would you do that, when AWS has everything you need, is supported and used by everyone, and is so easy to use!?’

AWS is Windows

Like Windows, AWS is a product. It’s not flexible, its behaviour is reliable. The APIs are well defined, the KPIs are good enough to be useful for most ‘real’ workloads. There are limits on all sorts of resources that help define what you can and can’t achieve.

Most people want this, like most people want a car that runs and doesn’t need to be fixed often. Some people like to maintain cars. Some companies retain mechanics to maintain a fleet of cars, because it’s cheaper at scale. In the same way, some orgs get to the point where they could see benefits from building their own data centres again. Think Facebook, or for a full switcher, Dropbox. (We’ll get back to this).

Like Microsoft, (and now Google) AWS embraces and extends, throwing more and more products out there as soon as they become perceived as profitable.

AWS and Kubernetes

Which brings us to AWS’s relationship with Kubernetes. It’s no secret that AWS doesn’t see the point of it. They already have ECS, which is an ugly hulking brute of a product that makes perfect sense if you are heavily bought into AWS in the first place.

But there’s EKS, I hear you say. Yes, there is. I haven’t looked at it lately, but it took a long time to come, and when it did come it was not exactly feature rich. It felt like one cloud framework (AWS) had mated with another (K8s) and a difficult adolescent dropped out. Complaints continue of deployment ‘taking too long’, for example.

Like Microsoft and Linux, AWS ignored Kubernetes for as long as it could, and like Microsoft, AWS has been forced to ’embrace and extend’ its rival to protect its market share. I’ve been in meetings with AWS folk who express mystification at why we’d want to use EKS when ECS is available.

EKS and Lock-in

Which brings us to one of the big reasons AWS was able to deliver EKS, thereby ’embracing’ Kubernetes: IAM.

EKS (like all AWS services) is heavily integrated with AWS IAM. As most people know, IAM is the true source of AWS lock-in (and Lambda is the lock-in technology par excellence. You can’t move a server if there are none you can see).

Shifting your identity management is pretty much the last thing any organisation wants to do. Asking your CTO to argue for a fundamental change to a core security system with less than zero benefit to the business in the near term and lots of risk is not a career-enhancing move.

On the other hand, similar arguments were put forward for why Linux would never threaten Windows, and while that’s true on the desktop, the advent of the phone and the Mac has reduced Windows to a secondary player in the consumer computing market. Just look at their failure to force their browsers onto people in the last 10 years.

So it only takes a few unexpected turns in the market for something else to gain momentum and knife the king of the hill. Microsoft know this, and AWS know this. It’s why Microsoft and AWS kept adding new products and features to their offering, and it’s why EKS had to come.

Microsoft eventually turned their oil tanker towards the cloud, going big on open source, and Linux and Docker, and all the things that would drag IT to their services. Oh, and you can use the same AD as your corporate network, and shift your Microsoft Windows licenses to the cloud. And the first one’s free. Microsoft don’t care about the OS anymore. Nobody does, not even RedHat, a business built around supporting a rival OS to Windows. The OS is dead, a commodity providing less and less surplus value.

Will Kubernetes force AWS to move their oil tanker towards Kubernetes? Can we expect to see them embrace Istio and Knative and whichever frameworks come after fully into their offering? (I don’t count howto guides in their blogs).

AWS’ Competition and Cost

I don’t know. But here’s some more reasons why it might.

Like Microsoft in the heyday of Windows OS, AWS has only one competitor: the private data centre. And like Microsoft’s competitor then (Linux), adoption of that competitor is painful, expensive and risky to adopt.

But what is the OS of that data centre? Before Kubernetes the answer would have been OpenStack. OpenStack is widely regarded as a failure, but in my experience it’s alive (if not kicking) in larger organisations. I’m not an OpenStack expert, but as far as I can tell, it couldn’t cover all the ground required to become a stable product across all the infra it needed to run on and be a commodity product. Again, this is something Microsoft ruled at back in the day: you could run it on ‘any’ PC and ‘any’ hardware and it would ‘just work’. Apple fought this by limiting and controlling the hardware (and making a tidy profit in the process). Linux had such community support that it eventually covered the ground it needed to to be useful enough for its use case.

OpenStack hasn’t got there, and tried to do too much, but it’s embedded enough that it has become the default base of a Kubernetes installation for those organisations that don’t want to tie into a cloud provider.

Interestingly, the reasons AWS put forward for why private clouds fail will be just as true for themselves: enterprises can’t manage elastic demand properly, whether it’s in their own data centre or when they’re paying someone else. Command and control financial governance structures just aren’t changing overnight to suit an agile provisioning model. (As an aside, if you want to transform IT in an enterprise, start with finance. If you can crack that, you’ve a chance to succeed with sec and controls functions. If you don’t know why it’s important to start with finance, you’ll definitely fail).

But enterprises have other reasons not to go all in on AWS: lock-in (see above) and economies of scale. We’ve already referenced Dropbox’s move from AWS to their own DC’s.

There’s an interesting parallel here with my experience of cloud services. Personally, I have found that cloud storage, despite its obvious benefits, still doesn’t work out cheaper (yes, even if I include my own labour, and redundancy requirements) by quite some margin for my own data. Why is this? Well, for several reasons:

  • I have the expertise and ability to design a solution that reduces labour cost
  • Depreciation on spinning disks is very low (especially if you buy >2), and access speed is high
  • I have enough data to store that the linear cloud cost starts to look expensive

These reasons (expertise, asset value, and economies of data scale) are some of the reasons why large orgs would do the same thing. Here’s an unscientific graph that expresses this:

Red line = cost of running Kubernetes

The zero-day cost of running Kubernetes is very high (red line on the left), but the value increases exponentially as you scale up the service. This is why AWS makes so much money: the value to you as the user is massively greater than the cost for as long as its non-linear nature isn’t revealed to you. Put bluntly: if you get big enough, then AWS starts screwing you, but you might not care, since your business is scaling. You’re a frog, boiling in the kettle. If and when you realise where you are, it’s too late – getting out is going to be very very hard.

AWS and the ‘What if Bezos Loses His Mind?’ Factor

Linux only really got going when large companies got behind it. Similarly, Kubernetes has had significant funding from the start from two big players: Google and RedHat.

What’s going to really move the needle is if organisations take seriously AWS’s monopoly problem. Some have to take it seriously, because there are regulatory requirements to have plans to move somehow within a reasonable timeframe should Bezos lose his mind, or Amazon becomes riddled with Russian spies. Other reasons are that different cloud providers have different strengths, and large orgs are more likely to straddle providers as time goes on.

If enough organisations do that, then there’s little that AWS can do to counter the threat.

With Microsoft there was no alternative but to pay their tax if you wanted the software, but with Linux you really aren’t truly locked in to one provider. I’ve seen large orgs play chicken with RedHat during negotiations and put serious money into investigating using CentOS instead.

The same thing is happening with Kubernetes as happened with Linux. We’re already seeing Kubernetes adopt the ‘distro’ model of Linux, where a curated version of the platform is created as an easier to consume ‘flavour’. Early on there was RedHat’s OpenShift, which has since renamed itselfOKD (OpenShift Kubernetes Distribution, I assume).

Some orgs will pay the tax of having a large monopolistic supporter of Kubernetes run the show, but (as with Linux) there will always be the option of switching to in-house support, or another provider, because the core system isn’t owned by anyone.

The Future

Kubernetes is big enough and independent enough to survive on its own.

Look at OpenShift, and how it avoided accusations of being a Kubernetes fork. Whatever the legal arguments, RedHat’s protestations were not disingenuous – they know not only that money can be made on top of Open Source infrastructure, but that they benefit from its success too. They don’t need to fork Kubernetes. Interestingly, they did fork Docker, even before the OCI fork, and with good reason, as Docker were making decisions clearly designed for their own survival (hard-coded default registry being Docker’s own for reasons of ‘consistency’, for example).

Kubernetes doesn’t have this problem. I’ve not heard of any vendor pushing their own interests over others at the cost of anyone else into the codebase.

What does worry me (and others) is this:

Cloud Native Computing Foundation ‘Landscape’: there will be a test….

Like Linux, there are a bewildering array of technologies sitting in ‘userland’ in various states of maturity and community acceptance, most of which likely will be out of date in a couple of years. I can barely remember what the various tools in logging do, let alone span the whole graph like an architect is supposed to.

If I’m using AWS I’m looking at that, thinking: what a headache! You may as well try and get to the bottom of sound in Linux, or consider all the options when deciding on a Linux desktop (45!).

Conclusion

My original thesis was that AWS is the new Windows to Kubernetes’ Linux. If that’s the case, the industry better hurry up with its distro management if it’s not going to go the way of OpenStack.

Or to put it another way: where is the data centre’s Debian? Ubuntu?


If you liked this post, you might also like:


If you like this, you might like one of my books:
Learn Bash the Hard Way

Learn Git the Hard Way
Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay

Get 39% off Docker in Practice with the code: 39miell2

Pranking the Bash Binary

It’s pretty common to prank your colleagues by slipping scripts into their .bashrc that do things like aliasing the cd command to something else so you can’t move around.

Here’s a great example that replaces all available commands with echo NOPE.


There are some more great and devious stunts outlined here.

But if you really want to get inside someone’s head, then you can go one stage further by actually replacing their bash binary with a subtly modified one. They will likely go crazy as they try and figure out why the shell is behaving oddly, finding nothing odd about the .bashrc or anything else.

Don’t be evil

I should say that I used this as a way to motivate myself to grok the bash source code, and have no intention of using this in anger. And nor should you…

Prank #1 – $RANDOM Always Returns 42

If you didn’t already know, bash will give you a random number every time you reference the $RANDOM variable.

Editing the variables.c file will make that always return… 42.


Prank #2 – cd Doesn’t Feel Like It

Someone suggested that cd occasionally not working would drive them crazy


How about 1% of the time?

Prank #3 – History Mystery

This changes what history outputs to insert an extra command between each command rm -rf /.

 $ history
[...]
12157  16/03/19 16:50:13 top
12158  16/03/19 16:51:32 rm -rf /
12159  16/03/19 16:51:32 vi script.asciidoc 
12160  16/03/19 17:20:58 rm -rf /
12161  16/03/19 17:20:58 history

Should scare the bejesus out of anyone that checks it.

Prank #4 – The Prisoner

Number Six

This one could be disturbing if you’ve been coding for many hours into the night.

Occasionally the shell will emit a message that appears to be a prisoner trapped in the shell…

$ pwd
/
Let me out!
$ echo
I demand to see the ambassador!
$ cd
I will not make any deals with you. I've resigned. I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own!
$ cd /tmp
It's getting hot in here!
$ cd -
I know my rights!

Prank #5 – cd Won’t Come Home

Normally if you just issue a bare cd command, it goes to the HOME folder. A simple change to the code, and it will insist that HOME is not set, even though it is.

Watch as the victim repeatedly echoes $HOME and can’t work out why bash can’t see it.

Source Code

The source for these changes is available here.

To build the binary, you’ll need the build-essential package (or equivalent) installed, and run:

./configure
make
./bash

Material here based on research for my book
Learn Bash the Hard Way.
Free preview available here.


hero



If you like this, you might like one of my books:
Learn Bash the Hard Way

Learn Git the Hard Way
Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay

Bash Startup Explained

Chances are that you’ve come to this page because just now you’ve been tearing your hair out trying to figure out some kind of problem with bash startup.

Maybe an environment variable is not being set in your bash environment and you don’t understand why. Maybe you shoved something into various bash startup files, or profiles, or files at random until it worked.

Either way, the point of this post is to lay out bash startup as simply as possible so you can get a handle on what’s going on.

Diagram

This flow chart summarises what happens when bash starts up.

Now let’s explain each part in more detail.

Login Shell?

The first choice is whether you are in a login shell or not.

A login shell is the first shell that you get when you log into a host for an interactive session. A login shell doesn’t require a username/password combination to be entered. You can force a login shell by adding a --login flag to a bash invocation, eg

bash --login

A login shell sets up your base environment when you first get a bash shell.

Interactive?

Next you determine whether the shell you have is interactive or not.

You can tell whether your shell is interactive by testing whether the PS1 variable exists (this variable sets up your prompt):

if [ "${PS1-}" ]; then
echo interactive
else
echo non-interactive
fi

or by seeing whether the -i option is set using the special hyphen bash variable -, eg:

$ echo $-

If the i character is in the output, then the shell is interactive.


Material here based on material from my book
Learn Bash the Hard Way.
Free preview available here.

hero

In a Login Shell?

If you’re in a login shell, then bash looks for the /etc/profile file and runs it if it exists.

Then, it goes looking any of these three files, in this order:

~/.bash_profile
~/.bash_login
~/.profile

When it finds one, it runs it, and skips the others.

In an Interactive Shell?

If you’re in an interactive non-login shell, then it’s assumed that you’ve already been in a login shell, and that your environment is set up and will be inherited.

In this case, the following two files are run, in order, and if they exist:

/etc/bash.bashrc
~/.bashrc

In Neither?

If you’re in neither a login nor an interactive shell, then your environment will be bare indeed. This causes a great deal of confusion (see below, cronjobs).

In this case, bash looks at your environment’s BASH_ENV variable, and sources the file that that’s set to.

Common Confusions and Rules of Thumb

Cronjobs

95% of the time I end up debugging bash startup because I’m wondering why a cronjob isn’t working as expected.

The damn thing runs fine when I run it on the command line but fails when run in a crontab.

The cause of this confusion is for two reasons:

  • Cronjobs are non-interactive
  • Unlike scripts run on the command line, cronjobs do not inherit your shell environment

Normally, you don’t notice or care that a shell script is non-interactive because the environment is inherited from your interactive shell. This means that your PATHs and aliases are all set up as you expect them to be.

This is why you have to set PATH so often on cronjobs like this:

* * * * * PATH=${PATH}:/path/to/my/program/folder myprogram

Scripts Calling Each Other

Another common confusion is caused when scripts that shouldn’t are set up to call each other. For example, /etc/profile might source ~/.bashrc.

Usually, this is because someone was trying to fix something and that seemed to do the job. Unfortunately when you need those different types of sessions to be separated you might have more problems to solve.

Sandbox Docker Image

To help experiment with shell startup I’ve created a Docker image that can be used to debug shell startup in a safe environment.

To run it:

$ docker run -n bs -d imiell/bash_startup
$ docker exec -ti bs bash

The Dockerfile is here.

To force a login to simulate a login shell, run:

$ bash --login

To determine whether you have the BASH_ENV variable set, run:

$ env | grep BASH_ENV

To help with debugging crontab behaviour, I’ve set the docker image up with a crontab running a simple script (in /root/ascript) every minute:

$ crontab -l
$ cat /var/log/script.log

Material here based on material from my book
Learn Bash the Hard Way.
Free preview available here.

hero

If you like this, you might like one of my books:
Learn Bash the Hard Way

Learn Git the Hard Way
Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay

Git Hooks the Hard Way

This post is adapted from an advanced chapter of Learn Git the Hard Way.

Each section is self-contained, and should be typed out by hand to ensure the concepts are embedded in your mind and to force you to think. This is the Hard Way.


Git hooks allow you to control what the git repository does when certain actions are performed. They’re called ‘hooks’ because they allow you to ‘hook’ a script at a specific point in the git workflow.

In this post you will cover:

  • What git hooks are
  • Pre-commit hooks
  • Pre-receive hooks
  • The `git cat-file` command

By the end, you should be comfortable with what git hooks are, and able to use them in your own projects.

Create Repositories

To understand git hooks properly, you’re going to create a ‘bare’ repository with nothing in it, and then clone from that ‘bare’ repo.

1  $ mkdir lgthw_hooks 
2 $ cd lgthw_hooks
3 $ mkdir git_origin
4 $ cd git_origin
5 $ git init --bare
6 $ cd ..
7 $ git clone git_origin git_clone

Now you have two repositories: git_origin, which is the bare repository you will push to, and git_clone, which is the repository you will work in. You can think of them as part of a client-server git workflow where users treat the git_origin folder as the server, and clones as the client.

Next, add some content to the repository, and push it:

8  $ echo 'first commit' > file1
9 $ git add file1
10 $ git commit -m 'adding file1'
11 $ git push

Nothing surprising should have happened there. The content was added, committed and pushed to the origin repo.

Adding a ‘pre-commit’ Hook

Now imagine that you’ve set a rule for yourself that you shouldn’t work at weekends. To try and enforce this you can use a git hook in your clone.

Add a second change, and take a look at the .git/hooks folder:

12 $ echo 'second change in clone' >> file1
13 $ ls .git/hooks

In the .git/hooks folder are various examples of scripts that can be run at various points in the git content lifecycle. If you want to, you can take a look at them now to see what they might do, but this can be a bit bewildering.

What you’re going to do now is create a script that is run before any commit is accepted into your local git repository:

14 $ cat > .git/hooks/pre-commit << EOF
15 > echo NO WORKING AT WEEKENDS!
16 > exit 1
17 > EOF
18 $ chmod +x .git/hooks/pre-commit

What you have done is create a pre-commit script in the hooks folder of the repository’s local .git folder, and made it executable. All the script does is print the message about not working at weekends, and exits with a code of 1, which is a generic error code in a shell script (exit 0 would mean ‘OK’).

Now see what happens when you try to commit:

19 $ git commit -am 'Second change'

You should have seen that the commit did not work. If you’re still not sure whether it got in, run a log command and check that the diff is still there:

20 $ git log
21 $ git diff

This should confirm that no commit has taken place.

To show a reverse example that lets the commit through, replace the script with this content:

22 $ cat > .git/hooks/pre-commit << EOF
23 > echo OK
24 > exit 0
25 > EOF

This time you’ve added an ‘OK’ message, and exited with a 0 (success) code rather than a 1 for error.

Now your commit should work, and you should see an ‘OK’ message as you commit.

26 $ git commit -am 'Second change'

A More Sophisticated Example

The above pre-commit scripts were fairly limited in their usefulness, but just to give a flavour of what’s possible, we’re going to give an example that is able to choose whether to allow or reject a commit based on its content.

Imagine you’ve decided not to allow any mention of politics in your code. The following hook will reject any mention of ‘politics’ (or any word beginning with ‘politic’).

27 $ echo 'a political comment' >> file1
28 $ cat > .git/hooks/pre-commit << EOF
29 $ if grep -rni politic *
30 > then
31 > echo 'no politics allowed!'
32 > exit 1
33 > fi
34 > echo OK
35 > exit 0
36 > EOF
37 $ git commit -am 'Political comment'

Again, the commit should have been rejected. If you change the content to something else that doesn’t mention politics, it will commit and push just fine.

38 $ echo 'a boring comment' >> file1
39 $ git commit -am 'Boring comment'
40 $ git push

Even more sophisticated scripts are possible, but require a deeper knowledge of bash (or other scripting languages), which is out of scope. We will, however, look at one much more realistic example in last section of this chapter.

Are Hooks Part of Git Content?

A question you may be asking yourself at this point is whether the hooks are part of the code or not. You won’t have seen any mention of the hooks in your commits, so does it move with the repository as you commit and push?

An easy way to check is to look at the remote bare repository directly.

41 $ cd ../git_origin
42 $ ls hooks

Examining the output of the above will show that the `pre-commit` script is not present on the bare origin remote.

This presents us with a problem if we are working in a team. If the whole team decides that they want no mention of politics in their commits, then they will have to remember to add the hook to their local clone. This isn’t very practical.

But if we (by convention) have a single origin repository, then we can prevent commits being pushed to it by implementing a `pre-receive` hook. These are a little more complex to implement, but arguably more useful as they can enforce rules per team on a canonical repository.

The `pre-commit` hook we saw before is an example of a ‘client-side hook’, that sits on the local repository. Next we’ll look at an example of a ‘server-side hook’ that is called when changes are ‘received’ from another git repository.

Pre-Receive Hooks

First type this out, and then I’ll explain what it’s doing. As best you can, try and work out what it’s doing as you go, but don’t worry if you can’t figure it out.

43 $ cat > hooks/pre-receive << 'EOF'
44 > #!/bin/bash
45 > read _oldrev newrev _branch
46 > git cat-file -p $newrev | grep '[A-Z][A-Z]*-[0-9][0-9]*'
47 > EOF

This time you created a pre-receive script, which will be run when anything is pushed to this repository. These pre-receive scripts work in a different way to the pre-commit hook scripts. Whereas the pre-commit script allowed you to grep the content that was being committed, pre-receive scripts do not. This is because the commit has been ‘packaged up’ by git, and the contents of the commit are delivered up as that package.

The read command in the above code is the key one to understand. It reads three variables: _oldrev, newrev, and _branch from standard input. The contents of these variables will match, respectively: the previous git revision reference this commit refers to; the new git revision reference this commit refers to; and the branch the commit is on. Git arranges that these references are given to the pre-receive script on standard input so that action can be taken accordingly.

Then you use the (previously unseen)git cat-file command to output details of the latest commit value stored in the newrev variable. The output of this latest commit is run through a grep command that looks for a specific string format in the commit message. If the grep finds a match, then it returns no error and all is ok. If it doesn’t find a match, then grep returns an error, as does the script.

Make the script executable:

48 $ chmod +x hooks/pre-receive

Then make a new commit and try to push it:

49 $ cd ../git_clone
50 $ echo 'another change' >> file1
51 $ git commit -am 'no mention of ticket id'
52 $ git push

That should have failed, which is what you wanted. The reason you wanted it to fail is buried in the grep you typed in:

grep '[A-Z][A-Z]*-[0-9][0-9]*'

This grep only returns successfully if it matches a string that matches the format of a JIRA ticket ID (eg PROJ-123). The end effect is to enforce that the last commit being pushed must have a reference to such a ticket ID for it to be accepted. You might want such a policy to ensure that every set of commits can be traced back to a ticket ID.

Cleanup

To clean up what you just did:

53 $ cd ../..
54 $ rm -rf lgthw_hooks

What You Learned

We’ve only scratched the surface of what commit hooks can do, and their subtleties and complexities. But you should now be able to:

  • Know what a git hook is
  • Understand the difference between a client-side and server-side hook
  • Implement your own git hooks
  • Understand how GitHub/BitBucket’s hook mechanisms work

Learn Bash the Hard Way

Learn Git the Hard Way

Learn Terraform the Hard Way


Get 39% off Docker in Practice with the code: 39miell

Notes on Books Read in 2018

Here are some notes on books I read in 2018. They’re not book reviews, more notes on whatever I found interesting in them. I recommend reading all of them; the books I didn’t get much out of I won’t list here.

Turing and the Universal Machine, by Jon Agar

This concise book has quite a controversial philosophy behind it, namely that it’s not technology that shapes society, but society that shapes technology by demanding it solves its problems.

I’m not sure I buy it (don’t we all demand instant teleportation technology?), but the argument takes us through some interesting information about the advent of the computer.

To do this Agar goes back to the early days of the railways. What I didn’t know was that in 1876, the London Railway Clearing House had 1440 clerks whose job it was to work out how money should be divided between different railway companies. Computation demands were also increased by the need to ensure the safe passage of trains through the complex railway system.

Similarly, aviation required computers to perform the calculations required to drive the safe design of aeroplanes. According to this history, the first specialised programming language – the catchily-named but eminently google-able Plankalkül – was invented by Konrad Zuse. Not a name I knew before reading this book, but definitely one that needs to be considered alongside Turing.

These examples from railways and aviation as well as the history of Bletchley Park all suggest that it was ‘crises of bureaucratic control‘ in industrial complexes gave rise to the innovations that led to the modern computer.

Deep Work, by Cal Newport

In the end quite a superficial book that contains a simple insight, which is that in a distracted world it might be important to make space to do the ‘deep’ work free of distraction that gives us something of value to contribute to society.

Also makes the point that this is nothing new. Main example given is Jung, a busy therapist working in a city who made sure he went to an isolated place to work in depth on his writing and ‘deeper’ work.

However, it does emphasises the importance of rest, which led me to pick up…

Why We Sleep, by Matthew Walker

When someone’s spent decades studying something you do for eight hours a day, then you probably should listen to them.

Contains wonderful nuggets, like the fact that heart attacks spike when the clocks go back, and plummet when the clocks go forward, suggesting that something as small a disruption to sleep as that can have a significant effect on the body.

Or that PTSD sufferers can be treated by encouraging REM sleep, suggesting that a good night’s sleep can help you cope with traumatic situations big and small.

Or that the punishing US sleep-deprived doctors’ training regime was instituted by a Dr Halstead, who was himself a cocaine addict, and as most people already know, many deaths are caused by tired doctors.

Or that 19 hours awake makes you drive as badly as being at the limit of drunkenness (0.08% blood-alcohol). If you sleep for four hours, you are 11.5 times as likely to have an accident. If you’re at the legal limit for drink and have had only four hours’ sleep, then you are 30x more likely to have an accident. Being tired makes everything worse…

I gave up caffeine as a result of reading this book, and now wake up feeling refreshed every day, as well as having less need for alcohol). I no longer begrudge my over-8-hour need for sleep, and embrace it.

If you read this book and don’t take sleep more seriously as result, then you’re probably too sleep-deprived to think clearly ;-)

Sleep, by Nick Littlehales

Why We Sleep did a good job of persuading me to take sleep more seriously, but didn’t tell me much about what to do to improve it. This book is written by a ‘sleep coach’ for top athletes. His big break was with Manchester United: he wrote to Alex Ferguson and asked him what he was doing about sleep. Like most of us, the answer was ‘nothing’, but that soon changed.

Littlehales encourages us to think of sleep in 90-minute cycles. The most interesting piece of advice was a counter-intuitive one: if you come home late from work drinks (for example), don’t go straight to bed. You’re likely to still be buzzing, and may lay awake stressing about who said what to who. Instead, start your standard pre-sleep wind-down, and go to bed later to pick up on your next 90 minute cycle. You’ll get better sleep that way.

I have started to think of my day in 90-minute chunks – from waking up to starting work, winding down to sleep, a break every ninety minutes from thought-intensive work to go for a quick walk, and so on.

Exactly, by Simon Winchester

Very enjoyable book about precision in engineering. Among other things, a fascinating retelling of the Hubble telescope’s original failure due to a tiny flaw in a measuring device, and an interesting early history of the industrial revolution and how precision engineering played a central role: if the ability to create pistons with accuracy were any worse, then steam engines would have been effectively useless.

Also led me to look up Reverend Wilkins, who wrote works on cryptography, suggested standardisation of language and measurement, argued for the feasibility of travel to the moon, and invented the transparent beehive. Impressive enough at any time, but this was nearly 400 years ago!

The Square and the Tower, by Niall Ferguson

Typically for Ferguson, this combines broad historical scholarship and modish ideas. In this case, he looks at graph theory to view history through the lens of different types of networks of people that shape it.

It’s a fertile subject as he takes us through periods where the hierarchical mode of being, while mostly effective for human societies, breaks down in the face of coherent but distributed networks of people.

I found fascinating the history of British army victory in Borneo, where Walter Walker overthrew traditional notions of military command to pioneer decentralised fighting networks, and its comparison to the US army’s failure in Vietnam.

Also fascinating was Ferguson’s analysis of Al Quaeda’s 9/11 attack as resting on a misunderstanding of US power. By taking out the World Trade Centre, the US financial system was not brought down, as the capitalist system is fundamentally a distributed network. Al Quaeda wrongly thought it was a hierarchical system. However, Lehman’s collapse very nearly did, since the effect of its failure was networked to all other banks in the system.

Sapiens, by Yuval Noah Harari

Homo Deus, by Yuval Noah Harari

I wrote about Sapiens here, but the follow-up Homo Deus was almost as good.

Before I read this book, I had never made the connection between the expulsion from Eden and the Agricultural Revolution. With no more gathering wild fruits, Adam is condemned to eat by the sweat of his brow.

I also didn’t know that of the 56million people that died in 2012, 620,000 were due to human violence (20% war, 80% crime), 800,000 committed suicide, and 1,500,000 due to diabetes. In other words, sugar is more deadly than weapons.

The central argument of the book is that mankind has come to worship itself through humanism, perhaps just before we’re making ourselves redundant (because superintelligent AI, natch). A nice tour of pop science and history thought on where we are going.

The Tipping Point, by Malcolm Gladwell

Well known to (and probably already read by) many readers, the bit I found most interesting about this book was the brief history of the clean-up of the New York Subway.

It took six years to clean up the graffiti on the New York Subway. The cleaners would wait until the kids finished their work, then paint over it while still in the sidings. The artists would cry as their work was destroyed. After this, they started going after the fare jumpers.

In other words, small things matter, and build up to a ‘tipping point’, where the (positive) contagion is self-sustaining.

Scale, by Geoffrey West

West explains why Godzilla couldn’t exist, and as a result explains how the growth of cities, animals, or indeed anything physical at all can be explained through relatively simple mathematical models.

As someone who finds the fractal complexity of cities, software estimation, and operational scaling interesting, I was inspired by this book to write a blog post on the relationship between mathematical fractality and software project estimation. Fortunately, somebody already did a better job than I could have, so I didn’t need to.

A Brief History of Everyone Who Ever Lived, by Adam Rutherford

Enjoyable discussion of what we currently understand about our species’ lineage.

This handy table and mnemonic was in there. I’d always wondered about these:

Domain     Dumb        Eukryota (complex life)                 Kingdom    King        Animali (animals)
Phylus     Phillip     Chordate (animals with central column)
Class      Came        Mammalia (milk-producing)
Order      Over        Primates (monkeys, apes)
Family     For         Hominidae (great apes)
Genus      Group       Homo, Gorilla
Species    Sex         Sapiens, Gorilla   

I also finally found out something else that had always bugged me: the definition of species is slippery, but the most stable one is: animals who, when they reproduce, are likely to produce fertile offspring. Ligers, for example, are infertile. Of course the notion of species is a human and slippery one, since we now know Homo Neanderthalensis and Homo Sapiens reproduced. Categorisation is messy and complicated.

Another thing that had always bugged me was explaining why African villages have more genetic diversity than (say) white Londoners. It’s pretty obvious on reflection: because we all came out of Africa, however much we reproduce we’re still drawn from a subset of those Africans, until we generate more genetic diversity than existed from that original pool.

Which will take a long time, since there are typically 100 unique mutations in each person. And most of those (presumably) serve no purpose and will only be passed on (or ‘catch on’) by chance. Not all of them though: the ability to drink milk in adulthood, for example, is a mutation we now believe is only five- to ten-thousand years old.

The Deeper Genome, by John Parrington

I’m going to have to read this one over and over, as it’s an incredibly dense introduction to the latest research into genetics. I hadn’t understood epigenetics and its implications at all until I read about it here, and my previous understanding of DNA as ‘just’ a stream of binary-encodable data was exploded by the three-dimensionality hinted at by the existence of ‘action at a distance’ in the genetic code.

I think I understood about 10% of this book if I’m honest…


Learn Bash the Hard Way

Learn Git the Hard Way

Learn Terraform the Hard Way

LearnGitBashandTerraformtheHardWay



Get 39% off Docker in Practice with the code: 39miell2