Skip to content
This repository was archived by the owner on Aug 3, 2020. It is now read-only.

Commit 353c745

Browse files
author
Craig Jellick
authored
Merge pull request #99 from mrajashree/catalogBackgroundPoll
Catalog background poll
2 parents fddf147 + f759a8f commit 353c745

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

integration/core/test_api.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -276,42 +276,39 @@ def test_v2_upgrade(client):
276276

277277

278278
def test_upgrade_filters(client):
279-
templates = client.list_template(catalogId='rancher')
279+
templates = client.list_template(catalogId='qa-catalog')
280280
if len(templates) > 0:
281281
for i in range(len(templates)):
282-
if templates[i].name == 'Kubernetes' \
283-
and templates[i].templateBase == 'infra':
282+
if templates[i].id == unicode('qa-catalog:many-versions'):
284283
versionUrlsMap = templates[i].versionLinks
285-
assert len(versionUrlsMap) == 12
284+
assert len(versionUrlsMap) == 15
286285

287-
filter = "v1.2.0-pre4-rc10"
288-
templates = client.list_template(catalogId='rancher',
286+
filter = "v2.2.0"
287+
templates = client.list_template(catalogId='qa-catalog',
289288
maximumRancherVersion_gte=filter,
290289
minimumRancherVersion_lte=filter)
291290
if len(templates) > 0:
292291
for i in range(len(templates)):
293-
if templates[i].name == 'Kubernetes' \
294-
and templates[i].templateBase == 'infra':
292+
if templates[i].id == unicode('qa-catalog:many-versions'):
295293
versionUrlsMap = templates[i].versionLinks
296294
assert len(versionUrlsMap) == 1
297-
assert "v1.4.6-rancher1" in versionUrlsMap
295+
assert "1.0.14" in versionUrlsMap
298296

299-
templates = client.list_template(catalogId='rancher')
297+
templates = client.list_template(catalogId='qa-catalog')
300298
if len(templates) > 0:
301299
for i in range(len(templates)):
302-
if templates[i].name == 'Kubernetes' \
303-
and templates[i].templateBase == 'infra':
300+
if templates[i].id == unicode('qa-catalog:many-versions'):
304301
versionUrlsMap = templates[i].versionLinks
305302
for key in versionUrlsMap.keys():
306-
if key == "v1.2.4-rancher10":
303+
if key == "1.0.12":
307304
url_to_try = versionUrlsMap[key]
308305
response = requests. \
309306
get(url_to_try +
310-
'?minimumRancherVersion_lte=v1.2.0-pre4-rc10&'
311-
'maximumRancherVersion_gte=v1.2.0-pre4-rc10')
307+
'?minimumRancherVersion_lte=v2.2.0&'
308+
'maximumRancherVersion_gte=v2.2.0')
312309
assert response is not 404
313310
response_json = response.json()
314311
upgradeUrls = response_json. \
315312
get(unicode('upgradeVersionLinks'))
316313
assert len(upgradeUrls) == 1
317-
assert "v1.4.6-rancher1" in upgradeUrls
314+
assert "1.0.14" in upgradeUrls

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func main() {
1717
manager.GetCommandLine()
1818

1919
go manager.Init()
20+
manager.StartCatalogBackgroundPoll()
2021
manager.WatchSignals()
2122
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *manager.Port), &handler))
2223
}

manager/catalog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (cat *Catalog) refreshCatalog() {
238238
cat.metadata = make(map[string]model.Template)
239239
filepath.Walk(cat.catalogRoot, cat.walkCatalog)
240240
} else {
241-
log.Debugf("Will not refresh the catalog since Pull Catalog faced error: %v", err)
241+
log.Infof("Will not refresh the catalog since Pull Catalog faced error: %v", err)
242242
}
243243
<-*cat.refreshReqChannel
244244
default:

manager/catalog_manager.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,10 @@ func Init() {
251251
for _, catalog := range CatalogsCollection {
252252
catalog.pullCatalog()
253253
}
254-
255-
//start a background timer to pull from the Catalog periodically
256-
startCatalogBackgroundPoll()
257254
}
258255

259-
func startCatalogBackgroundPoll() {
256+
//StartCatalogBackgroundPoll starts a background timer to pull from the Catalog periodically
257+
func StartCatalogBackgroundPoll() {
260258
ticker := time.NewTicker(time.Duration(*refreshInterval) * time.Second)
261259
go func() {
262260
for t := range ticker.C {

0 commit comments

Comments
 (0)