Skip to content

Dev mode config updates - #189

Closed
Rub21 wants to merge 12 commits into
stagingfrom
dev_mode
Closed

Rub21 wants to merge 12 commits into
stagingfrom
dev_mode

Conversation

@Rub21

@Rub21 Rub21 commented Oct 18, 2022

Copy link
Copy Markdown
Member

@Rub21

Rub21 commented Nov 9, 2022

Copy link
Copy Markdown
Member Author

@danrademacher , When you test that this documentation is good enough to make working the Dev environment , you can merge this PR.

Dan Rademacher added 3 commits November 9, 2022 15:39
Hit an error with
```sh
% docker-compose up db -d
ERROR: No such service: -d
```
but
`docker-compose up -d db` works fine
@danrademacher

Copy link
Copy Markdown

Hitting some issues here. Will document in this thread while still trying to work through them:

Editing config/settings.yml

sed on the SMTP password fails becuase the password from AWS contains a slash. When @Rub21 demoed this for me, he was able to make changes in the settings.yml in his git repo, manually, and changes made inside the container via sed were reflected in git, and vice versa.

For me, the sed commands inside the container are not changing the settings.yml file in my repo, and I stopped and started a couple of times to make sure I wasn't somehow running this from another copy on my machine. I am very sure that's not the case, though I also can't explain why this different behavior is occurring...

I installed nano on the container so I could edit the file there, splicing in the password and also commenting out some lines to later populate with OAUTH tokens.

running apache in foreground doesn't seem to work

After doing apachectl -k start -DFOREGROUND, I don't see anything from there -- I'd expect a status or serving/running something like that. And localhost fails. If I just do apachectl -k start it works fine. Whatevs. I can kill it later

signing up for account, didn't get email

Ruben demonstrated the full cycle, including getting an email. I signed up for an account but did not get an email...

Searching [email protected] in all-mail did not turn anything up. I suspect my SMTP settings are somehow not correct.

Ah, and here's the error:

[Worker(host:42a5817b24be pid:325)] Job ActionMailer::MailDeliveryJob [7705a6b2-db18-4338-b0bc-7a6708023d90] from DelayedJob(mailers) with arguments: ["UserMailer", "signup_confirm", "deliver_now", {"args"=>[{"_aj_globalid"=>"gid://open-street-map/User/1"}, {"_aj_globalid"=>"gid://open-street-map/UserToken/2"}], "_aj_symbol_keys"=>["args"]}] (id=1) (queue=mailers) FAILED (0 prior attempts) with Net::OpenTimeout: Timeout to open TCP connection to email-smtp.us-east-1.amazonaws.com:25 (exceeds 30 seconds)
[Worker(host:42a5817b24be pid:325)] Job ActionMailer::MailDeliveryJob [95b5f763-9636-43ee-b640-98a69a91f4e4] from DelayedJob(mailers) with arguments: ["UserMailer", "signup_confirm", "deliver_now", {"args"=>[{"_aj_globalid"=>"gid://open-street-map/User/1"}, {"_aj_globalid"=>"gid://open-street-map/UserToken/4"}], "_aj_symbol_keys"=>["args"]}] (id=2) (queue=mailers) RUNNING

Specifically
FAILED (0 prior attempts) with Net::OpenTimeout: Timeout to open TCP connection to email-smtp.us-east-1.amazonaws.com:25 (exceeds 30 seconds)

I'm going to have to come back to this and see what's wrong with those SMTP settings. I did just confirm they look proper in the settings.yml:

smtp_address: "email-smtp.us-east-1.amazonaws.com"
smtp_port: 25
smtp_domain: "openhistoricalmap.org"
smtp_enable_starttls_auto: true
smtp_tls_verify_mode: "none"
smtp_authentication: "login"
smtp_user_name: "AK..."
smtp_password: BB.../...

so it doesn't seem like a simple lack of credentials.

@danrademacher

Copy link
Copy Markdown

I am testing my SMTP connection using the methods at https://docs.aws.amazon.com/ses/latest/dg/send-email-smtp-client-command-line.html

