Posts

Showing posts from 2019

Perspectives

Image
I find this picture is intriguing. To one chicken, the other chicken is on the other side To the viewer of this picture, we have two stupid chickens (or one?). I find it is interesting because it's just one picture yet we could perceive it differently, depending on the place we put our perspectives.

Technical Note: LXD Database and patch SQL

I deleted some unused zfs storage pools without realizing that they are used by LXD, so today after a machine rebooted, LXD refused to startups with following log messages were output to lxd.log files t = 2019-10-07T23:02:43+0900 lvl = info msg = "Initializing storage pools" t = 2019-10-07T23:02:43+0900 lvl = eror msg = "Failed to start the daemon: ZFS storage pool \"juju-zfs\" could not be imported: " t = 2019-10-07T23:02:43+0900 lvl = info msg = "Starting shutdown sequence" t As lxd settings are stored in dqlite database (distributed sqlite) at /var/snap/lxd/common/lxd/database/global/db.bin , so I go confirm the record settings. sqlite> .tables certificates networks config networks_config images networks_nodes images_aliases nodes images_nodes operations images_properties profiles i

Visualize Enviro pHat sensors data

Image
Enviro pHat is an low-cost environmental sensing boards that let you measure temperature, light color, motion and analog sensors. The accompanied python SDK makes writing program to get data from enviro pHat as easy as pie. Enviro pHat could be used in combination with RaspPi zero to become a simple room conditions monitoring sensing board. With grafana and prometheus, it looks so easy to at least build a dashboard for environ pHat sensors data, so I decided to build a enviro pHat dashboard. System Diagram Though Enviro pHat provides SDK to get data from sensors, we need methods to that data to server. We also need to care about the connection between the device and server side. In home environment, I used Wifi as Pi Zero supports Wifi connections. Prometheus also provides scrape methods to fetch data from prometheus client, so I will add a prometheus client in the device side for prometheus server to scrape. The data is stored in prometheus data store and visualized by gra

Use MaaS to manage local computing resource

Image
Besides managing bare metal machines, MaaS (Metal as a Service) can also manage KVM guests as long as those machines are boot from network PXE. This feature allow us to efficiently manage local computing resources, while at the same time, leverage JuJu for automatically middle ware deployment. In this blog post, I will detail steps to manage KVM guest machines using MaaS. System diagram MaaS Managed Machine : MaaS Virtual Machine creates other Virtual machines through KVM Pod. All VMs access the internet through physical machine's NIC using NAT. The MaaS server will be deployed to a virtual machine running inside the physical machine. The reason for installing MaaS into a virtual machine instead of directly install to the physical machine is that we want to have the flexibility of VMs as we want to update MaaS version, or backup... The MaaS server will manage its "parent" physical machine resources through KVM pod. All machines will access to the Internet thr

Technical Notes: How to change Juju user password

Juju User JuJu has an internal user framework , which supports sharing of controllers and models. Using JuJu user feature, a sysadmin could separated users for controllers as in multiple clouds deployment or for users as in multiple systems deployment. Each juju user can have its own permissions at application, model, or controller layer. This separation of responsibilities allow multiple users to manage multiple infrastructures with a clear border of responsibilities. At controller bootstrap phase, Juju automatically creates a new user named admin with superuser privileges. This user could perform all operations at cluster level. We could confirm the current user and its privileges by  $ juju whoami Controller: kvm Model: k8s User: admin $ juju users Controller: kvm Name Display name Access Date created Last connection admin* admin superuser 23 hours ago just now  Authentication An user needs to submit its username and password in order t

Technical Notes: How to remove juju application in error state

I have been playing with juju for application deployment recently as parts of my current job. Most of the time, I just need to ` juju deploy application ` and JuJu gives me all settings, no matter what cloud I am using. However, in some cases, juju refuses to follow my orders, which makes me really frustrasted. For example, the following deployment will definitely fail because grafana charm version 24 was not updated to changes in upstream grafana. $ juju deploy grafana-24 The system will stuck with following juju status $ juju status Model Controller Cloud/Region Version SLA Timestamp experiment stark-kvm stark-kvm 2.6.5 unsupported 16:53:31+09:00 App Version Status Scale Charm Store Rev OS Notes grafana error 1 grafana jujucharms 24 ubuntu Unit Workload Agent Machine Public address Ports Message grafana/0* error idle 0 10.4.23.120 hook failed: "install"

Trading Review: No suitable stop loss and Premature Quit

I made two trading mistakes today as a beginner: No suitable stop loss and Premature Exit. I want to discuss each in more details to help my future self. 1. No suitable stop loss 2 weeks ago on May 31, I observed a big sell-off of USD agains JPY. The sell-off happened because the US and China did not agree with the counterpart's trade terms. The USD price felt because traders worried that if trade war prolongs, USD economics might get worse and therefore they sold the dollar to park their assets to a more stable currency the JPY. I myself did not think that trade war will prolong [1] and leaders of those two countries will act when they see enough struggle from their domestic company. I also observe that historically since Trump became the POTUS, he had not one time tried to devalue USD against other currency to boost America's economics. Due to above reason, I bet that USD will rise again JPY after a while, so I entered USD/JPY position by buying 50,000USD at following dis

