Select Page

NETWAYS Blog

git gud! or: How I Learned to Stop Worrying and Love my Code

(…and I’m only 13 years late to the party…)
First of all, I have a confession to make. I’m code shy. At least that’s what I thought I was.
One of the fresh-faced young trainees this year here at NETWAYS, I’m not entirely “new” to the scene. Having gone to university (with varied success) I never was bestowed with the confidence to actually contribute to anything. In terms of feedback, my lecturers and I only looked at what I was doing wrong – yes, admittedly, to get me to stop what I was doing wrong, but approaching code like this made me feel like I was always doing something wrong.
Again, admittedly, I probably was always doing something wrong, but I felt like I shouldn’t contribute, I mustn’t contribute, the only thing I would add to an open source project would be bugs, I would mess things up more than I would be helpful to anybody. I’ve written some small stuff for myself at home, but.. why would anybody rely on my code?
It was an awful feeling. So I never did contribute. And that’s how I became code shy.
Three months into my stint at NETWAYS, and it all changed massively. Apart from my wonderful colleagues, git helped in a big way to give me more confidence, to be more active in my participation, to instill a kind of pride in my work I haven’t felt before – to stop worrying and love my code.
 

So – why write the millionth paragraph about git?

This won’t be a technical introduction, but rather a little recollection of my thoughts and emotions while getting introduced to git and using it at work – because my mind has been thoroughly blown.
 

What’s git?

Well, let’s take a look at good ol’ Wikipedia:

Git (/ɡɪt/) is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people.

Version-control? Now, what’s that supposed to mean? Is that like back in the days when I sent my source code files to my professor via mail, so he could check over them and see if I did my stuff?
Well, in a way, that could be some sort of version control system as well – just not a very automated and effective one. Version control is about the general management of files, code, data – it keeps track of changes, who did what, when (and if you’re lucky, you’ll even find a hint or two explaining why), and it allows for reversion of changes and modifications people have made.
My ears perked up when I heard this.
I can go around and mess things up and nobody would get mad at me? I won’t break stuff from the get go? I was amazed.
 

But how does git do it?

At work we have remote repositories hosted on GitLab, from which I could pull all of the files of the project onto my local machine. So now I have my own copy of the project, in which I could move, delete, add or modify files to my liking – and I wouldn’t break anything doing so, because the remote repository on GitLab would be completely unchanged.
In a way, it’s a sandbox for me, where I can go ahead and code, take care of issues, fix bugs, or add features, test them – until I feel safe to share the work I’ve done with other people. You can see how that is a comforting feeling to have – you can code without worries.
 

So – what happens behind the scenes?

Git takes snapshots of my work. A snapshot is the way git keeps track of all of the files belonging to a project. Git will checksum them, generate a SHA-1 hash. These hashes are the way git knows about the changes to the code inside the files. After I’ve staged my modified files, I can commit the changes I’ve made. Committing will checksum all of the project directories and store them in the repository – and it will store a pointer to the commit that came before it. This is awesome! So now I can have multiple points to revert the project back to, just in case. But… how would I go about doing that?
Well, let’s talk about branches. Branches are pointers to these commits, the default one being the master branch. There is a master branch on my local machine as well as on GitLab – which made me immediately nervous again. But luckily, I can just branch off of my local master, give it a meaningful name, and even push and store the commits belonging to that branch to GitLab, with the master being untouched. Again, another safe environment for me to go about my work, be more assertive in sharing it, all in a peaceful state of mind.
So – thanks to git, I feel safe in being much more creative and independent when going about contributing to our projects here at NETWAYS – and thanks to the awesome work environment here, I do have space and time to try to add to these projects in a constructive way. My colleagues can look at my code, give me tips and hints, and neither them nor me have to worry about me being a nuisance messing things up.
But what if I’ve finally fixed a bug, or added an awesome feature to one of our projects? Then it’s time to make a merge request. On GitLab, I pick a branch of mine, write a little bit about the new functions or which bugs I (hopefully) fixed, and request for these changes to be added into the master. From there, my fate lies in the hands of the project maintainers…
A successful merge request might just be the greatest feeling of all.
I know that there are a million new ways I could break things if I use git wrongly. So, getting good at git is something I must and will learn at NETWAYS. And – bursting with pride and with a newfound confidence – I look forward to learning more every day.

GitKraken – Der nahezu perfekte Git-Client


