Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to update-environment on a EB Worker installation #40

Closed
dmessenger opened this issue Dec 31, 2013 · 8 comments
Closed

Unable to update-environment on a EB Worker installation #40

dmessenger opened this issue Dec 31, 2013 · 8 comments

Comments

@dmessenger
Copy link

I have 3 environments running in an application and am using beanstalker to deploy from Jenkins using the same maven profile.
Recently, I changed one environment from a webserver type environment to a worker type environment. I am now receiving an error [environment not found] on the update environment call for the worker type environment:

message : Failed to execute goal br.com.ingenieux:beanstalk-maven-plugin:1.1.1:update-environment (default) on project task: Failed
cause : Failed
Stack trace : 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal br.com.ingenieux:beanstalk-maven-plugin:1.1.1:update-environment (default) on project task: Failed
[truncated]
Caused by: java.lang.RuntimeException: org.apache.maven.plugin.MojoExecutionException: No environments found
    at br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo.configure(AbstractNeedsEnvironmentMojo.java:74)
    at br.com.ingenieux.mojo.aws.AbstractAWSMojo.execute(AbstractAWSMojo.java:357)
    ... 28 more
Caused by: org.apache.maven.plugin.MojoExecutionException: No environments found
    at br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo.handleNonSingle(AbstractBeanstalkMojo.java:95)
    at br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo.handleResults(AbstractBeanstalkMojo.java:87)
    at br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo.lookupEnvironment(AbstractBeanstalkMojo.java:77)
    at br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo.configure(AbstractNeedsEnvironmentMojo.java:72)
    ... 29 more

Is it possible to deploy using update-environment to a worker type environment ?
Do I need to use a different approach for these types of environments ?

@aldrinleal
Copy link
Member

I haven't looked at worker types yet. I expect to spend the next week doing some code maintenance and I expect to get back at you shortly

Meanwhile, can you issue a call to describe-environments and send its output to me via email? It could help

Thanks

@aldrinleal
Copy link
Member

Amazing. Worker instances do not set cnamePrefix. It seems we need to bring back environmentName back into AbstractNeedsEnvironment.

