Friday, April 12, 2019

Tech Notes:-How to copy files from Windows Subsystem For Linux to Windows

If you work on Windows Subsystem for Linux  either Ubuntu or OpenSuse, I am sure you have faced with situations where you had to copy files from Ubuntu or OpenSuse to Windows.

If you are not aware how to do it. Here are the easy steps

  • Right-click the start and then run , paste the below path and press enter     
    •     %userprofile%\AppData\Local\Packages
  • Now in the windows explorere search packages option type ubuntu. This should show the Ubuntu folder with the name something like 
    • CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
  • Open this folder and browse to LocalState --> rootfs
  • Now this is the root file system of your Ubuntu.Mostly your files will be saved under /home/UserName/
  • Now you should be able to copy the files using windows explorer itself

Sunday, April 7, 2019

Tech Notes:- How To Bootsrap a Percona Xtradb Cluster After All The Nodes Are Down

Often there is confusion regarding which node to start first after we shut down all the nodes or a Percona XtraCB Cluster. So here is how we can decide that

Safe_to_bootstrap Flag

Our decision should be based on the value of this flag, if we are sure that the cluster was shut down properly. If we are talking about a 3 nodes cluster, you have to check the value of this flag in the file /var/lib/mysql/grastate.dat in each of the nodes.

The node with the value 1 should be the one we use for bootstrap. Others will have a value of 0. So here in my case, Node1 with the value of 1 for safe_to_bootstrap should be the one which we bootstrap.


But what happens if you try to  bootstrap from the nodes 2 and 3 which had a value of 0 for safe_to_bootstrap. The cluster will refuse to start those nodes. You can see the below message in the logs /var/log/mysqld.log

It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates.

What if the nodes were not shut down properly.?


In case of a hard crash or an abrupt shutdown, all nodes will have a value of 0 for the safe_to_bootstrap. In this case, we have to check the DB engine to determine which node has committed the last transaction. For this, we have to start mysqld in each node with the wsrep-recover variable  

sudo mysqld_safe --wsrep-recover

The above command will have something like below in the output

 mysqld_safe WSREP: Recovered position  f23bb233-5840-11e9-919a-9eac3900b870:14 

The number after the UUID string is the one to look for. Select  the node that has the highest number and update its /var/lib/mysql/grastate.dat to set  safe_to_bootstrap: 1

sudo less /var/lib/mysql/grastate.dat
# GALERA saved state
version: 2.1
uuid:    f23bb233-5840-11e9-919a-9eac3900b870
seqno:   -1
safe_to_bootstrap: 1

Now it is safe to bootstrap this node.

Note:-The above procedure is not needed for most recent versions of Percona XtraDB cluster as there is a new option pc.recovery which is enabled by default and will recover the cluster promoting the node with the last commit as the primary node after all the members again start to see each other.

Sunday, March 24, 2019

Tech Notes:-Using Cryptomator to encrypt you personal data in cloud





One confusion most of us always had from the early years of cloud adoption is whether to upload confidential data to the cloud or not and how safe is the data.

Now, we have a free solution which we can use to encrypt the data uploaded to the cloud. This is using a tool called Cryptomator.

 https://cryptomator.org/ 

Cryptomator is a free, opensource client-side tool for encrypting your cloud files.T he tool is available for Linux, Windows, Mac, Android and Apple.

Cryptomator encrypts the data with either a key or a password as per your choice before its uploaded from your device.This means that the data stored in the cloud will be in encrypted form. All that someone who gets access to your cloud account sees is like below which  doesn't make any sense






It will make sense only once we decrypt it with the same password or key after we download it back to our device. 

Now we will see how we can setup cryptomator to encrypt files and then sync it to google drive.



Setting up Google drive 


First, we have to download and install Google Backup and Sync from below URL

https://www.google.com/drive/download/backup-and-sync/

  1. On launching Google  Backup and Sync, you will be asked to sign in with your Google credentials.
  2. If you have enabled 2-step verification, you will be asked to complete the formalities for 2-step verification.
  3. ClickAllow for trust verification message
Once you sign-in, follow below youtube video to add the folder that you want to sync. I have chosen the folder E:\Google Drive to sync. We will be creating a folder named MyDocs under the Google Drive folder and this folder will contain our data which will be encrypted using cryptomator.