Heute möchte ich euch GitKraken vorstellen, ein Git-GUI-Client welcher sich nun seit fast 3 Jahren bei mir im täglichen Einsatz findet und mir die Arbeit mit Git an einigen Tagen sehr vereinfacht.
Wieso ein GUI-Client, wenn man CLI haben kann?
Ich habe schon einige Male von Kollegen gesagt bekommen, dass ich GitKraken doch nur nutze, weil ich mit der CLI nicht zurecht komme. Der wahre Grund ist für mich einfach die viel bessere Übersicht über Changes, History und anderen Branches, schnelleres Auschecken und Resetten von Braches und auch manchmal, die Undo- und Redofunktionen.
Einfacheres Aufteilen in Commits
Jeder der oft viel schreibt und erst nach Stunden anfängt seine Arbeit in einzelne Commits aufzuteilen, weiß wie aufwendig es ist mit git add-p zu arbeiten. Diese Arbeit wird einem von GitKraken sehr vereinfacht und geht dadurch um einiges schneller. Hier können direkt einzelne Zeilen oder Hunks zum Stagen ausgewählt werden.
Was kostet der Spaß?
GitKraken kostet je nach Projekt zwischen 0€ und 99€/Jahr. Dies hängt von der Art des Projekts ab, an dem man mit GitKraken arbeitet. Möchte man mit dem Projekt Geld verdienen und es ist nicht Open-Source, dann muss man dafür mindestens 49€ im Jahr blechen. Wer jedoch ausschließlich an privaten und/oder Open-Source-Projekten arbeitet, kann GitKraken komplett kostenlos nutzen.
Nur nahezu perfekt
Auch wenn GitKraken einwandfrei funktioniert und sehr viele gut implementierte Funktionen bieten, hat es auch so einige kleine Macken. Um GitKraken nutzen zu können benötig man einen Account, GitKraken ist Closed-Source und kostet sogar Geld, wenn man es kommerziell nutzen möchte. Diese Aspekte treffen in der Open-Source-Community oft auf wenig Unterstützung.
Download
GitKraken ist für Windows, MacOS und Ubuntu/Debian erhältlich und kann hier heruntergeladen werden.

Monthly Snap September – NETWAYS News | Tips & Tricks | DevOps | Conferences & Trainings


Hellooooo Huuumans!!! 🙂
Autumn is here & I came to think of the most famous GOT quote “Winter is coming!!“. Well, Let’s move back to the current season – “Autumn”. Did you also have the feeling, that this was a very quick month? #Vacayisover

What happened in the NETWAYS Shop?

The New of AKCP: Battery Temp Sensor (BTTS) Time to celebrate! Our NETWAYS MonitorSilke. The brand new software version 3.32 of SMS Eagle is here! Callback URL, Autoreply, SMS forwarding, and more. Silke shared her best autumn- tips: “Wir haben aufgeräumt und aufgestockt! Neues Gude Sortiment steht im Shop zur Verfügung” (We have lots of new products from Gude in our online shop!)

What are they up to now? #Developers

#Monitoring: everything is regulated. But!! What Thomas said???  Jennifer reports on DevOpsDays Berlin 2018,  “Warum ist das jetzt wichtig und was hat das mit IT zu tun?“ Weg mit dem Schrott: Müll im Weltraum – says Marius. (Store the garbage in space?).  Michael released GitLab training v2.3.0 which includes bug fixes and new features. He also updated the material and tagged v2.3.0 .  Aleksander (our new trainee) has got some news on “Ubuntu 18.04 LTS“. Michael told us about the days away with his fellow developers at the “Franconian Alps” #DEV Retreat 2018 Recap 

How do they do this all the time? #superactive | The most awaited conference is coming soon! #OSMC 

Julia claimed that the workshops are the best place to learn and get inspired. #OSMC workshops (FYI: Prometheus and Icinga 2 / Puppet workshops are sold out. Get your Graylog and Ansible workshops tickets quickly, before it`s too late!). Preparing for the OSMC? A perfect way to get in the mood for the OSMC 2018 is by watching the recap from 2017!  Julia wrote about a great opportunity at this- years` #OSMCGoing to the OSMC? Join the OSCAMP #Puppet! Check out the speakers and their talks“.
 

Stay tuned for many more upcoming NETWAYS voices!! 🙂
Keya Kher
Keya Kher
Marketing Specialist

