dannyman.toldme.com

This page features every post I write, and is dedicated to Andrew Ho.

February 16, 2017
Ganeti, Linux, Technical

Ganeti: Segregate VMs from Running on the Same Hardware

Link: https://dannyman.toldme.com/2017/02/16/ganeti-exclusion-tags/

We have been using this great VM management software called Ganeti. It was developed at Google and I love it for the following reasons:

It is frustrating that relatively few people know about and use Ganeti, especially in the Silicon Valley.

Recently I had an itch to scratch. At the recent Ganeti Conference I heard tell that one could use tags to tell Ganeti to keep instances from running on the same node. This is another excellent feature: if you have two or more web servers, for example, you don’t want them to end up getting migrated to the same hardware.

Unfortunately, the documentation is a little obtuse, so I posted to the ganeti mailing list, and got the clues lined up.

First, you set a cluster exclusion tag, like so:

sudo gnt-cluster add-tags htools:iextags:role

This says “set up an exclusion tag, called role

Then, when you create your instances, you add, for example: --tags role:prod-www

The instances created with the tag role:prod-www will be segregated onto different hardware nodes.

I did some testing to figure this out. First, as a control, create a bunch of small test instances:

sudo gnt-instance add ... ganeti-test0
sudo gnt-instance add ... ganeti-test1
sudo gnt-instance add ... ganeti-test2
sudo gnt-instance add ... ganeti-test3
sudo gnt-instance add ... ganeti-test4

Results:

$ sudo gnt-instance list | grep ganeti-test
ganeti-test0 kvm snf-image+default ganeti06-29 running 1.0G
ganeti-test1 kvm snf-image+default ganeti06-29 running 1.0G
ganeti-test2 kvm snf-image+default ganeti06-09 running 1.0G
ganeti-test3 kvm snf-image+default ganeti06-32 running 1.0G
ganeti-test4 kvm snf-image+default ganeti06-24 running 1.0G

As expected, some overlap in service nodes.

Next, delete the test instances, set a cluster exclusion tag for “role” and re-create the instances:

sudo gnt-cluster add-tags htools:iextags:role
sudo gnt-instance add ... --tags role:ganeti-test ganeti-test0
sudo gnt-instance add ... --tags role:ganeti-test ganeti-test1
sudo gnt-instance add ... --tags role:ganeti-test ganeti-test2
sudo gnt-instance add ... --tags role:ganeti-test ganeti-test3
sudo gnt-instance add ... --tags role:ganeti-test ganeti-test4

Results?

$ sudo gnt-instance list | grep ganeti-test
ganeti-test0 kvm snf-image+default ganeti06-29 running 1.0G
ganeti-test1 kvm snf-image+default ganeti06-09 running 1.0G
ganeti-test2 kvm snf-image+default ganeti06-32 running 1.0G
ganeti-test3 kvm snf-image+default ganeti06-24 running 1.0G
ganeti-test4 kvm snf-image+default ganeti06-23 running 1.0G

Yay! The instances are allocated to five distinct nodes!

But am I sure I understand what I am doing? Nuke the instances and try another example: 2x “www” instances and 3x “app” instances:

sudo gnt-instance add ... --tags role:prod-www ganeti-test0
sudo gnt-instance add ... --tags role:prod-www ganeti-test1
sudo gnt-instance add ... --tags role:prod-app ganeti-test2
sudo gnt-instance add ... --tags role:prod-app ganeti-test3
sudo gnt-instance add ... --tags role:prod-app ganeti-test4

What do we get?
$ sudo gnt-instance list | grep ganeti-test
ganeti-test0 kvm snf-image+default ganeti06-29 running 1.0G # prod-www
ganeti-test1 kvm snf-image+default ganeti06-09 running 1.0G # prod-www
ganeti-test2 kvm snf-image+default ganeti06-29 running 1.0G # prod-app
ganeti-test3 kvm snf-image+default ganeti06-32 running 1.0G # prod-app
ganeti-test4 kvm snf-image+default ganeti06-24 running 1.0G # prod-app

