-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
After the ACME challenge is removed from the zone, the new zone data must be applied to the DNS servers.
A syntax and variable name error messed up the refresh action.
Sorry, I messed up this pull request. Fixes are on the way. |
Now everything should work. |
bin/delete-record.js
Outdated
process.exit(1); | ||
} | ||
}); | ||
|
||
process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again for contributing!
Unfortunately it doesn't work yet, the async POST call to refresh the zone never happens because process.exit(0)
is called before. You could simply delete that line, since it's completely redundant. Also, I personally like to use different exit codes, so I know where the process exited. You could simply go up a number and use process.exit(3)
instead of process.exit(1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I am completely new to node.js...
I see, the POST call is actually inside the DELETE call. That was not what I intended to do.
About the exit code, in 'bin/create_record.js' you used process.exit(1)
for exiting when a error occurred. I overlooked that you use different exit codes in 'delete_record.js'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've all been there! ;)
Well, it is actually good the way you did it. You have to wait for the call back from the DELETE call.
The problem is that ovh.request('POST',...
puts an async operation on the event loop to not block the thread, meaning it continues the flow, hitting process.exit(0)
and closing the whole program all together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think simply removing process.exit(0);
will be enough.
To ensure that the zone refresh call is actually executed, call it from an own request.
To distinguish exit point, change exit code when the zone refresh command fails.
bin/delete-record.js
Outdated
}); | ||
|
||
process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, now this is even worse 😅
Basically what will happen is:
- DELETE request is scheduled
- POST request is scheduled
- Process exited (0)
- DELETE & POST request are executed at the same time.
Of course 4 never happens because the process is already exited. The way it was done before it was perfect. Before, the flow was:
- DELETE is scheduled
- DELETE is executed
- Callback of DELETE is executed
- POST is scheduled
- Process is exited (0)
- POST is executed.
The problem here was simply that the process exited before the refresh call could be executed. I suggest to go back to the previous commits, simply deleting the process.exit(0);
line that is superfluous and actually bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, to be clear: you wrote the process.exit(0);
not me. That actually confused me a bit.
What confuses me a little bit more, the code actually works fine. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I wrote it, but when I did there was nothing else to do… while now you have also refresh the zone — which btw is a good idea because it is a necessary step to update the zone.
In my tests it actually doesn't delete the record… you can test by running dig against the DNS record or using the API console here: https://api.ovh.com/console/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I have to excuse. You are right, the record will not be deleted. It is possible that I ran the test with older code... oops.
We have to wait until the delete request is finished before exiting the process.
Thank you again for your contributions! |
After the ACME challenge is removed from the zone, the new zone data
must be applied to the DNS servers.