The connection seemed fine, so I went on to teh command line test of sending an email, from inside the container.

root@42a5817b24be:/var/www# openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.us-east-1.amazonaws.com:587 < input.txt
depth=2 C = US, O = Amazon, CN = Amazon Root CA 1
verify return:1
depth=1 C = US, O = Amazon, OU = Server CA 1B, CN = Amazon
verify return:1
depth=0 CN = email-smtp.us-east-1.amazonaws.com
verify return:1
250 Ok
250-email-smtp.amazonaws.com
250-8BITMIME
250-STARTTLS
250-AUTH PLAIN LOGIN
250 Ok
334 [REDACTED id string, not sure if credential]
334 [REDACTED id string, not sure if credential]
235 Authentication successful.
250 Ok
250 Ok
354 End data with <CR><LF>.<CR><LF>
250 Ok 010001845f4bfb86-b216722c-9c89-4c3c-97ad-a91bd8751c6a-000000
451 4.4.2 Timeout waiting for data from client.

So the auth to SMTP is successful, the content of the email is in a text file, and yet it's timing out.

But wait, I got the email!
image

Huh but why am I getting timeouts and NOT getting emails from the Rails app.

Looks like some info about timeouts at https://docs.aws.amazon.com/ses/latest/dg/troubleshoot-smtp.html:

You're sending to Amazon SES from an Amazon EC2 instance using port 25, and you're receiving timeout errors.
Amazon EC2 restricts port 25 by default. To remove these restrictions, submit an Amazon EC2 Request to Remove Email > Sending Limitations. You can also connect to Amazon SES using ports 465 or 587, neither of which is restricted.

I tried changing to smtp_port: 465 from smtp_port: 25 to see if that would work, but I get the same error:

Job ActionMailer::MailDeliveryJob [95b5f763-9636-43ee-b640-98a69a91f4e4] from DelayedJob(mailers) with arguments: ["UserMailer", "signup_confirm", "deliver_now", {"args"=>[{"_aj_globalid"=>"gid://open-street-map/User/1"}, {"_aj_globalid"=>"gid://open-street-map/UserToken/4"}], "_aj_symbol_keys"=>["args"]}] (id=2) (queue=mailers) FAILED (2 prior attempts) with Net::OpenTimeout: Timeout to open TCP connection to email-smtp.us-east-1.amazonaws.com:25 (exceeds 30 seconds)
[Worker(host:42a5817b24be pid:325)] Job ActionMailer::MailDeliveryJob [7705a6b2-db18-4338-b0bc-7a6708023d90] from DelayedJob(mailers) with arguments: ["UserMailer", "signup_confirm", "deliver_now", {"args"=>[{"_aj_globalid"=>"gid://open-street-map/User/1"}, {"_aj_globalid"=>"gid://open-street-map/UserToken/2"}], "_aj_symbol_keys"=>["args"]}] (id=1) (queue=mailers) RUNNING

@Rub21

Rub21 commented Nov 14, 2022

Copy link
Copy Markdown
Member Author

@danrademacher , are you using smtp_values branch, where I updated config/settings.yml file OpenHistoricalMap/ohm-website#136 ?

@danrademacher

Copy link
Copy Markdown

I am using:

  • smtp_values branch for ohm-website
  • dev_mode branch for ohm-deploy

One thing I was wrong about:

For me, the sed commands inside the container are not changing the settings.yml file in my repo, and I stopped and started a couple of times to make sure I wasn't somehow running this from another copy on my machine. I am very sure that's not the case, though I also can't explain why this different behavior is occurring...

this was human error on my part - I was looking for changes in the ohm-deploy repo, rather than ohm-website. The changes are actually as expected on config/settings/yml:
image

(SMTP user and password also changed, but leaving those out here for security reasons)

So it seems like settings are all proper, and emails are getting sent when using the raw SES testing methods

@danrademacher

Copy link
Copy Markdown

Ruben has again confirmed this is working for him... but I have tried probably 6 times and still no dice

@tomay is our third person, trying a fresh install! When rerunning after the first time, these commands will dump the data base to ensure a fresh start in case OAUTH keys were wrong:

