Monday, March 18, 2019

How to find files which do not have a string

In Linux, i have a folder which has 1K files. I need to know which all files doesn't have a string which I need. In this example, I need to know which all files doesn't have the string/word - apps

cd /path/to/folder
grep -rIL apps

This will list the files which doesn't have the string "apps" in it 

Thursday, March 14, 2019

CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Scenario :

My UI is developed in OJet. It accept some input fields from browser and these inputs needs to be passed as a parameter a shell script.

My Ojet application is running on port 80 and I have a nodejs server running on port 8000. From Ojet web UI when a user clicked on button, it will call an api POST request to my nodejs application and the user input fields are as parameters.

How to solve this error

CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Open your nodejs server.js file (In my case) . Add the following res.header fileds.

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

It fixed my issue.

Monday, March 11, 2019

Oracle API Gateway Node installation error on join action

I am trying to install a gateway node setup using a OCI-classic. Though i could complete the action install,configure & start in sequence, i am unable to finish the JOIN action. I am doing the steps in sequence. Below is the snip of the logs that i have got from registerNode.log (full logs attached as a image): 

DEBUG:root:Performing dev env SSL related workarounds
ERROR:root:Error: Unable to add grant , reason = ['Traceback (most recent call last):\n', '  File "", line 2246, in addGrantToUser\n    resp = urllib2.urlopen(request,data = addGrantJson,context=sslContext)\n', '  File "", line 154, in urlopen\n', '  File "", line 429, in open\n', '  File "", line 447, in _open\n', '  File "", line 407, in _call_chain\n', '  File "", line 1241, in https_open\n', '  File "", line 1201, in do_open\n', '  File "", line 1121, in getresponse\n', '  File "", line 438, in begin\n', '  File "", line 402, in _read_status\n', "BadStatusLine: ''\n"]
WARNING:root:Gateway runtime user could not be given the requisite node service account grants
INFO:status:complete action: join isSuccess: failed detail: {"status": "NOT_JOINED"}
ERROR:main:Action join has failed. Detail: {"status": "NOT_JOINED"}
INFO:main:Gateway join complete.Status = NOT_JOINED.Please check log files for more details

I am pretty sure that i have the entered Gateway runtime user in the node service account grants of the logical gateway itself.

The gatewayExecutionMode is Development. And, i have checked the status of the gateway node but it looks alright. I have attached the logs as image.  I doubt this is related to network. But, could someone please give me a clarity on this ? 

Solution : 
Check your MTU setting for the network interface of the gateway node machine. It should be 1500. For more details, how to set the MTU to 1500 (