Skip to content

Commit

Permalink
Merge pull request #413 from joesondow/ASGARD-1253-fix-startup-errors…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
joesondow committed Oct 25, 2013
2 parents 0069345 + bac2681 commit 33d7e9b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.3.1

Bug Fixes
- Fixed startup error for new Asgard installations that lack an existing Config.groovy file
- Fixed startup error for AWS accounts that don't yet have an asgard SWF domain


1.3

Features
Expand Down
2 changes: 1 addition & 1 deletion application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
app.grails.version=2.2.4
app.name=asgard
app.servlet.version=2.4
app.version=1.3
app.version=1.3.1
1 change: 1 addition & 0 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ beans = {

deploymentActivitiesImpl(DeploymentActivitiesImpl) {
it.autowire = "byName"
it.lazyInit = true
}

snsTaskFinishedListener(SnsTaskFinishedListener) { bean ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class AwsSimpleWorkflowService implements CacheInitializer, InitializingBean {
* Set up relevant cache objects to begin retrieving data.
*/
void initializeCaches() {
caches.allWorkflowDomains.ensureSetUp({ retrieveDomains() }, {
caches.allWorkflowDomains.ensureSetUp({ retrieveDomainsAndEnsureDomainIsRegistered() }, {
caches.allOpenWorkflowExecutions.ensureSetUp({ retrieveOpenWorkflowExecutions() })
caches.allClosedWorkflowExecutions.ensureSetUp({ retrieveClosedWorkflowExecutions() })
caches.allWorkflowTypes.ensureSetUp({ retrieveWorkflowTypes() })
caches.allActivityTypes.ensureSetUp({ retrieveActivityTypes() })
})
caches.allWorkflowTypes.ensureSetUp({ retrieveWorkflowTypes() })
caches.allActivityTypes.ensureSetUp({ retrieveActivityTypes() })
}

// Activity types
Expand Down Expand Up @@ -364,7 +364,12 @@ class AwsSimpleWorkflowService implements CacheInitializer, InitializingBean {

// Workflow Domains

private List<DomainInfo> retrieveDomains() {
/**
* Gets all the SWF domains and registers the main domain we need if it's not already in the list.
*
* @return info objects for all the registered domains in the default region
*/
List<DomainInfo> retrieveDomainsAndEnsureDomainIsRegistered() {
log.debug('Retrieve workflow domains')
ListDomainsRequest request = new ListDomainsRequest(registrationStatus: 'REGISTERED')
List<DomainInfo> domains = domainFetcher.retrieve(Region.defaultRegion(), request)
Expand Down
6 changes: 6 additions & 0 deletions grails-app/services/com/netflix/asgard/FlowService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.springframework.beans.factory.InitializingBean
class FlowService implements InitializingBean {

def awsClientService
def awsSimpleWorkflowService
def configService
def idService
DeploymentActivitiesImpl deploymentActivitiesImpl
Expand All @@ -61,6 +62,11 @@ class FlowService implements InitializingBean {
] as Map)

void afterPropertiesSet() {

// Ensure that the domain has been registered before attempting to reference it with workers. This code runs
// before cache filling begins.
awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()

String domain = configService.simpleWorkflowDomain
String taskList = configService.simpleWorkflowTaskList
GlobalWorkflowAttributes.taskList = taskList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AwsSimpleWorkflowServiceUnitSpec extends Specification {
awsSimpleWorkflowService.simpleWorkflowClient = Mock(AmazonSimpleWorkflow)

when:
List<DomainInfo> domains = awsSimpleWorkflowService.retrieveDomains()
List<DomainInfo> domains = awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()

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

when:
awsSimpleWorkflowService.retrieveDomains()
awsSimpleWorkflowService.retrieveDomainsAndEnsureDomainIsRegistered()

then:
1 * awsSimpleWorkflowService.simpleWorkflowClient.registerDomain(_)
Expand Down

0 comments on commit 33d7e9b

Please sign in to comment.