Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
cc772fcb
Commit
cc772fcb
authored
4 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Fix an error where we'd constantly try to renew SSL certificates
Set the renewal timestamp on the initial certificate load.
parent
e678f2d6
No related branches found
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
node/acme/manager.go
+11
-11
11 additions, 11 deletions
node/acme/manager.go
with
11 additions
and
11 deletions
node/acme/manager.go
+
11
−
11
View file @
cc772fcb
...
...
@@ -80,6 +80,12 @@ func NewManager(ctx context.Context, cli *clientv3.Client, email, directoryURL s
// validation tokens on etcd.
acmeMgr
:=
NewACME
(
email
,
directoryURL
,
newEtcdKeyStore
(
cli
,
keyPath
),
newEtcdTokenStore
(
cli
))
m
:=
&
Manager
{
ACME
:
acmeMgr
,
names
:
certNames
,
cli
:
cli
,
}
// Try to fetch the existing certificate from etcd, or
// generate a self-signed one.
cert
,
rev
,
err
:=
fetchCert
(
ctx
,
cli
,
certPath
)
...
...
@@ -92,17 +98,9 @@ func NewManager(ctx context.Context, cli *clientv3.Client, email, directoryURL s
return
nil
,
fmt
.
Errorf
(
"failed to create self-signed certificate: %v"
,
err
)
}
}
tlsCert
,
err
:=
cert
.
TLSCertificate
()
if
err
!=
nil
{
return
nil
,
err
}
m
:=
&
Manager
{
ACME
:
acmeMgr
,
names
:
certNames
,
cli
:
cli
,
cert
:
cert
,
tlsCert
:
tlsCert
,
if
err
:=
m
.
setCert
(
cert
);
err
!=
nil
{
return
nil
,
err
}
// Update m.cert using a watcher.
...
...
@@ -143,13 +141,15 @@ func (m *Manager) shouldRenew() bool {
func
(
m
*
Manager
)
renewLoop
(
ctx
context
.
Context
)
{
// Initial delay to stagger concurrent initialization.
time
.
Sleep
(
time
.
Duration
(
mrand
.
Intn
(
30
))
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
mrand
.
Intn
(
30
0
))
*
time
.
Second
)
for
{
if
m
.
shouldRenew
()
{
log
.
Printf
(
"attempting to renew SSL certificate..."
)
if
err
:=
m
.
renew
(
ctx
);
err
!=
nil
{
log
.
Printf
(
"renewal failed: %v"
,
err
)
}
else
{
log
.
Printf
(
"successfully renewed SSL certificate"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment