Unable to start AWS EC2 instance with deltacloud - ruby

I am trying to manage a EC2 cloud instance with deltacloud API through curl. With the mock driver everything works fine: deltacloudd -i mock -r 10.0.0.3
curl --user "mockuser:mockpassword" "http://10.0.0.3:3001/api/instances?format=xml"
curl -X POST --user "mockuser:mockpassword" "http://10.0.0.3:3001/api/instances/inst1/stop?format=xml"
But with EC2 I am unable to start a stopped instance: deltacloudd -i ec2 -P eu-west-1 -r 10.0.0.3 -V
curl --user "accesskey:secretaccesskey" "http://10.0.0.3:3001/api/instances?format=xml"
curl -X POST --user "accesskey:secretaccesskey" "http://10.0.0.3:3001/api/instances/i-NNNNNNNN/start?format=xml"
Returns: The required capability to execute this operation is missing
Deltacloud log output:
Listening on 10.0.0.3:3001, CTRL+C to stop
D, [2014-06-25T10:47:34.149001 #3575] DEBUG -- : New Aws::Ec2 using per_thread-connection mode
D, [2014-06-25T10:47:34.150897 #3575] DEBUG -- : Opening new HTTPS connection to ec2.eu-west-1.amazonaws.com:443
10.0.0.5 - - [25/Jun/2014 10:47:34] "GET /api/instances?format=xml HTTP/1.1" ec2 eu-west-1 200 1628 0.6204
10.0.0.5 - - [25/Jun/2014 10:48:14] "POST /api/instances/i-NNNNNNNN/start?format=xml {} HTTP/1.1" ec2 eu-west-1 412 60 0.0077
Its therefore obvious that deltacloud process GET, but not forward the POST request to AWS.
The Problem also happens even by clicking the start button at the webinterface (10.0.0.3:3001). The accesskey and secretaccesskey are working fine with python-boto.
Can anyone suggest me whats wrong?

The short answer is, that you can not start a stopped Amazon EC2 instance with deltacloud in the current version 1.1.3 (2013-04-17). Perhaps there will be soon a newer version, but since Red Hat reduced their support the development of deltacloud slowed down.

Related

How to run docker successfully?

I am trying to run the docker example here.
http://chembl.blogspot.com/2020/01/new-chembl-ligand-based-target.html
I can start the docker correctly.
docker run -p 8080:8080 chembl/mcp:25
But when I run this
curl -X POST -H 'Accept: */*' -H 'Content-Type: application/json' -d '{"smiles": "CC(=O)Oc1ccccc1C(=O)O"}' http://127.0.0.1:8080
I got these logging messages.
2020/03/26 13:21:38 Started logging stderr from function.
2020/03/26 13:21:39 Started logging stdout from function.
2020/03/26 13:21:39 OperationalMode: http
2020/03/26 13:21:39 Timeouts: read: 10s, write: 10s hard: 10s.
2020/03/26 13:21:39 Listening on port: 8080
2020/03/26 13:21:39 Writing lock-file to: /tmp/.lock
2020/03/26 13:21:39 Metrics listening on port: 8081
2020/03/26 13:24:53 Upstream HTTP request error: Post http://127.0.0.1:5000/: dial tcp 127.0.0.1:5000: connect: connection refused
I use Mac OS X.
Does anybody know how to fix the problem? Thanks.
I was able to run into the same problem and managed to fix it. All I had to do was increase the resources on Docker Desktop for Mac OS X (the RAM, to be more specific). And also, wait a minute or two as it seems that the module loading is quite resource-intensive.

Not able to start Kibana in local ubuntu : Service Unavailable :: {"path":"/_cluster/settings"

I have installed elastic 6.6 on Ubuntu and it is running fine on port 9200.
I also created a new data using my json file.
curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/product/default/_bulk?pretty" --data-binary "#test-data.json"
But when I start kibana it throws an error.
error [06:27:47.587] [warning][process] Service Unavailable ::
{"path":"/_cluster/settings","query":{"include_defaults":true},"statusCode":503,"response":"503
Service Unavailable\nNo server is available to handle this
request.\n\n\n"}
at respond (/home/svaibhav/Downloads/kibana-6.6.0-linux-x86_64/node_modules/elasticsearch/src/lib/transport.js:308:15)
at checkRespForFailure (/home/svaibhav/Downloads/kibana-6.6.0-linux-x86_64/node_modules/elasticsearch/src/lib/transport.js:267:7)
at HttpConnector. (/home/svaibhav/Downloads/kibana-6.6.0-linux-x86_64/node_modules/elasticsearch/src/lib/connectors/http.js:165:7)
at IncomingMessage.wrapper (/home/svaibhav/Downloads/kibana-6.6.0-linux-x86_64/node_modules/elasticsearch/node_modules/lodash/lodash.js:4935:19)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19) log [06:27:48.009] [warning][admin][elasticsearch] Unable to revive
connection: http://localhost:9200/ log [06:27:48.009]
[warning][admin][elasticsearch] No living connections
EDIT:
IT IS RESOLVED NOW. There were two services running on 9200 port.
one on TCP other on tcpV6. Elastic was up on tcpv6, but kibana was looking on tcp 9200 port.
I changed the port on elastic and it worked.

Docker on Mac is running but refusing to expose port

Mac here, running Docker Community Edition Version 17.12.0-ce-mac49 (21995).
I have Dockerized a web app with a Dockerfile like so:
FROM openjdk:8
RUN mkdir /opt/myapp
ADD build/libs/myapp.jar /opt/myapp
ADD application.yml /opt/myapp
ADD logback.groovy /opt/myapp
WORKDIR /opt/myapp
EXPOSE 9200
ENTRYPOINT ["java", "-Dspring.config=.", "-jar", "myapp.jar"]
I then build that image like so:
docker build -t myapp .
I then run a container of that image like so:
docker run -it -p 9200:9200 --net="host" --env-file ~/myapp-local.env --name myapp myapp
In the console I see the app start up without any errors, and all seems to be well. Even my metrics publishes (which publish heartbeat and other health metrics every 20 seconds) are printing to the console as I would expect them to. Everything seems to be fine.
Except when I go to run a curl against my app from another terminal/session:
curl -i -H "Content-Type: application/json" -X POST -d '{"username":"heyitsme","password":"12345"}' http://localhost:9200/v1/auth/signIn
curl: (7) Failed to connect to localhost port 9200: Connection refused
Now, if this were a situation where the /v1/auth/signIn path wasn't valid, or if there was something wrong with my request entity/payload, the server would pick up on it and send an error (I assure you; as I can confirm this exact same curl works when I run the server outside of Docker as just a standalone service).
So this is definitely a situation where the curl command can't connect to localhost:9200. Again, when I run my app outside of Docker, that same curl command works perfectly, so I know my app is trying to standup on port 9200.
Any ideas as to what could be going wrong here, or how I could begin troubleshooting?
The way you run your container has 2 conflicting parts:
-p 9200:9200 says: "publish (bind) port 9200 of the container to port 9200 of the host"
--net="host" says: "use the host's networking stack"
According to Docker for Mac - Networking docs / Known limitations, use cases, and workarounds, you should only publish a port:
I want to connect to a container from the Mac
Port forwarding works for localhost; --publish, -p, or -P all work. Ports exposed from Linux are forwarded to the Mac.
Our current recommendation is to publish a port, or to connect from another container. This is what you need to do even on Linux if the container is on an overlay network, not a bridge network, as these are not routed.
The command to run the nginx webserver shown in Getting Started is an example of this.
$ docker run -d -p 80:80 --name webserver nginx
Check that your app bind to 0.0.0.0:9200 and not localhost:9200 or something similar
Problem seems to be in the network mode you are running the container.
Quick test: Login to your container and run the curl cmd there, hopefully it works. That would isolate the problem to request not being forwarded from host to container.
Try running your container on the default bridge network and test.
Refer to this blog for details on the network modes in docker
TLDR; You will need to add an IPtables entry to allow the traffic to enter your container.

Docker nginx container: http code 400

I’m a new in docker and I’m trying to run nginx from https://hub.docker.com/_/nginx/
I pulled the image
docker pull nginx
I’m running container
docker run --rm --name=some-nginx -p 8080:80 nginx
but getting http 400 all time when I open localhost:8080 in browser in local machine. Log from docker output:
172.17.0.1 - - [14/Dec/2017:23:07:11 +0000] "\x16\x03\x01\x00\xB5\x01\x00\x00\xB1\x03\x03\x81e|u\x93\xFC`Qo\xC8\xE6y\x18{%\x83\x8C\xC2a\xC93V\xB5;\xC0V\xDC\x10{\xC9)X\x00\x00\x1E\xC0+\xC0/\xCC\xA9\xCC\xA8\xC0,\xC00\xC0" 400 173 "-" "-" "-"
What’s wrong? I checked nginx inside the containter (curl localhost) and it works.
Thank you.
I got it now. It's a bit complicated, but I will try to simplify:
You are binding the 8080 host port to 80 container port. So, if you do a curl localhost at the host, it means you are not calling Nginx service inside the container, but the port 80 process in your *nix system. Likewise, if you send the same command inside the container, it will work, because it has exposed the default http port (80) inside the container, but not outside. You may confirm this assumption by calling curl localhost:8080. If this return as the container command, it is right.
Is it possible to understand?

CircleCI: Best way to verify if docker containers are responding via HTTP

here is an example of part of my circle.yml how I am currently verifying if my mongodb docker container is responding to an http request, so that I can verify if the response is ok and that the server is up.
test:
override:
# RUN DOCKER CONTAINERS
# MongoDB -------------
- docker run --name MongoDB -p 27018:27018 -d mongo:3.0 mongod --port 27018 --replSet "rs"; sleep 10
- curl --retry 10 --retry-delay 5 -v http://localhost:27018
with this curl it's working fine, sometimes.
And sometimes it gives me this error:
curl --retry 10 --retry-delay 5 -v http://localhost:27018
* About to connect() to localhost port 27018 (#0)
* Trying 127.0.0.1... Connection refused
* couldn't connect to host
* Closing connection #0
How can I improve this, to make it more reliable so my tests won't sometimes pass and sometimes fail, if I rebuild the same build?
note: this question was also asked on discuss.circleci.com

Resources