Keya ist seit Oktober 2017 in unserem Marketing Team. Nach ihrer Elternzeit ist sie seit Februar 2024 wieder zurück, um sich speziell um Icinga-Themen zu kümmern. Wenn sie sich nicht kreativ auslebt, entdeckt sie andere Städte oder schmökert in einem Buch. Ihr Favorit ist “The Shiva Trilogy”.  

GitLab training v2.3.0 released

We really had an awesome time in the last 2 days practicing Git and GitLab. With all those ideas from a training, I’ve updated the material and tagged v2.3.0.
This release includes bugfixes for “hard to understand” slides and continues with new features added to the training, done “on the fly” yesterday: Issue boards, Web IDE with commits & CI pipeline jobs, improved workflows with milestone, issue and merge request handling and much more.
Cannot wait to practice this? Get your ticket for our GitLab training soon enough! 🙂

Icinga2 GitLab Health Check

GitLab
Neulich hatten wir bei einigen GitLab Updates auf die neueste Version das Problem, dass die Dienste nach dem Update zwar korrekt alle wieder gestartet wurden und daher unser alter Monitoring Check “Service: gitlab” den Status “Gitlab OK: All services are running!” zurückgeliefert hat, auch der Check “Service: http git.netways.de” “HTTP OK: HTTP/1.1 200 OK” geliefert hat, und daher hat ohne manuelle Prüfung niemand vermutet, dass im Hintergrund doch etwas schief gelaufen war (z.B. die Datenbank Migration während einem Update, oder ein vergessenes skip-XXX File im /etc/gitlab Verzeichnis).
Auch wenn man das Update direkt auf der command line ausgeführt hat, konnte man in der abschliessenden Meldung nicht sehen, ob noch alles o.k. ist.
Festgestellt hat man das dann erst, wenn man sich in der GitLab Admin Area unter “Health Check” den Status angesehen hat.
Unten ein Beispiel wie es aussieht, wenn alles i.O. ist (Zur Info: Die Beispiel URL und Token gibt es nicht):
GitLab Status
D.h. ein neuer Check musste her, und den gibt es auch direkt bei GitLab zum Downloaden unter:
https://gitlab.com/6uellerBpanda/check_gitlab/blob/master/check_gitlab.rb
Der alte Check lief dabei direkt auf den einzelnen GitLab Hosts. Das war mit dem neuen Check allerdings ein Problem, weil er als Voraussetzung Ruby >2.3 hat, und wir z.B. noch einige Hosts unter Ubuntu Trusty betreiben.
Deshalb wird der neue Check direkt auf dem Monitoring Server (auch Ubuntu Trusty) ausgeführt, der zu diesem Zweck zusätzlich per rvm mit einem z.Zt. neuen Ruby 2.5.1 ausgestattet wurde, wobei im Ruby Skript das Shebang leider hardcoded eingetragen werden musste, weil es (zumindest unter Trusty) nicht anders funktioniert hatte (ohne grösseren Aufwand und vielen Änderungen an anderen Systemdateien):

#!/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby

Nachdem die Token zum Zugriff im Bild oben seit einigen GitLab Versionen deprecated sind zugunsten einer IP Whitelist, hat das den Deploy des Checks zusätzlich erleichtert.
Der Aufruf des Checks sieht dann z.B. so aus:

root@icinga2-server:~# check_gitlab.rb -m health -s https://gitlab.netways.de -k
OK - Gitlab probes are in healthy state

Damit das dann auch funktioniert, muss auf der entfernten GitLab Instanz noch die IP Whitelist unter /etc/gitlab/gitlab.rb eingetragen werden:

gitlab_rails['monitoring_whitelist'] = ['127.0.0.1/8','10.XX.XX.XX/24']

Am besten checkt man natürlich nur über ein internes Netz, wie oben im Beispiel angegeben.
Das ganze kann man auch über ein GitLab Puppet Modul realisieren, indem man die Whitelist über Hiera oder Foreman verteilt:
Beispiel Hierarchie im Foreman:

gitlab:
    gitlab_rails:
      monitoring_whitelist:
      - 127.0.0.1/8
      - 10.XX.XX.XX/24
Stefan Gundel
Stefan Gundel
Senior Systems Engineer

Stefan ist ein Urgestein bei NETWAYS und arbeitet im Managed Services Team. Der internationale Durchbruch gelang Stefan als Fotomodel für den K+K Warenkorb. Nachdem er einige Jahre exklusiv für unseren Kunden StayFriends gearbeitet hat, darf er nun endlich auch wieder in anderen Projekten mitarbeiten.