Skip to content

Commit 33d7e9b

Browse files
committed
Merge pull request Netflix#413 from joesondow/ASGARD-1253-fix-startup-errors-on-missing-credentials-and-swf-domain
ASGARD-1253 - Asgard should start without error even when server has no credentials yet and AWS account has no SWF domains yet
2 parents 0069345 + bac2681 commit 33d7e9b

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
1.3.1
2+
3+
Bug Fixes
4+
- Fixed startup error for new Asgard installations that lack an existing Config.groovy file
5+
- Fixed startup error for AWS accounts that don't yet have an asgard SWF domain
6+
7+
18
1.3
29

310
Features

application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
app.grails.version=2.2.4
44
app.name=asgard
55
app.servlet.version=2.4
6-
app.version=1.3
6+
app.version=1.3.1

grails-app/conf/spring/resources.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ beans = {
4848

4949
deploymentActivitiesImpl(DeploymentActivitiesImpl) {
5050
it.autowire = "byName"
51+
it.lazyInit = true
5152
}
5253

5354
snsTaskFinishedListener(SnsTaskFinishedListener) { bean ->

grails-app/services/com/netflix/asgard/AwsSimpleWorkflowService.groovy

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ class AwsSimpleWorkflowService implements CacheInitializer, InitializingBean {
8181
* Set up relevant cache objects to begin retrieving data.
8282
*/
8383
void initializeCaches() {
84-
caches.allWorkflowDomains.ensureSetUp({ retrieveDomains() }, {
84+
caches.allWorkflowDomains.ensureSetUp({ retrieveDomainsAndEnsureDomainIsRegistered() }, {
8585
caches.allOpenWorkflowExecutions.ensureSetUp({ retrieveOpenWorkflowExecutions() })
8686
caches.allClosedWorkflowExecutions.ensureSetUp({ retrieveClosedWorkflowExecutions() })
87+
caches.allWorkflowTypes.ensureSetUp({ retrieveWorkflowTypes() })
88+
caches.allActivityTypes.ensureSetUp({ retrieveActivityTypes() })
8789
})
88-
caches.allWorkflowTypes.ensureSetUp({ retrieveWorkflowTypes() })
89-
caches.allActivityTypes.ensureSetUp({ retrieveActivityTypes() })
9090
}
9191

9292
// Activity types
@@ -364,7 +364,12 @@ class AwsSimpleWorkflowService implements CacheInitializer, InitializingBean {
364364

365365
// Workflow Domains
366366

367-
private List<DomainInfo> retrieveDomains() {
367+
/**
368+
* Gets all the SWF domains and registers the main domain we need if it's not already in the list.
369+
*
370+
* @return info objects for all the registered domains in the default region
371+
*/
372+
List<DomainInfo> retrieveDomainsAndEnsureDomainIsRegistered() {
368373
log.debug('Retrieve workflow domains')
369374
ListDomainsRequest request = new ListDomainsRequest(registrationStatus: 'REGISTERED')
370375
List<DomainInfo> domains = domainFetcher.retrieve(Region.defaultRegion(), request)

grails-app/services/com/netflix/asgard/FlowService.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import org.springframework.beans.factory.InitializingBean
4343
class FlowService implements InitializingBean {
4444

4545
def awsClientService
46+
def awsSimpleWorkflowService
4647
def configService
4748
def idService
4849
DeploymentActivitiesImpl deploymentActivitiesImpl
@@ -61,6 +62,11 @@ class FlowService implements InitializingBean {
6162
] as Map)
6263

6364
void afterPropertiesSet() {
65+
66+
// Ensure that the domain has been registered before attempting to reference it with workers. This code runs
67+
// before cache filling begins.
68+
awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()
69+
6470
String domain = configService.simpleWorkflowDomain
6571
String taskList = configService.simpleWorkflowTaskList
6672
GlobalWorkflowAttributes.taskList = taskList

test/unit/com/netflix/asgard/AwsSimpleWorkflowServiceUnitSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class AwsSimpleWorkflowServiceUnitSpec extends Specification {
5151
awsSimpleWorkflowService.simpleWorkflowClient = Mock(AmazonSimpleWorkflow)
5252

5353
when:
54-
List<DomainInfo> domains = awsSimpleWorkflowService.retrieveDomains()
54+
List<DomainInfo> domains = awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()
5555

5656
then:
5757
domains == [new DomainInfo(name: 'domain1')]
@@ -69,7 +69,7 @@ class AwsSimpleWorkflowServiceUnitSpec extends Specification {
6969
awsSimpleWorkflowService.simpleWorkflowClient = Mock(AmazonSimpleWorkflow)
7070

7171
when:
72-
awsSimpleWorkflowService.retrieveDomains()
72+
awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()
7373

7474
then:
7575
1 * awsSimpleWorkflowService.simpleWorkflowClient.registerDomain(_)

0 commit comments

Comments
 (0)