Yes! The first two instances are allocated to different nodes, then when the tag changes to prod-app, ganeti goes back to ganeti06-29 to allocate an instance.

Feedback Welcome

January 27, 2017
Linux, Technical, Technology

Duct Tape Ops

Link: https://dannyman.toldme.com/2017/01/27/duct-tape-ops/

Threading specification, via Wikipedia

Yesterday we tried out Slack’s new thread feature, and were left scratching our heads over the utility of that. Someone mused that Slack might be running out of features to implement, and I recalled Zawinski’s Law:

Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.

I think this is a tad ironic for Slack, given that some people believe that Slack makes email obsolete and useless. Anyway, I had ended up on Jamie Zawiski’s (jwz) Wikipedia entry and there was this comment about jwz’s law:

Eric Raymond comments that while this law goes against the minimalist philosophy of Unix (a set of “small, sharp tools”), it actually addresses the real need of end users to keep together tools for interrelated tasks, even though for a coder implementation of these tools are clearly independent jobs.

This led to The Duct Tape Programmer, which I’ll excerpt:

Sometimes you’re busy banging out the code, and someone starts rattling on about how if you use multi-threaded COM apartments, your app will be 34% sparklier, and it’s not even that hard, because he’s written a bunch of templates, and all you have to do is multiply-inherit from 17 of his templates, each taking an average of 4 arguments … your eyes are swimming.

And the duct-tape programmer is not afraid to say, “multiple inheritance sucks. Stop it. Just stop.”

You see, everybody else is too afraid of looking stupid … they sheepishly go along with whatever faddish programming craziness has come down from the architecture astronauts who speak at conferences and write books and articles and are so much smarter than us that they don’t realize that the stuff that they’re promoting is too hard for us.

“At the end of the day, ship the fucking thing! It’s great to rewrite your code and make it cleaner and by the third time it’ll actually be pretty. But that’s not the point—you’re not here to write code; you’re here to ship products.”

jwz wrote a response in his blog:

To the extent that he puts me up on a pedestal for merely being practical, that’s a pretty sad indictment of the state of the industry.

In a lot of the commentary surrounding his article elsewhere, I saw all the usual chestnuts being trotted out by people misunderstanding the context of our discussions: A) the incredible time pressure we were under and B) that it was 1994. People always want to get in fights over the specifics like “what’s wrong with templates?” without realizing the historical context. Guess what, you young punks, templates didn’t work in 1994.

As an older tech worker, I have found that I am more “fad resistant” than I was in my younger days. There’s older technology that may not be pretty but I know it works, and there’s new technology that may be shiny, but immature, and will take a lot of effort to get working. As time passes, shiny technology matures and becomes more practical to use.

(I am looking forward to trying “Kubernetes in a Can”)

Feedback Welcome

January 16, 2017
Technical

A Complex Cron Entry Explained

Link: https://dannyman.toldme.com/2017/01/16/crontab-backtick-returncode-conditional-command/

A crontab entry I felt worth explanation, as it illustrates a few Unix concepts:

$ crontab -l
# m h dom mon dow command
*/5 8-18 * * mon-fri grep -q open /proc/acpi/button/lid/LID0/state && mkdir -p /home/djh/Dropbox/webcam/`date +%Y%m%d` && fswebcam -q -d /dev/video0 -r 1920x1080 /home/djh/Dropbox/webcam/%Y%m%d/%H%M.jpg ; file /home/djh/Dropbox/webcam/`date +%Y%m%d/%H%M`.jpg | grep -q 1920x1080 || fswebcam -q -d /dev/video1 -r 1920x1080 /home/djh/Dropbox/webcam/%Y%m%d/%H%M.jpg

That is a huge gob of text. Let me un-pack that into parts:

*/5 8-18 * * mon-fri

Run weekdays, 8AM to 6PM, every five minutes.