docker-compose down
rm -rf data

then proceed with steps in the DEVLEOPMENT.MD

docker-compose build
docker-compose up -d db
docker-compose up -d memcached
docker compose run --service-ports web bash

And then into the container and following the docs from there.

@danrademacher

Copy link
Copy Markdown

@tomay and I have continued to struggle with getting local development working all the way through to loading iD… We spent another hour this morning going through it and after a fresh start, I’m still at the point I was before — 500 error on clicking /edit with the following in log/production.log :

I, [2022-11-22T19:35:38.393693 #2399]  INFO -- : [56160867-9cf8-4633-a1b5-ae20afd66a24] Completed 500 Internal Server Error in 86ms (ActiveRecord: 38.7ms | Allocations: 4143)
F, [2022-11-22T19:35:38.400919 #2399] FATAL -- : [56160867-9cf8-4633-a1b5-ae20afd66a24]
[56160867-9cf8-4633-a1b5-ae20afd66a24] ActionView::Template::Error (undefined method `access_token_for_user' for nil:NilClass):
[56160867-9cf8-4633-a1b5-ae20afd66a24]     10: <body>
[56160867-9cf8-4633-a1b5-ae20afd66a24]     11: <% data = {}
[56160867-9cf8-4633-a1b5-ae20afd66a24]     12:    if Settings.key?(:id_key)
[56160867-9cf8-4633-a1b5-ae20afd66a24]     13:      token = current_user.access_token(Settings.id_key)
[56160867-9cf8-4633-a1b5-ae20afd66a24]     14:      data[:token] = token.token
[56160867-9cf8-4633-a1b5-ae20afd66a24]     15:      data[:token_secret] = token.secret
[56160867-9cf8-4633-a1b5-ae20afd66a24]     16:      data[:consumer_key] = token.client_application.key
[56160867-9cf8-4633-a1b5-ae20afd66a24]
[56160867-9cf8-4633-a1b5-ae20afd66a24] app/models/user.rb:346:in `access_token'
[56160867-9cf8-4633-a1b5-ae20afd66a24] app/views/site/id.html.erb:13
[56160867-9cf8-4633-a1b5-ae20afd66a24] app/controllers/site_controller.rb:125:in `id'
[56160867-9cf8-4633-a1b5-ae20afd66a24] config/initializers/compressed_requests.rb:27:in `call'
[56160867-9cf8-4633-a1b5-ae20afd66a24] config/initializers/cors.rb:9:in `call'
I, [2022-11-22T19:35:38.407045 #2399]  INFO -- : [56160867-9cf8-4633-a1b5-ae20afd66a24] Processing by ErrorsController#internal_server_error as HTML
I, [2022-11-22T19:35:38.415193 #2399]  INFO -- : [56160867-9cf8-4633-a1b5-ae20afd66a24]   Rendered errors/internal_server_error.html.erb within layouts/error (Duration: 4.4ms | Allocations: 79)
I, [2022-11-22T19:35:38.426475 #2399]  INFO -- : [56160867-9cf8-4633-a1b5-ae20afd66a24]   Rendered layout layouts/error.html.erb (Duration: 15.8ms | Allocations: 1518)
I, [2022-11-22T19:35:38.429602 #2399]  INFO -- : [56160867-9cf8-4633-a1b5-ae20afd66a24] Completed 500 Internal Server Error in 20ms (Views: 19.1ms | ActiveRecord: 0.0ms | Allocations: 2034)

In theory, this is due to improper OAUTH keys, but I’ve recreated, set, and checked those a few times over, including on a screenshare with Tom and at least some with Ruben (though cut up by intervening meetings I had to go to), all to no avail.

@danrademacher

Copy link
Copy Markdown

@batpad is going to run through this process and consult with @Rub21 to figure out if we have a documentation issue, some step @tomay and I are not doing correctly, or something else that's blocking local dev for some of us.

@danrademacher

Copy link
Copy Markdown

Given latest method of local dev within the ohm-website code, I am closing this out unmerged

@Rub21
Rub21 deleted the dev_mode branch January 23, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants