How Do You Troubleshoot “groovy.lang.MissingPropertyException: No such property” when running a Groovy Program?

Problem scenario
You are running a Groovy program.  

Here is your code:

def input = System.console().readLine ‘Please provide some input: ‘
def x = input
def boardArray = new String[2]
boardArray[0] = “”
boardArray[1] = “”
boardArray[1] = $x //this is the incorrect version
println boardArray[1]

When you run it (i.e., with groovy foobar.groovy), you get this error:

Caught: groovy.lang.MissingPropertyException: No such property: $x for class:
groovy.lang.MissingPropertyException: No such property

What should you do?

How Do You Troubleshoot the Amazon EKS Web Console Error “AccessDeniedException not authorized to perform: iam:PassRole on resource”?

Problem scenario
You are logged into the AWS web console.  You try to perform an operation but you get this error:

“AccessDeniedException
User: arn:aws:iam::12345678910:user/jdoe is not authorized to perform: iam:PassRole on resource: arn:aws:iam::12345678910:role/rolename”

What should you do?

Solution
1.  Create a role with “EKS” (to create Kubernetes clusters).  If you don’t know how, see this posting.
2.  Follow steps 1,

How Do You Troubleshoot the “kubectl” Error ‘the server doesn’t have a resource type “svc”‘?

Problem scenario
You are trying to use Kubernetes in AWS.  You have installed kubectl and you run this command:

kubectl get svc

You receive this:  ‘error: the server doesn’t have a resource type “svc”‘

You try again with a more verbose output.  You run this command:

kubectl get svc -v=8

In the output you see messages like this: “Response Status: 401 Unauthorized in 73 milliseconds”

What should you do to use kubectl with AWS?

How Do You Determine the URL for the AWS Web Console for a Non-root User?

Problem scenario
You created an AWS Console user (e.g., an IAM user).  You want to log into the web UI with the user.  You have the username and password.  What is the URL for the AWS web console for a non-root user?

Solution
1.  Log into the web UI.
2.  Go here: https://console.aws.amazon.com/iam/home?
3.  Go to Users on the left.  
4. 

Is Jenkins job-dsl Different from Jenkinsfile Pipelines’ Scripted Syntax?

Question
You have heard of Jenkins job-dsl.  You are not sure if it is the same DSL found in scripted syntax Jenkinsfile pipelines.  Is Jenkins job-dsl different from Jenkinsfile pipelines’ scripted syntax?

Answer
Yes.  Jenkins job-dsl is different from the DSL used in Jenkinsfile pipelines’ scripted syntax.  This thread confirms this fact.  This link helps explain the differences.

How Do Quotes Affect Python if Conditional Tests of Equality for a Variable?

Problem scenario
You are programming in Python, and you want to use conditional logic.  You want to know how variables are evaluated and tested.  You want to use the keyword “if” to evaluate a variable assignment.

Solution
This program below shows how the evaluation of a variable in Python behaves when quotes are involved. Errors are not thrown or displayed to the programmer.  Therefore in some instances the programmer must know how quotes affect logical evaluations with variables.

How Do You Iterate through Data Members (the Individual Components) of a Groovy Object?

Problem scenario
You have an object that you want to sequentially pass through.  That is, you want to print either the value or the key/name and value pair of every member data item of the object.  How do you print every individual data member of a given object in Groovy?

Solution
Invoke the “.properties.each” keyword.  This built-in feature will allow you to do just this.  There is one “if” condition you will use to avoid printing the “class=class …” feature.

How Do You SSH to a GCP server?

Problem scenario
You cannot SSH into a Linux Google Cloud Platform server.  How do you create new GCP servers that you can SSH into?

Solution
Summary
Use the “Startup script” in Google Cloud Platform.  This script comes with precautions.  Be careful when pasting it.  The lines can potentially not wrap properly.  Carriage returns could be introduced to make this script fail.  Be very careful because this script creates a user with sudoer privileges. 

How Do You Troubleshoot “Redirecting to /bin/systemctl start docker.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units”?

Problem Scenario
You try to configure Docker such that you can run “docker” commands without sudo.  You run these three commands:

sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker

You then installed Docker and rebooted the server.  You then run this:

docker run hello-world

But you received this:

/usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.