grep -q open /proc/acpi/button/lid/LID0/state &&
mkdir -p /home/djh/Dropbox/webcam/`date +%Y%m%d` &&
fswebcam -q -d /dev/video0 -r 1920x1080 /home/djh/Dropbox/webcam/%Y%m%d/%H%M.jpg

Check if the lid on the computer is open by looking for the word “open” in /proc/acpi/button/lid/LID0/state AND
(… if the lid is open) make a directory with today’s date AND
(… if the directory was made) take a timestamped snapshot from the web cam and put it in that folder.

Breaking it down a bit more:

grep -q means grep “quietly” … we don’t need to print that the lid is open, we care about the return code. Here is an illustration:

$ while true; do grep open /proc/acpi/button/lid/LID0/state ; echo $? ; sleep 1; done
state: open
0
state: open
0
# Lid gets shut
1
1
# Lid gets opened
state: open
0
state: open
0

The $? is the “return code” from the grep command. In shell, zero means true and non-zero means false, that allows us to conveniently construct conditional commands. Like so:

$ while true; do grep -q open /proc/acpi/button/lid/LID0/state && echo "open lid: take a picture" || echo "shut lid: take no picture" ; sleep 1; done
open lid: take a picture
open lid: take a picture
shut lid: take no picture
shut lid: take no picture
open lid: take a picture
open lid: take a picture

There is some juju in making the directory:

mkdir -p /home/djh/Dropbox/webcam/`date +%Y%m%d`

First is the -p flag. That would make every part of the path, if needed (Dropbox .. webcam ..) but it also makes mkdir chill if the directory already exist:

$ mkdir /tmp ; echo $?
mkdir: cannot create directory ‘/tmp’: File exists
1
$ mkdir -p /tmp ; echo $?
0

Then there is the backtick substitition. The date command can format output (read man date and man strftime …) You can use the backtick substitution to stuff the output of one command into the input of another command.

$ date +%A
Monday
$ echo "Today is `date +%A`"
Today is Monday

Once again, from the top:

grep -q open /proc/acpi/button/lid/LID0/state &&
mkdir -p /home/djh/Dropbox/webcam/`date +%Y%m%d` &&
fswebcam -q -d /dev/video0 -r 1920x1080 /home/djh/Dropbox/webcam/%Y%m%d/%H%M.jpg ;
file /home/djh/Dropbox/webcam/`date +%Y%m%d/%H%M`.jpg | grep -q 1920x1080 ||
fswebcam -q -d /dev/video1 -r 1920x1080 /home/djh/Dropbox/webcam/%Y%m%d/%H%M.jpg

Here is where it gets involved. There are two cameras on this mobile workstation. One is the internal camera, which can do 720 pixels, and there is an external camera, which can do 1080. I want to use the external camera, but there is no consistency for the device name. (The external device is video0 if it is present at boot, else it is video1.)

Originally, I wanted to do like so:

fswebcam -q -d /dev/video0 -r 1920x1080 || fswebcam -q -d /dev/video1 -r 1920x1080

Unfortunately, fswebcam is a real trooper: if it can not take a picture at 1920×1080, it will take what picture it can and output that. This is why the whole cron entry reads as:

Check if the lid on the computer is open AND
(… if the lid is open) make a directory with today’s date AND
(… if the directory was made) take a timestamped snapshot from web cam 0
Check if the timestamped snapshot is 1920×1080 ELSE
(… if the snapshot is not 1920×1080) take a timestamped snapshot from web cam 1

Sample output from webcam. Happy MLK Day.

Why am I taking these snapshots? I do not really know what I might do with them until I have them. Modern algorithms could analyze “time spent at workstation” and give feedback on posture, maybe identify “mood” and correlate that over time … we’ll see.

OR not.

Feedback Welcome

December 29, 2016
Technical, Technology

It Wasn’t That Bad

Link: https://dannyman.toldme.com/2016/12/29/it-wasnt-that-bad/

Friend: Dang it Apple my iPhone upgrade bricked the phone and I had to reinstall from scratch. This is a _really_ bad user experience.

