Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
The obvious and the not-so-obvious
Letâs take that pipeline from a Pendolino to a Japanese Bullet Train
Continuous Integration and Continuous Delivery (CI/CD) is a staple of any software house worth its salt. It is a practice that has become so foundational in the industry that many of us can no longer imagine working without it. It is as basic as tests and every bit as useful. Yet, there are such a great variation of pipelines out there, some bad, some good, some insane. Iâve seen many of them.
Iâve been working with CI/CD systems for several years now and in my time, Iâve amassed a plethora of my own failures. Failures that have resulted in a little wisdom and a lot of grey hairs.
To start, Iâll go over some basic capabilities that your pipeline should have. Iâll mark the essentials, the nice to haves and the downright futuristic. Then weâll talk about your Non-functionals. Speed, logging, error handling.
Just what the hell is CI/CD?
Before we get into the meat of this article, a quick overview. Back in the glory days of 1997, when Oasis were going strong and dressing like an undertaker was cool, two men came out with Extreme Programming. Kent Beck and Ron Jeffries. XP listed out a set of practices, principles and values that they believed would usher in a better world of software engineering. It was a sensational change.
First, CI.
While Continuous Integration (CI) had been proposed by Grady Booch in 1991, it was Kent and Ron that pushed it forward. In short, CI is taking all of the code and testing it, all the time. Constantly. The aim? To prove that the team arenât drifting away from one another. To nip integration issues in the bud.
And CD.
Continuous Delivery was popularised by Jez Humble and David Farley. This is a two pronged principle:
- The code in the trunk (the master branch or the SVN trunk) should be deployable.
- Those deployments should be completely automated and should not require any manual steps.
Together, theyâre awesome.
Thatâs it, CI/CD is constantly packaging, testing and easily deploying code into a production environment. This has the advantage of eliminating integration issues and mitigating risk in deployments by making them more frequent.
So, what should a pipeline do?
Iâm glad you asked. Each of the features I have included here are necessary to realise the benefits of a CI/CD pipeline. I have tried to be exhaustive, but expect some variation.
Tests
It should run some tests against your code. This one is obvious. Wanna know your code is working? Run some damn tests.
Packaging
It should be building some kind of deployable artifact. Again, obvious. Youâre planning on deploying this, arenât you? You need an artifact.
Security Scanning
This one raises a few eyebrows, but having implemented this, I have decided it is going on the âmust haveâ list. Code and artifact scanning provide indispensable feedback. OWasp can scan your dependencies. Tenable can scan your containers. Checkmarx can take a look at your code. The specific tool isnât what is important. What matters is the capability. You need to know when a SQL injection vulnerability pops up. Your tests might pass but your code isnât production ready because itâs insecure.
Whatâs this trojan.ru file in your /tmp directory?
Donât offload that responsibility onto an Ops department or your InfoSec team. Own the problem and visualise it using automation. By baking security scanning into your pipeline, youâre generating vast streams of data. Those streams can be used in a crisis or in day to day debugging.
Deployment of Applications to ALL ENVIRONMENTS
I was once told that all deployments except production were automated because we couldnât risk it for our production environments. Their deployments were so convoluted that they didnât want to âriskâ automating it. Deciding instead to leave it to the ever reliable human mind.
Donât shy away because youâre feeling nervous. If youâve got a simple deployment process, automation is easy. If youâve got a complex process, itâs an absolute necessity. Thereâs no way out. Automate, automate, automate.
Post deployment checks
Once youâve got that deployment out, how do you know itâs working? One key ingredient to a robust pipeline is a sanity check. This can take the form of a smoke test, or something more rigorous. You might issue a HTTP call to your API and check it returns with a 2xx status code. Whateverâââdonât just assume your deployment was peachy because your app has started up.
NotificationsAll together now - my deployment just failed!!
Whether your build has failed or succeeded, a notification should be issued by the pipeline. This should be sent to the medium that your engineers use most frequently. Donât clog up peopleâs email inboxesâââall theyâll do is make a rule and hide them away in a random folder. Push them into IM (and into any auditing solution). Slack, Microsoft Teams (sigh),
Good error messages
The best way to talk about good error messages is to start with an unclear error message.
Error: "nginx-ingress" has no deployed releases
This is really obvious if you know about helmâââif you have already seen this issue before. Alas, our error messages shouldnât be aimed at only the people who know. It should be easily understood by everyone. So on the face of it, this message isnât all that clear is it? I deployed my last release. It is deployed⊠I think. If you were to run helm list youâd see something like:
NAME REVISION UPDATED STATUS
nginx-ingress 6 Fri May 3 11:19:45 2019 FAILED
The problem with the error message is that it offers no context or instruction. These are two completely essential ingredients. What does this mean, what is the impact? And what should you do? With these in mind, a more useful error message is something like this:
Your application can not be deployed because it is in a failed state. You can verify this using the helm list command. You should rollback to a previous working revision, using the helm rollback command.
The first sentence here provides the contextâââthe application is in the wrong state. Thatâs the root cause. It also offers diagnostic assistance, should you want to verify this issue yourself. Context.
The second portion of this error message offers instruction for remediation. Instead of following some ancient confluence document, the instructions are right there in the code. A good error message can remove the need for extensive tutorials and how-to guides. It can eliminate costly googling and create living, responsive documentation in the code that wonât go stale. Itâs worth spending the time getting those right.
Metrics
The last one is metrics. It is helpful to know how many deployments are failing, how many are succeeding, how long builds are taking, where the choke points are etc. There is a wealth of information for your team to dig into and understand.
Understanding metrics like these unlock true team improvement.
This data is the lifeblood of your teamâââthe metrics represent your teamâs ability to deliver software changes. If you can surface it, youâre sitting on a goldmine of information.
CI/CD is just one of my topics I ramble about on my twitter account.
CI/CD Ingredients for Success was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.