Advertisement

Showing posts with label DevOps. Show all posts
Showing posts with label DevOps. Show all posts

Wednesday, May 6, 2020

DEVOPS - How to find out processes in 'D' state of uninterruptible sleep (High I/O Wait)

IN this blog I am going to write on how to find out processes state and specially when there is high I/O wait on the system. 


The key is to list down the process which are in 'D' or 'S' state (primarily 'D').


Run below command to list processes in 'D' state. Replace '^D' with '^S' to get list of processes in S State.
Once you get the process you can do action on it 

 for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done

Friday, February 14, 2020

DEVOPS : Slack : How to Upload File to Slack using Python

When uploading files to slack using Webhook - it is not possible. You need to use Slack API.
Below is sample code which can be used to put files to slack.

The key thing here is the token. You need to request a new token from Slack which you can do from Below URL - 

https://api.slack.com/legacy/custom-integrations/legacy-tokens

Sample Code - 


import requests
token  = "xxxxxxx"my_file = {
  'file' : ('/tmp/temp_file.out', open('/tmp/temp_file.out', 'rb'), 'txt')
}
payload={
  "filename":"temp_file.out",
  "token":token,
  "channels":['#channel-name'],
}
r = requests.post("https://slack.com/api/files.upload", params=payload, files=my_file)



Monday, November 25, 2019

DevOps: GIT - How to Sync Fork with Master or Pull Upstream

In this blog I am going to discuss about how to Sync your forked branch to the master branch. 
If you have followed my previous blog on Fork Workflow  then this blog is (somewhat) a continuation of that blog. 

Now if you have performed your steps properly then 


Check if you added upstream
$ git remote -v

If you have then good, else refer my previous blog. 

Update with master

$ git pull upstream master

That's it your fork is synced with master fork.

In case you want to break it down into multiple steps, you can use below
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork

Monday, November 18, 2019

DevOps: GIT : Breaking Down the GIT PUSH - Meaning and Details

Well 'git push' is one of the widely used commands by developers, In this blog I am going to break down what it means. 

In very simple terms.


So a normal syntax of command is like this

$ git push origin master
OR
$ git push <remote> <branch_name>

Here 
origin means : The remote repository which is tracked as origin.  You can get these details by running git remote -v.

branch_name: Means the local branch which you want to push to origin. So, if you give master it is your local master branch or if it is not master then the name which you gave. 

Another alternate to this is using HEAD
git push origin HEAD pushes the current branch which you are working on and is checked out by you.

So, that's it. If you have any questions feel free to ask. 


DevOps: GIT : Fork Workflow

In this blog I am going to discuss on the workflow for Fork Request. 
A fork is essential a point in time copy of your master Branch which you create and then you can download the point in time copy and make changes to that copy.

Finally when you are happy (or not happy) you may - sync the downloaded fork with your main branch or upload changes to Fork and raise Pull request for the main branch. 

How to do so ? 

1. Create the Fork of Repository you  want from GitHub
2. Clone the forked repository now to your local
  git clone git@github.com:<username>/<repo_name.git>
3. Add Upstream to the Repo (this is used to sync with the main branch
  git remote add upstream git@github.com/<org_name>/<repo_nameg.git>

4. Checkout Branch
   git checkout -b < name >
5.  git add (or git add individual files)
6.  git commit
7.  git push origin HEAD
8. Create Pull Request
9. Compare and Merge 

That's it..

Monday, November 11, 2019

DevOps: GIT : fatal: refusing to merge unrelated histories

Let's say you are trying to merge 2 branches using
git pull <remote> <branch>

or example 


$ git pull --allow-unrelated-histories  git@github.com:username/firstrepo.git master

And then you get an error 
.
.
fatal: refusing to merge unrelated histories


At this stage what do you do? 

the easy way to circumvent this problem is to allow 


$ git pull --allow-unrelated-histories  git@github.com:username/firstrepo.git master

However, you need to be cautious of the fact that there is going to be unrelated histories to be merged, if you are sure and want to really pull and merge the branches, then follow above.