aldrinleal added a commit that referenced this issue Jan 13, 2014
- Handling of Worker Instance Types (see #40)
- Waits for Green as well as Status (see #38)
- Minor Dependency Update on Archetype
@aldrinleal
Copy link
Member

@dmessenger, should work out of the box from 1.2.0-SNAPSHOT (use sonatype-oss-snapshots as a repository)

If you want to enable it for creation, this should work:

    <profile>
        <id>worker</id>
        <properties>
            <beanstalk.workerEnvironmentName>sample-aws-worker</beanstalk.workerEnvironmentName>
            <beanstalk.environmentName>sample-aws-worker</beanstalk.environmentName>
            <beanstalk.environmentTierName>Worker</beanstalk.environmentTierName>
            <beanstalk.sqsdHttpPath>/services/api/v1/sqsd</beanstalk.sqsdHttpPath>
        </properties>
    </profile>

The archetype also includes an example of an SQSD Listener. In theory, I've tested most aspects involved around it (create-environment, update-environment, terminate-environment and fast-deploy)

Thanks.

@dmessenger
Copy link
Author

This no longer throws an exception with Environment Not Found.
However, if I have an application which contains at least 1 standard and 1
worker, then update-environment does not work.

  1. It returns successfully, but chooses the current environment version
    (versionLabel does not change from old)
  2. It performs an update-environment redeploy with the same version

Here are my plugins:

aws-deploy br.com.ingenieux beanstalk-maven-plugin 1.2.0-SNAPSHOT accountmarshal-${env} ${env}-${beanstalk.name} ${beanstalk.name}-${env} accountmarshal ${project.artifactId}/${beanstalk.versionLabel}.war verify describe-environments upload-source-bundle create-application-version update-environment aws-deploy-worker br.com.ingenieux beanstalk-maven-plugin 1.2.0-SNAPSHOT accountmarshal-${env} ${beanstalk.name}-${env} Worker accountmarshal ${project.artifactId}/${beanstalk.versionLabel}.war verify describe-environments upload-source-bundle create-application-version update-environment

And here is a basic trace of the steps for aws-deploy-worker. As you can
see, the version uploaded is [task-1.0.0.0-SNAPSHOT-20140115222724] but the
version deployed is [task-1.0.0.0-SNAPSHOT-20140113-2341]. I can deploy the
uploaded version manually no problems.

[INFO] --- beanstalk-maven-plugin:1.2.0-SNAPSHOT:describe-environments
(default) @ task ---
[WARNING] You should encrypt your passwords. See
http://beanstalker.ingenieux.com.br/security.html for more information
[INFO] SUCCESS
[INFO] * environments: [{EnvironmentName:
accountmarshal-tsk-test,EnvironmentId: e-icavjyvkzm,ApplicationName:
accountmarshal-test,VersionLabel:
task-1.0.0.0-SNAPSHOT-20140113-2341,SolutionStackName:
64bit Amazon Linux 2013.09 running Tomcat 7 Java 7,DateCreated: Mon Dec 30
15:24:50 GMT 2013,DateUpdated: Mon Jan 13 23:47:55 GMT 2014,Status:
Ready,Health: Green,Tier: {Name: Worker,Type: SQS/HTTP,V
ersion: 1.0}}, {EnvironmentName: accountmarshal-app-test,EnvironmentId:
e-txidqfi2py,ApplicationName: accountmarshal-test,VersionLabel:
accountmarshal-app-1.0.0.0-SNAPSHOT-20140115-1625,SolutionStackN
ame: 64bit Amazon Linux 2013.09 running Tomcat 7 Java 7,Description:
test-accountmarshal-app,EndpointURL:
awseb-e-t-AWSEBLoa-1L3BGOJ7Q8I4O-927306776.us-east-1.elb.amazonaws.com,CNAME:
test-accountmars
hal-app.elasticbeanstalk.com,DateCreated: Sun Dec 29 22:23:37 GMT
2013,DateUpdated: Wed Jan 15 21:56:47 GMT 2014,Status: Ready,Health:
Green,Tier: {Name: WebServer,Type: Standard,Version: 1.0}}, {Envi
ronmentName: accountmarshal-api-test,EnvironmentId:
e-mm5gbsxduw,ApplicationName: accountmarshal-test,VersionLabel:
api-1.0.0.0-SNAPSHOT-20140113-2338,SolutionStackName: 64bit Amazon Linux
2013.09 run
ning Tomcat 7 Java 7,Description: test-accountmarshal-api,EndpointURL:
awseb-e-m-AWSEBLoa-DYRFY3Q5RVQB-903604744.us-east-1.elb.amazonaws.com,CNAME:
test-accountmarshal-api.elasticbeanstalk.com,DateCre
ated: Sun Dec 29 22:20:26 GMT 2013,DateUpdated: Mon Jan 13 23:47:07 GMT
2014,Status: Ready,Health: Green,Tier: {Name: WebServer,Type:
Standard,Version: 1.0}}] [class: List]
[INFO]
[INFO] --- beanstalk-maven-plugin:1.2.0-SNAPSHOT:upload-source-bundle
(default) @ task ---
[WARNING] You should encrypt your passwords. See
http://beanstalker.ingenieux.com.br/security.html for more information
[INFO] Target Path:
s3://accountmarshal/task/task-1.0.0.0-SNAPSHOT-20140115222724.war
[INFO] Uploading artifact file:
c:\dev\am\accountmarshal-task\target\task-1.0.0.0-SNAPSHOT.war
100.00% 21 MiB/21 MiB Done
[INFO] Artifact Uploaded
[INFO] SUCCESS
[INFO]
[INFO] --- beanstalk-maven-plugin:1.2.0-SNAPSHOT:create-application-version
(default) @ task ---
[WARNING] You should encrypt your passwords. See
http://beanstalker.ingenieux.com.br/security.html for more information
[INFO] SUCCESS
[INFO] * sourceBundle: {S3Bucket: accountmarshal,S3Key:
task/task-1.0.0.0-SNAPSHOT-20140115222724.war} [class: S3Location]
[INFO] * versionLabel: task-1.0.0.0-SNAPSHOT-20140115222724 [class: String]
[INFO] * description: Update from beanstalk-maven-plugin [class: String]
[INFO] * applicationName: accountmarshal-test [class: String]
[INFO] * dateCreated: Wed Jan 15 22:29:20 GMT 2014 [class: Date]
[INFO] * dateUpdated: Wed Jan 15 22:29:20 GMT 2014 [class: Date]
[INFO]
[INFO] --- beanstalk-maven-plugin:1.2.0-SNAPSHOT:update-environment
(default) @ task ---
[WARNING] Ignoring cnamePrefix. Using workerEnvironmentName instead
[WARNING] You should encrypt your passwords. See
http://beanstalker.ingenieux.com.br/security.html for more information
[INFO] ... with status NOT set to 'Updating'
[INFO] ... with environmentId equal to 'e-icavjyvkzm'
[INFO] ... and with environmentName set to 'accountmarshal-tsk-test'
[INFO] Will wait until Wed Jan 15 22:31:22 GMT 2014 to get into expected
condition
[INFO] SUCCESS
[INFO] * versionLabel: task-1.0.0.0-SNAPSHOT-20140113-2341 [class: String]
[INFO] * status: Updating [class: String]
[INFO] * applicationName: accountmarshal-test [class: String]
[INFO] * tier: {Name: Worker,Type: SQS/HTTP,Version: 1.0} [class:
EnvironmentTier]
[INFO] * health: Grey [class: String]
[INFO] * dateUpdated: Wed Jan 15 22:29:21 GMT 2014 [class: Date]
[INFO] * environmentId: e-icavjyvkzm [class: String]
[INFO] * solutionStackName: 64bit Amazon Linux 2013.09 running Tomcat 7
Java 7 [class: String]
[INFO] * dateCreated: Mon Dec 30 15:24:50 GMT 2013 [class: Date]
[INFO] * environmentName: accountmarshal-tsk-test [class: String]

On 13 January 2014 09:18, Aldrin Leal notifications@github.com wrote:

@dmessenger https://github.com/dmessenger, should work out of the box
from 1.2.0-SNAPSHOT (use sonatype-oss-snapshots as a repository)

If you want to enable it for creation, this should work:

<profile>
    <id>worker</id>
    <properties>
        <beanstalk.workerEnvironmentName>sample-aws-worker</beanstalk.workerEnvironmentName>
        <beanstalk.environmentName>sample-aws-worker</beanstalk.environmentName>
        <beanstalk.environmentTierName>Worker</beanstalk.environmentTierName>
        <beanstalk.sqsdHttpPath>/services/api/v1/sqsd</beanstalk.sqsdHttpPath>
    </properties>
</profile>

The archetype also includes an example of an SQSD Listener. In theory,
I've tested most aspects involved around it (create-environment,
update-environment, terminate-environment and fast-deploy)

Thanks.


Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-32153968
.

@aldrinleal
Copy link
Member

I'm going to review it. I have some Integration Test in the works and I expect to have you guys something these days. Meanwhile, you can use the -SNAPSHOT for the create-environment tasks, which is a good thing

@aldrinleal
Copy link
Member

There's a new build, and you'd need to change from workerEnvironmentName to environmentRef (cnamePrefix is also suggested to be, say, cnameprefix.elasticbeanstalk.com). I'm going to consolidate that in the new IT so it could be easier understood, but if you have the guts to try now, just let me know :)

@dmessenger
Copy link
Author

Thanks Aldrin. I will review and get back to you.

On 20 January 2014 17:41, Aldrin Leal notifications@github.com wrote:

There's a new build, and you'd need to change from workerEnvironmentName
to environmentRef (cnamePrefix is also suggested to be, say,
cnameprefix.elasticbeanstalk.com). I'm going to consolidate that in the
new IT so it could be easier understood, but if you have the guts to try
now, just let me know :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-32780790
.

@aldrinleal
Copy link
Member

Dominic,

Thanks, while I still have some work to do with integration testing, this helped me cover the legacy S3 stuff. I'm not finished, but here's what happens:

Basically, I created a new project using the archetype and ported your statements over it, so you could track the diffs and figure it out. Its at this address. Now, lets look at the changes.

  1. describe-environments is not needed. Some mojos which need an environment to be found now work around the environmentRef variable, where:
    • whatever.elasticbeanstalk.com looks up by cnamePrefix (what used to be the original way)
    • if it matches "e-\p{Alnum}{10}", then it uses by environmentId instead (some people just don't learn hehe. plus, we use it internally in some cases and I've refactored this code to ease on maintenance)
    • if it doesn't match anything of the above, it uses the environmentName instead
  2. See the notes (^F NOTE#) I've scattered around the source. Most likely, for legacy deployment, you'll need:
    • A Version Label (we use the maven build timestamp, but others have been integrated with the maven release plugin or combined with versions. There's no consensus and I really made this part more 'freestyle', while git-based deployments takes a more 'opinionated' approach)
    • Bucket Reference: s3Bucket and s3Key
    • An environmentReference (see previous item)
    • A cnamePrefix and environmentName (if we're using a SQS Worker Instance, only the latter - as long as environment)
  3. Note we prefer variables over configuration sections. This is intentional, as it makes it easier to override.

So here are the commands I've used so far to test it properly, once I've applied the changes:

$ mvn package beanstalk:upload-source-bundle beanstalk:create-application-version beanstalk:put-environment -Paws-deploy

In this case, I wanted to update / create an environment

$ mvn beanstalk:put-environment -Paws-deploy-worker

Looks up the latest version and creates a worker.

$ echo hello >> src/main/webapp/index.txt
$ mvn verify -Paws-deploy   

Creates a new version and updates, as expected

$ mvn beanstalk:update-environment -Paws-deploy-worker

Updates just the worker to the latest version.

$ mvn package beanstalk:upload-source-bundle beanstalk:create-application-version beanstalk:replace-environment -Paws-deploy

does a zero-downtime-redeploy on Webserver Environment (note this DOES NOT WORK with Worker Instances)

$ mvn beanstalk:terminate-environment -Paws-deploy

Terminates the WebServer Environment

$ mvn beanstalk:terminate-environment -Paws-deploy-worker

Same but for the worker instance

btw, a build of 1.2.0-SNAPSHOT should be deployed soon enconpassing those scenario

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants