Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
GitHub Mirror
Renovate Bot
renovate
Commits
b277dfe7
Unverified
Commit
b277dfe7
authored
5 years ago
by
Rhys Arkins
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(docker): caching of null lookup responses (#6534)
parent
cf508a3c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/datasource/docker/index.ts
+12
-13
12 additions, 13 deletions
lib/datasource/docker/index.ts
with
12 additions
and
13 deletions
lib/datasource/docker/index.ts
+
12
−
13
View file @
b277dfe7
...
@@ -336,12 +336,13 @@ export async function getDigest(
...
@@ -336,12 +336,13 @@ export async function getDigest(
);
);
logger
.
debug
(
`getDigest(
${
registry
}
,
${
repository
}
,
${
newValue
}
)`
);
logger
.
debug
(
`getDigest(
${
registry
}
,
${
repository
}
,
${
newValue
}
)`
);
const
newTag
=
newValue
||
'
latest
'
;
const
newTag
=
newValue
||
'
latest
'
;
const
cacheNamespace
=
'
datasource-docker-digest
'
;
const
cacheKey
=
`
${
registry
}
:
${
repository
}
:
${
newTag
}
`
;
let
digest
=
null
;
try
{
try
{
const
cacheNamespace
=
'
datasource-docker-digest
'
;
const
cacheKey
=
`
${
registry
}
:
${
repository
}
:
${
newTag
}
`
;
const
cachedResult
=
await
globalCache
.
get
(
cacheNamespace
,
cacheKey
);
const
cachedResult
=
await
globalCache
.
get
(
cacheNamespace
,
cacheKey
);
// istanbul ignore if
// istanbul ignore if
if
(
cachedResult
)
{
if
(
cachedResult
!==
undefined
)
{
return
cachedResult
;
return
cachedResult
;
}
}
const
manifestResponse
=
await
getManifestResponse
(
const
manifestResponse
=
await
getManifestResponse
(
...
@@ -349,14 +350,10 @@ export async function getDigest(
...
@@ -349,14 +350,10 @@ export async function getDigest(
repository
,
repository
,
newTag
newTag
);
);
if
(
!
manifestResponse
)
{
if
(
manifestResponse
)
{
return
null
;
digest
=
extractDigestFromResponse
(
manifestResponse
)
||
null
;
logger
.
debug
({
digest
},
'
Got docker digest
'
);
}
}
const
digest
=
extractDigestFromResponse
(
manifestResponse
);
logger
.
debug
({
digest
},
'
Got docker digest
'
);
const
cacheMinutes
=
30
;
await
globalCache
.
set
(
cacheNamespace
,
cacheKey
,
digest
,
cacheMinutes
);
return
digest
;
}
catch
(
err
)
/* istanbul ignore next */
{
}
catch
(
err
)
/* istanbul ignore next */
{
if
(
err
instanceof
DatasourceError
)
{
if
(
err
instanceof
DatasourceError
)
{
throw
err
;
throw
err
;
...
@@ -369,8 +366,10 @@ export async function getDigest(
...
@@ -369,8 +366,10 @@ export async function getDigest(
},
},
'
Unknown Error looking up docker image digest
'
'
Unknown Error looking up docker image digest
'
);
);
return
null
;
}
}
const
cacheMinutes
=
30
;
await
globalCache
.
set
(
cacheNamespace
,
cacheKey
,
null
,
cacheMinutes
);
return
digest
;
}
}
async
function
getTags
(
async
function
getTags
(
...
@@ -386,7 +385,7 @@ async function getTags(
...
@@ -386,7 +385,7 @@ async function getTags(
cacheKey
cacheKey
);
);
// istanbul ignore if
// istanbul ignore if
if
(
cachedResult
)
{
if
(
cachedResult
!==
undefined
)
{
return
cachedResult
;
return
cachedResult
;
}
}
// AWS ECR limits the maximum number of results to 1000
// AWS ECR limits the maximum number of results to 1000
...
@@ -486,7 +485,7 @@ async function getLabels(
...
@@ -486,7 +485,7 @@ async function getLabels(
cacheKey
cacheKey
);
);
// istanbul ignore if
// istanbul ignore if
if
(
cachedResult
)
{
if
(
cachedResult
!==
undefined
)
{
return
cachedResult
;
return
cachedResult
;
}
}
try
{
try
{
...
...
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