Me: If you can re-install the software, the phone isn’t actually “bricked” …

Friend: I had to do a factory restore through iTunes.

Me: That’s not bricked that’s just extremely awful software.

(Someone else mentions Windows.)

Me: Never had this problem with an Android device. ;)

Friend: With Android phones you are constantly waiting on the carriers or handset makers for updates.

Me: That is why I buy my phones from Google.

Friend: Pixel looks enticing, I still like iPhone better. I am a firm believer that people stick with what they know, and you are unlikely to sway them if it works for them.

Me: Yeah just because you have to reinstall your whole phone from scratch doesn’t make it a bad experience.

Feedback Welcome

December 1, 2016
News and Reaction, Politics

US May Soon Allow High Speed Trains

Link: https://dannyman.toldme.com/2016/12/01/us-may-soon-allow-high-speed-trains/

Good news via Streetsblog: the United States FRA are nearly done revising safety regulations which would allow for operation of high-speed trains in the United States!

A fleet of TGV waiting to serve passengers in Marseille in 2002. These French trains have a top speed of 200 MPH.

A fleet of TGV waiting to serve passengers in Marseilles, France in 2002. These trains have a top speed of 200 MPH. Proposed US safety rules would permit lighter, faster trains that meet European safety standards to run at speeds of up to 220 MPH.

Current US regulations, from the 1800s and the 1930s, mandate heavier trains to survive crashes. Unfortunately, heavy trains cost more to build, operate, and maintain. Heavier trains are also harder to stop in an emergency.

European train safety regulations are comparable to modern cars: lighter trains are cheaper to build and operate, and they stop faster. They feature “crumple zones” to absorb damage in an accident.

Since the United States is a small market for passenger trains, divergent safety standards make it even more expensive to buy trains. Instead of purchasing inexpensive, reliable, “off-the-shelf” European-designed train sets, vendors need to make alternate, heavier, slower, more expensive designs for American railroads. The adoption of European safety standards will make it cheaper and easier for American railroads to provide modern, comfortable, faster passenger service.

In anticipation of these new rules, Amtrak in September announced the purchase of 28 Avelia Liberty trains from the French company Alstom. The trains will be manufactured in upstate New York and will be used for Acela service starting is 2021. These trains can be upgraded to run at 220 MPH, but this will only be allowed after right-of-way upgrades on the Northeast Corridor.

These rules coming at the end of the Obama administration, with promises of infrastructure spending under the Trump administration, could help American rail transport see more rapid improvements in short order.

Feedback Welcome

November 24, 2016
News and Reaction, Technology

Tool for Generating Isochrones: Mapzen Mobility Explorer

Link: https://dannyman.toldme.com/2016/11/24/tool-for-generating-isochrones-mapzen-mobility-explorer/

Via Steve Vance, Mapzen has a new tool, Mobility Explorer, which can generate isochrones for walking, biking, driving, and transit. I have previously used tools provided by Walk Score, but Mapzen seems more accurate, and the transit shed can be calculated based on a time-of-day.

Here is how far you can get on public transit from Sunnyvale at noon on a Wednesday in 15, 30, 45 and 60 minutes.

Here is how far you can get on public transit from Sunnyvale at noon on a Wednesday in 15, 30, 45 and 60 minutes.

The colors on the web site color scheme are not that great. On Steve’s blog you can see he’s generated his own map via an API call.

Feedback Welcome

November 20, 2016
About Me, Sunnyvale, Testimonials

Valley of Broad Shoulders

Link: https://dannyman.toldme.com/2016/11/20/valley-of-broad-shoulders/

I was in Chicago this week. There was a death in the family, so it was good to be among my kinfolk with our adorable, loving child.

Chicago is famously corrupt and moribund and the State of Illinois is mired in perpetual scandal. It is a magnet for immigrants but it is also a city from which many of us Californians are originally from. I’ve gotten used to the California way and I generally prefer it but what I noticed this week in Chicago was all the construction.