Technical Note: Dell XPS 9370 dynamic brightness control

Recently while using Windows Pro 10, I notice that my XPS 9370 adapts its screen brightness according to contents displayed on it. When I view websites with bright color theme, XPS 9370 screen will display the website's content with its maximum brightness. However, when I view websites using dark color theme, my dell laptop screen will automatically lower its brightness accordingly. This adaptation is good because lowering display brightness helps reduce power consumption, as well as make our eyes comfortable. However, my Dell laptop often reacts too much to minor changes of contents' brightness. A huge recognizable brightness often happens even when there are minor changes to color themes. The problem turns worse when brightness incurs latency. I switch between windows of multiple applications often enough to find the brightness adaption and its latency annoying. I decided to turn off this feature. It turns out to be quite difficult to find a place to turn off this feature

Technical Memo: DynamicUser in systemd

Recently, I received a really interesting question from my customer. He found out in his file system two files (directories), which belong to an user that not in /etc/passwd . Specifically in Ubuntu Linux 18.04, these 2 files are /var/lib/private/systemd /var/lib/private/systemd/timesync These two files belong to a user named systemd-timesync with UID/GID in 62583 and this user does not belong to /etc/passwd . Traditionally, a Linux user does not always need to be in /etc/passwd because it can come from many remote sources, for example LDAP NIS / NIS+ server Windows Domain Controller Server ... All current users, both from /etc/passwd and remote sources, can be queried by getent command [1] $ getent passwd Unfortunately, Our systemd-timesync user does not appear in getent list A quick Google points to an article [2], written by systemd developer - Lennart Poettering , explaining about DynamicUser feature. It turns out that DynamicUser was introduced from sy

A Review of Kubernetes Tokyo Meetup #18

Image
In a time when every cool developer talks about infrastructure software, a meetup of infrastructure technology is certainly getting a lot of attention. In Tokyo, Tokyo k8s meetup is one of the most popular community, where k8s enthusiasts gather and share their knowledge about this new rising infrastructure technology. This week's Monday, Tokyo Kubernetes Meetup #18 was held in Tokyo and I and my colleague Wenhan fortunately have chance to join it. Never before I realize that k8s is becoming such a hot technology. The attention for this technology can be felt by the number of event registration. The event halls' capacity was solely 170 people, yet there were more than 500 people made registration (at the time I register). The organizer had to make a ticket lottery and select participants by random. I was lucky enough to get the lottery for the event. The number of registrations is 5 times over the capacity of event hall. The organizer had to randomly select participan

Technical Memo: Apparmor starting errors in Ubuntu Bionic 18.04

1. System Degradation Issue As usual, after installing some modules and modifying some user privileges, I performed a reboot for my home desktop computer. After the reboot, I always check for system start health and today is no different. $ systemctl status ● stark State: degraded Jobs: 0 queued Failed: 1 units Since: Tue 2019-04-23 13:37:13 JST; 0h 4min ago CGroup: / ├─user.slice │ ├─user-1000.slice │ │ ├─user@1000.service ...    2. What was the problem? hm... I was quite surprised at this degradation of my system, so I look for the unit that fails to start at boot time. $ systemctl list-units --failed UNIT LOAD ACTIVE SUB DESCRIPTION ● apparmor.service loaded failed failed AppArmor initialization LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, v

Technical Note: Roles, Grants for newly installed PostgreSQL

I'm familiar with MySQL yet I have always wanted to use PosegreSQL due to its feature richness. Due to differences between the 2 databases, I always find it hard to remember initial setups. Today, It took me a while to re-navigate Postgres official documentation again, before I can create a role and grant permissions to newly created roles. I think it's useful to note those tasks for my future references. Steps to setup Postgres Allow local role to access using password Create Role and Grant Permission  Manual 1. Allow password authentication to local role Postgres comes with different role management mechanisms from MySQL's. By default, local users connect with Postgres throught Unix socket without password. Postgres delegates user authentication to Linux, which means that user connect to Postgres locally needs not only a role in Postgres but also a Linux account. For a local development, this setting is quite inconvenient so I switch local user authencation t

Technical Note: Sleep Issue on Dell XPS 9370 with Ubuntu 18.04 (Bionic Beaver)

I notice than when I close my lit of Dell XPS 9370, which is installed Ubuntu Linux 18.04 (Bionic Beaver),the OS does not get into deep sleep mode. It does turn off the display, and hard disk and CPU seems to get into low power mode. However, the OS consumes battery power as normal mode and if I forget to put my computer into my backpack in this sleep mode, the CPU rallies producing heats. This definitely reduce the life of my laptop and I know that I need to do something. At first, I thought this issue relates to driver due to new hardware, but after a quick Google, I found out that Arch Linux user and Bionic Beaver users see the same issue. I think the answer made by monty47 is so complete that I need no further explanation. I copied his solution here including several references for my personal educational purposes. 1. Root cause and Solution Linux Kernel supports 4 system sleep states, though some states depend on platform support codes. Those 4 states are represented by st