https://www.youtube.com/watch?v=Y4kJ9-j_FUY


Setting up Cryptomator

  1. Download and install cryptomator form below link
    1. https://cryptomator.org/downloads/#winDownload
  2. Launch cryptomator and click on the + and then select create a new vault
  3. Browse to your Google drive path. In my case, it is E:\Google Drive
  4. Name the vault and supply a password and then click on Create Vault
  5. That's it, you have created the vault
  6. Now click on the drop-down near Lock Vault and then select Reveal Drive
  7. This will open the drive in Windows Explorer.
  8. By default, the drive will be mounted in Windows Explorer as Z drive
  9. Now whatever files you copy to this drive will be encrypted and since this folder is already part of Google Drive folder, this will be synced to Google drive.
  10. But to access the contents, you need to have theCryptomator software as well as the password that you set for the vault.
  11. Once your work is done, you can close this drive by selecting the drop-down near to the Lock Vault and then selecting eject drive
You can access your encrypted files from even your Android phone or iPhone As of this writing, the Cryptomator client for Android is not free.

Tech Notes:-Extracting specific tables from MySQL dump

I encountered a situation where I had to extract only a specific table from a huge  MySQL dump. Here is how you could accomplish this.

Lets say the name of the table is mytable and the file containing the huge mysql dump is mysql.dump. Here is the command to extract mytable


This will copy into the file mytable.dump what is located between CREATE TABLE mytable and the next CREATE TABLE corresponding to the next table.

If required you can then adjust the file mytable.dump which contains the structure of the table mytable, and the data.

Tech Notes:- Yum reinstall command

The Problem

Often we encounter scenarios where we have to re-install packages in yum. Here I am explaining one such scenario.

Last week I installed an application using yum and then removed the rpm packages one by one. And then deleted the application folder. Later I decided to install it back and I used yum to install it. But after I installed the application I noticed that the application was not launching. On investigation, I could find that the yum install did not install certain dependancy packages which had some libraries required for the application to start.

Analysis

So what happened here?. Although I removed most of the packages using rpm, I missed to remove certain dependency packages and then later when the folder was deleted, the files associated with the dependency packages got deleted. But as per yum database, the dependency package is still installed and when we installed it using yum the second time, these packages were skipped.

Solution

How to deal with this?. First of all we have to find out which package provides the missing files.

rpm -qf filename

Now we can ascertain that the file is part of the dependency package for the packages we installed using yum.

Fortunately, yum has an option called reinstall which will completely re-install the packages including the dependancy packages. The syntax is simple

yum reinstall PACKAGE_NAME




Saturday, March 23, 2019

Paella from Preston market Melbourne


I was on a normal routine visit to Preston market in Melbourne and I noticed something special and that was seafood Paella. The deliciousness spreading through the air was so tempting that I decided to join the huge queue for a taste.
Now, like me, for those who don't know what is Paella. Paella is known to have originated in the Spanish city of Valencia and then spread across Spain and now spreading all over the world including Melbourne :).

We have different types of Paella now, veg, seafood and mixed. The one I had from Preston market is the seafood Paella and these are some of the ingredients I could figure out, a special kind of rice called Calasparra or Bomba rice, medium grain rice grown in Spain, crushed saffron, shrimp, calamari, mussels, chicken pieces etc.


Tech Notes:- Nginx reverse proxy issues in AWS due to name resolution failure

The Problem

There are certain failure scenarios in AWS which is hard to detect. One of them is Nginx reverse proxy failure due to name resolution issues.

AWS has certain services like ELB, RDS with dynamic changes in underlying host IP. The problem here is that some applications resolve the IP only once mostly during the startup, restart or reload of that service. One such application is the Nginx web server. 

Nginx resolves all the names to their IP and caches it during the start, restart or reload. If the DNS resource record changes in between, Nginx fails. This typically happens when Amazon ELB IP address changes. Amazon updates the DNS record, but Nginx never re-resolves the DNS record and stays pointing at the old IP address. Subsequently requests to the backend start failing once Amazon drops services from the old IP address.


Analysis

But how do you find out if the Nginx issues are caused due to name resolution? One of the best options in front of us is Amazon CloudTrail. Normally ELB IP changes when the ELB scales or there is a scale up or down of hosts behind the ELB.