For a city that is corrupt and moribund, there was an awful lot of demolition and rebuilding going on. On the way to the L in the evening we stopped and stared over a fence as a variety of heavy machines worked under brilliant stadium lights. The star of the show was a yellow machine with a huge claw on the end of a boom arm reaching several stories up, to the top of a building, it was tearing down from the top, girder by girder, as another machine sprayed down the dust with a water hose. The claw was at the very end of its reach, it felt the machine was on tippy toes, as it tugged away, girder after girder, waiting for torrents of debris to fall, pulling the pieces out and dropping them into piles to be dragged into more discrete piles by lesser enormous machines. It was like watching dinosaurs go about their business. Father, Son, and Grandmother: none of us could take our eyes off the marvel. “They should sell beer and peanuts,” said I.

The neighbors of this derelict house in Sunnyvale are terrified at the prospect of it being replaced with housing for families.

The neighbors of this derelict house in Sunnyvale are terrified at the prospect of it being replaced with housing for families.

We don’t get this in Suburban California. What little “history” we have is viciously guarded and any attempt to replace the old with newer and better is often met with resistance and exaggerated speculation as to the intentions and end results of new development. You don’t see that so much in the old country–In Chicago, and in any place with some history under its belt, everyone knows that they are surrounded by at least a century of continuity–Everyone is merely links in a great chain. The city is inherited and bequeathed and the hope is to leave it in a little better shape: Urbs in Horto.

In Dublin, I saw them building a light rail line, right down an ancient street. It made the Northern Californian in me jealous.

In Dublin, I saw them building a light rail line, right down an ancient street. It made the Northern Californian in me jealous.

They say that University Politics is the most vicious because the stakes are so low. I get a sense of that observing some of the political rhetoric in Sunnyvale. Out here the city is so new and raw that the idea of changing it implies that those who built the city and have lived in it until now are being completely rejected by the hordes of newcomers flooding the city from the Midwest and the Far East. But in the ancient lands where the immigrants come from, there is no such sentiment: the cities are naturally timeworn, and the idea of redevelopment is an intuitive component of the cycle of death and rebirth.

Fierce as a dog with tongue lapping for action, cunning as a savage pitted against the wilderness,
Bareheaded,
Shoveling,
Wrecking,
Planning,
Building, breaking, rebuilding,
Under the smoke, dust all over his mouth, laughing with white teeth,
Under the terrible burden of destiny laughing as a young man laughs,
Laughing even as an ignorant fighter laughs who has never lost a battle

The land in which I live would be enriched if it embraced a bit of the poetry of the land in which I was born.

Feedback Welcome

November 13, 2016
About Me, Letters to The Man, News and Reaction, Politics

America 1956

Link: https://dannyman.toldme.com/2016/11/13/america-1956/

https://youtu.be/cJq2DUyzSdg

Feedback Welcome

November 13, 2016
About Me, Letters to The Man, News and Reaction, Politics

America 2016

Link: https://dannyman.toldme.com/2016/11/13/america/

https://youtu.be/BG-_ZDrypec

Feedback Welcome

November 9, 2016
About Me, News and Reaction, Politics

Head Full of Doubts

Link: https://dannyman.toldme.com/2016/11/09/head-full-of-doubts/

There’s a darkness upon me that’s flooded in light
In the fine print they tell me what’s wrong and what’s right
And it comes in black and it comes in white
And I’m frightened by those that don’t see it

When nothing is owed or deserved or expected
And your life doesn’t change by the man that’s elected
If you’re loved by someone, you’re never rejected
Decide what to be and go be it

–Avett Brothers

Feedback Welcome

November 8, 2016
News and Reaction, Sunnyvale

Planning Mistake: Dividing Lawrence Station Neighborhood with an Onramp

Link: https://dannyman.toldme.com/2016/11/08/planning-mistake-dividing-lawrence-station-neighborhood-with-an-onramp/

I am proud to have grown up in Chicago. It is a great city. But us Chicago fans have to admit to its numerous mistakes and sins. One of those sins was repeated over and over again in the mid-twentieth century, when neighborhood after neighborhood was torn apart to make way for highways. Working class neighborhoods, homes to people of color and immigrants … the fabric of community life was torn away. Neighborhoods were divided and conquered and made into ghettos.

One would hope for Silicon Valley in the twenty-first century not to repeat the mistakes of twentieth-century Chicago.

On Wednesday, the Santa Clara Planning Commission will review the Environmental Impact Report for the Lawrence Station Area Plan. The Lawrence Station Area Plan is an ambitious project to redevelop a low-rise industrial area into a modern urban neighborhood, providing 3,500 housing units, office space, and parks, directly adjacent to commuter rail services.

The Lawrence Station Area as it exists today: mainly ugly, low-rise Industrial.

The Lawrence Station Area as it exists today: mainly low-rise industrial.

Plans for 3,500 residential units, 104,000 square feet of office, and six acres of parks.

Plans for 3,500 residential units, 104,000 square feet of office, and six acres of parks.

Among the current recommendations is to cut off the Northwest block of housing from the rest of the neighborhood because it serves as a connector ramp between Lawrence and Central Expressways. Instead of crosswalks for people to walk across their community, pedestrians will need to walk up and over a ramp so as not to slow down the cars … on a two-lane road.

It is hard to find pictures of pedestrian bridges spanning two-lane roads, but picture something like this, but everyone gets to walk up and down long long long wheelchair ramps to cross the street.

It is hard to find pictures of pedestrian bridges spanning two-lane roads. Picture something like this, with elevators on each side.

This is another case where we err on the side of inconveniencing people and dividing neighborhoods for the sake of keeping cars moving along as fast as possible. A crosswalk would allow people to cross the street in their new neighborhood and be better connected to their neighbors, at the cost of possibly adding an occasional minute or two to someone’s commute. Does that sound so unreasonable?

Perhaps instead of right-left-right through a neighborhood, we could drive a gentle arc around the neighborhood?

Perhaps instead of right-left-right through a neighborhood, we could drive a gentle arc around the neighborhood. The path is still there.

We might explore some alternatives. One thing I notice is that the right-of-way still exists to restore the old on-ramp from Lawrence Northbound to Central Eastbound. Instead of making a right-left-right through a residential neighborhood, drivers just coast on up a gentle right-hand curve and merge on to Central. From there, the existing two-way on-ramp might be adapted to a two-lane one-way street. The two-lane street allows more cars to queue at a crosswalk while pedestrians cross, reducing potential congestion.

Alternatively, traffic off of Central Eastbound could simply take alternate routes from Oakmead/Corwin.

The Santa Clara Planning Commission is in a place to recommend smarter planning that better addresses the concerns of pedestrians, neighborhood vitality, and motorists. The Commission will review the Specific Plan this Wednesday at 7:00pm. I hope to drop by and share my concerns. You should show up too, if you are interested. You can also write a letter to the Planning Commission: PlanningCommission@santaclaraca.gov and CC planner John Davidson: JDavidson@santaclaraca.gov.

Many thanks to Green Caltrain for the tip.

Feedback Welcome

November 6, 2016
Politics

Evaluating California Ballot Propositions

Link: https://dannyman.toldme.com/2016/11/06/evaluating-california-ballot-propositions/

A few rules of thumb I use in evaluating California ballot propositions:

1) Is it a REVENUE BOND? — Likely YES
2) Is it a CONSTITUTIONAL AMENDMENT? — Default NO
3) Endorsed by Jerry Brown? — Likely YES
4) Argument in favor/opposition use LOTS OF CAPITALIZED WORDS AND PHRASES — Those arguments are nutters
5) Wait, why shouldn’t the legislature, &c. be figuring this out?! — Likely NO

This time around I figure condoms, ammunition, and plastic bags are issues Cal/OSHA and the legislature need to figure out.

Feedback Welcome

« Newer Stuff . . . Older Stuff »
Site Archive