How Do You Unlock a GitHub Repository when You Only Know Its Name?

Problem scenario
You want to unlock a GitHub repository. You know the name of the repo. (When you browse to it in a web browser, you see that it is locked, and you cannot see the files inside as normal.) How do you unlock it?

Solution
You need to find the migration GUID for the locked repository. Then you need to run a command on it. For general information about GitHub Enterprise migrations and using Dockerfile, see this external page.

1.a. Run a command like this (but substitute /var/log/github/ghe-migrator.log with the path to the file that is the GHE migrator log):

cat /var/log/github/ghe-migrator.log | grep -i nameofrepo

In the results of the above or in the log file itself, mentally identify the GUID for the repository.
For more information about this file, see https://ppouliot.github.io/dockerfile-ghe-helper/#gheghe-migratorlog

1.b. If nothing shows up in that command, it may be that the migration used a list of URLs. (We think that consuming a list of URLs has different logging from running ghe-* commands individually.) In this case, you will have to exhaustively search:

Run "ghe-migrator list" to show all the GUIDs. (Taken from https://enterprise.github.com/releases/2.15.4/notes.)

Run this (but substitute abcd1234 with a GUID found in the results above):

cat /var/log/github/ghe-migrator.log | grep abcd1234

Continue until you see results with the name of the repository that you are looking for.

  1. Finally run a command like this (where abcd1234 is the migration GUID found above):
ghe-migrator unlock -g abcd1234 -u jdoe -p goodpassword

# Above command was adapted from 4:08 of this video: https://www.youtube.com/watch?v=Vsyncm9cJuA
# Which is close to https://docs.github.com/en/enterprise-server@2.20/admin/user-management/migrating-data-to-your-enterprise

How Do You List the Kafka Topics when You Cannot Find the kafka-topics.sh File?

Problem scenario
You cannot find kafka-topics.sh. But you want to list the Kafka topics. What should you do?

Solution
Find the kafka-topics binary file. Use something like this (but replace "localhost" with the server name of Zookeeper and "2181" with the TCP port number):

kafka-topics --list --zookeeper localhost:2181

(This was adapted from https://stackoverflow.com/questions/44405663/list-all-kafka-topics.)


What AWS CLI Command Can You Run to List Roles with EKS Access?

Problem scenario
You want to list IAM roles that have access to EKS. You have the AWS CLI installed and jq installed. What should you do?

Solution
Run this command:

aws iam list-roles | jq -r '.Roles[] | select(.AssumeRolePolicyDocument.Statement[].Principal.Service=="eks.amazonaws.com")'

How Do You Iterate Through Two Lists of Unequal Length in Python?

Problem scenario
You want to iterate through two lists and perform some operation. The lists are not equal length. You want to iterate through them in some type of step-by-step fashion despite their lack of equality. What should you do?

Solution
Use this as an example:

list_a = [1, 2, 3]
list_b = ["dog", "cat", "rat", "chicken"]

i = 0
j = 0

while (i < len(list_a)) or (j < len(list_b)):
    if (i < len(list_a)):
        print(list_a[i])
        i += 1
    if (j < len(list_b)):
        print(list_b[j])
        j += 1

How Do You Write Python Code to Test if a Dictionary Exists?

Problem scenario
You want to test if a dictionary exists or not. You know its name if/when it exists. What do you do?

Solution

# Suggested usage: 1) run it is as it is.  
# 2) uncomment out the dictionary_name1 definition stanza. 
# Then run this program again.

#dictionary_name1 = "good_dict"

if 'dictionary_name1' in locals():
  print("IT IS IN LOCALS")
else:
  print("IT IS NOT IN LOCALS")

if 'dictionary_name1' in globals():
  print("IT IS IN GLOBALS")
else:
  print("IT IS NOT IN GLOBALS")

How Do You Install Troubleshoot the Kubernetes Error “dial tcp x.x.x.x:10248 connection refused”?

Problem scenario
You are trying to run "kubeadm init", but you get this error:

"failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused."

What should you do?

Solution
Is the kubelet service running? Run this: sudo systemctl status kubelet

To install the kubelet, see this posting for How Do You Install the kubelet on any type of Linux?

You may want to see this posting too. You may want to check if there is a firewall issue with this posting.

How Do You Troubleshoot the Kubernetes Error “[ERROR Port-10250]: Port 10250 is in use”?

Problem scenario
You are trying to run a kubeadm command. But you get this error:

[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Port-10250]: Port 10250 is in use
[preflight] If you know what you are doing, you can make a check non-fatal with --ignore-preflight-errors=...

What should you do?

Solution
Remove the kubelet that snap installed; this assumes that you have two installations of kubelet. Here is the command:

sudo snap remove kubelet