Refer the below Amazon link to read about the ELB behavior
https://aws.amazon.com/articles/best-practices-in-evaluating-elastic-load-balancing/

AWS CloudTrail logs all the API activities associated with your AWS account and this includes the changes related to ELB as well.


Solution

Now how do we resolve this problem? If we are using the community edition of Nginx, the best option is to configure a resolver entry.


But how do you know the IP address of the DNS that you should use in resolver?AWS documentation comes handy here

https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html

The first four IP addresses and the last IP address in each subnet CIDR block are not available for you to use, and cannot be assigned to an instance. For example, in a subnet with CIDR block 10.0.0.0/24, the following five IP addresses are reserved:
  • 10.0.0.0: Network address.
  • 10.0.0.1: Reserved by AWS for the VPC router.
  • 10.0.0.2: Reserved by AWS. The IP address of the DNS server is always the base of the VPC network range plus two; however, we also reserve the base of each subnet range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. For more information, see Amazon DNS Server.
  • 10.0.0.3: Reserved by AWS for future use.
  • 10.0.0.255: Network broadcast address. We do not support broadcast in a VPC, therefore we reserve this address.
Apart from that there is VPC independent up address which can be used as resolver and that is 169.254.169.253. Here the catch is you lose the ability to resolve up outside AWS from nginx point of view.




Saturday, March 9, 2019

Tech Notes:- How to selectively merge files from a git branch to master

People who work with git regularly especially with branches might encounter a situation where they want to merge specific files from one branch to another. Here I am explaining how I accomplished this

My Scenario

I have a master branch and a new branch called "observium". I wanted to merge a few files to the master branch. To demonstrate it I did a checkout of the master branch, created a file called sreedev.txt and then committed it.

[sudeep@dev ansible]$ git checkout master
Switched to branch 'master'

[sudeep@dev ansible]$ git status
# On branch master


[sudeep@dev ansible]$ vim sreedev.txt
I entered the text "This is a file from the main branch" and saved it

[sudeep@dev ansible]$ git commit -m "Added a new file for demonstrating selective file merge"
[master e3a1a33] Added a new file for demonstrating selective file merge
 1 file changed, 1 insertion(+), 2 deletions(-)

[sudeep@dev ansible]$ git push origin master
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@bitbucket.org:sudeepkumarks/ansible.git
   6ffda3a..e3a1a33  master -> master

Now I did a git checkout of my branch observium


[sudeep@dev ansible]$ git checkout observium
Switched to branch 'observium'

Created a file with the same name sreedev and updated a similar content which will conflict with content in the main branch. The intention here is to show how we handle the conflict during the selective merge

[sudeep@dev ansible]$ git add sreedev.txt
[sudeep@dev ansible]$ git commit -m "Added a new file for demonstrating selective file merge"
[observium 04b5fa6] Added a new file for demonstrating selective file merge
 1 file changed, 1 insertion(+), 3 deletions(-)

How to merge the files

Now we will try to merge the files sreedev in observium branch to the main branch 

[sudeep@dev ansible]$ git checkout master
Switched to branch 'master'

[sudeep@dev ansible]$ git checkout --patch observium sreedev.txt
diff --git b/sreedev.txt a/sreedev.txt
index e7d96cb..fe3f28c 100644
--- b/sreedev.txt
+++ a/sreedev.txt
@@ -1,2 +1 @@
-This is a file from the main branch
-
+This is a file from the observium branch
Apply this hunk to index and worktree [y,n,q,a,d,/,e,?]?

Since there is a conflict its asking questions on resolving the conflicts. At this stage, you have the below options

y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

If you press y, the line  "This is a file from the main branch" will be removed and the line "This is a  file from the observium branch" will be added. If you want to keep the first line and remove the second one which is from the observium branch, you can press e and make manual changes and save it like how you save files in vim editor.

Once you complete the changes by saving, it will go to the next hunk if there is any conflict. This will repeat until all the conflict in the file is resolved. Now the git status should show the file as modified and added for commit. 

[sudeep@dev ansible]$ git checkout --patch observium sreedev.txt
diff --git b/sreedev.txt a/sreedev.txt
index e7d96cb..fe3f28c 100644
--- b/sreedev.txt
+++ a/sreedev.txt
@@ -1,2 +1 @@
-This is a file from the main branch
-
+This is a file from the observium branch
Apply this hunk to index and worktree [y,n,q,a,d,/,e,?]? y

[sudeep@dev ansible]$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#       modified:   sreedev.txt
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       master


Now you can commit the changes like normal to have the changes from Observium branch in your master branch. This can be followed for merging specific files from any branch.

Behavioral interview questions related to managing work.How do you handle situations where you did not have enough work to do

Although most of the time we will have more than enough work to do, there are situations in an organization where there is not much work to do. This can be due to a transition phase of the organization or the organization might be in a restriction period for change implementation or for new projects because of the annual high transaction period or budget constraints. In an interview, there can be questions related to this and the intention of asking this question is to understand the attitude of the candidate.

Here we review some sample questions related to this.


Sample questions related to managing your work

  • Have you been in a situation where you did not have enough work to do
  • How do you keep you busy if you don't have much to do at work
  • How do you kill time when there is not much work to do

Situation

  • I was working in a financial services organization which enforces restriction period wherein no project specific changes are deployed during the busy transaction period from November to January
  • Restriction period basically translates to less busy time with respect to work. And there are days where we cannot do anything with the systems which we work on.

Approach

  • Although I didn't have enough work during the restriction period, there were opportunities to improve my knowledge as well as to share it. I was utilizing this opportunity to learn new technology relevant to work as well as sharing my knowledge with others in my team.
  • I also took this as an opportunity to research on improving the existing systems, optimizing the process/systems to get some re-engineering saves.
  • I also took initiatives to do the proof of concept study for some of the new improvements that I found.

Results

  • Although there was not much work, I was able to utilize the work hours effectively to the advantage of the organization in all possible manner.

How effective is the above answer

The candidate was able to demonstrate that he will be committed to the betterment of the organization and he thinks innovatively and comes up with better ideas instead of sitting idle or spending work hours in a non-fruitful manner.

Summary

Spending your work time wisely and effectively is something that every organization expects and questions related to this is common in an interview. It's also good to have a story handy to address these questions.

Behavioral interview questions related to managing conflicts

It is very important for an organization to assess candidates ability to manage conflicts as a part of assessing interpersonal skills during an interview. The expectation here is that the candidate should showcase his competency to get along with different types of people as we cannot expect everybody in the organization to behave nicely to you :). He should also show how he manages those disagreements gracefully.

 Here we will see some sample questions related to conflict management and how to answer them effectively.

Conflict management

  • What do you do when a team member refuses to complete his or her quota of the work?
  • Tell me about a time when you had to disagree with a specific approach or process
  • Tell me about a time you had a conflict at work.
  • Tell me about an incident where you had to handle an unhappy customer/employee/supervisor/colleague
  • Tell me about a situation where you had to work with a colleague who is difficult to deal with.

Situation

  • I was the project manager for a high visibility project with a tight deadline As. the project was a very important one from an organizational perspective, senior leadership including directors were closely monitoring the progress.
  • I was managing a bridge call to complete the User Acceptance Testing(UAT). Multiple teams including leadership and all other stakeholders joined the call except the systems assurance analyst who was supposed to do the UAT.
  • When I approached the systems assurance analyst who was supposed to join the call and complete the UAT,, he blew up at me.

Approach

  • Although I was not getting an expected response from him. I maintained my composure and explained to him once again about the importance/visibility of the project as well as the importance of completing the UAT on time.
  • He apologized for not making it to the call and explained about the competing priorities he has with other projects.
  • We discussed further to find a solution and finally decided to approach his Director to appraise her of the importance of this project over others
  • She decided to assign another Systems Assurance Analyst who is more experienced to handle my project's UAT testing

Results

  • Although we lost almost half an hour of our UAT time, we could complete the UAT well before the deadline because we had a well experienced Systems Assurance Analyst doing our UAT.
  • We were able to complete the project on schedule and the handling of conflicting situations was well appreciated by the leadership in the final project completion notification.

How effective is the above answer

Here the candidate was able to handle the situation without impacting the project schedule with a final positive outcome. He was able to handle the conflict very well without impacting the relationship with Systems Assurance Analyst.

Summary

Conflict resolution is not only relevant to the interview but its also important in our day to day life. It's important to learn the art of conflict management and to resolve conflicts with a positive outcome for all the parties involved.
This is a sure shot question in an interview and preparing the story well in advance and practicing to answer will definitely impact the interview outcome.

All the best with the interview preparation!


Behavioral interview questions related to culture

Although there are a lot of questions and sample answers available for common questions on the internet, I found that there are some specific questions for which answers are not available. Here I will be covering questions related to culture.

Cultural awareness

  • Tell me about a time when you had to take someone's cultural perspective into account when dealing with them.
  • Give me an example of a situation where you had to take into account the sensitivities of different parties.
  • Tell me about a time when you have worked in a team with individuals from different cultural backgrounds.
    Here is the example of an answer which follows the STAR approach.

    Situation

    Here we need to provide a context for the story and this section should be concise and to the point.
    • Recently I had a chance to manage a project which involved the release of specific software to multiple regions across the globe over Citrix infrastructure.
    • One of the tasks involved was setting up and managing weekly bridge calls involving different teams including business, technology and leadership teams from different countries across the globe. 
    • During these calls, I noticed that we were not getting much input from some regions and the leadership was getting the impression that everything was going smoothly.

    Approach

      In the previous section, you described the situation. Now the important part comes which is how you demonstrated the specific competency you have which you want to highlight through the steps that you have taken to resolve it
      • The project was on a tight deadline so everybody was keen on moving things as quickly as possible.
      • However, I was very concerned about the lack of inputs from specific regions where the software will be rolled out.
      • As a project manager, I decided to set up calls with each regional team and get their inputs, just to make sure that they don't have any inputs/concerns.
      • It turned out that several of them had concerns regarding the response time and some specific features related to the customization as per the language.
      • They were hesitant to express their concerns because they did not want to contradict opinions from the leadership team.
      • From there on I started setting up regular bridge calls with specific regional teams, note their concerns/opinions and then summarise and present it in the larger team calls.

      Results

      • I was happy that I was able to capture concerns/opinion of regional teams well before the rollout and that saved us from trouble which could have happened after the roll-out.
      • I found that people from regional teams are more confident, comfortable and gets more time to explain their concerns/opinions in detail when we setup calls with individual teams.  
      • I got appreciations from my leadership team for this approach as we were successful in addressing the concerns from regional teams well before the rollout which otherwise could have remained unknown.
      • This experience helped me understand how important is to have a platform where everyone is comfortable to communicate effectively.

      How effective is the above answer

      Here we are highlighting
      • the project manager's project management as well as general people management skills.
      • he is meticulous, a good learner and  willing to go the extra mile to achieve results
      • above all, he shows that he is very good at dealing with people from different cultural or regional backgrounds.

      Summary

      Nowadays with more and more organizations going global, you can expect questions related to cultural perspective in most of the interviews. Therefore it's very important that you prepare a few stories in advance to avoid surprises.

      All the best with the interview preparation!

      Sunday, March 3, 2019

      Behavioral interview questions









      What are behavioral interview questions?

      Most often we come across these categories of questions in a job interview. Here  I am providing a  summary of what these questions are all about, how to answer them and some sample questions along with sample answers.

      How to identify if the question being asked is a behavioral interview question

      If the question starts with something like below, it's highly likely to be a behavioral question

      "Give me an example of ....."
      "Have you ever..."
      "Describe a time when..."
      "Have you had to.."
      "What do you do if you.."

      Methods  for answering behavioral interview questions

      The STAR technique


      STAR stands for SITUATION  TASK ACTION  and  RESULT

      Situation/Task  -  Explain the event or task that you encountered.

      Action -  Explain what steps you undertook

      Result - Describe the outcome that you delivered

      The CAR  technique








      This method is similar to the STAR method except that here you provide a CONTEXT, ACTION, and RESULT

      Context -  Explain the situation and the background

      Action - Describe what measure of steps you took

      Result- Describe the outcome  you achieved

      Pointers to  answering behavioral interview questions effectively

      Due diligence -  Find out what skills and behaviors the employer is looking for, and find answers for possible questions including well-known questions that you will definitely get in an interview. If possible, prepare answers from your own previous experience. If there are questions beyond your experience, make sure you have a story ready. Remember, the expectation here is to demonstrate how you handled those situations.

      Practice - answering the questions using STAR or CAR method out loud in advance for those questions you identified. Make sure that while telling your story, you stay on point. Better if you have someone to listen to your answers and provide corrections.
      Related Posts Plugin for WordPress, Blogger...