GoogleCloudPlatform / gcloud-maven-plugin

Cloud SDK Maven Plugin for Google App Engine (Managed VMs and non Managed VMs)
Apache License 2.0
29 stars 24 forks source link

Plugin generates app.yaml with env: string #61

Closed spark2ignite closed 8 years ago

spark2ignite commented 8 years ago

When running mvn gcloud:deploy, it generates app.yaml as following:

runtime: java
env: 2
api_version: 1
threadsafe: True
handlers:
  - url: .*
    script: dynamic

The problem with env: 2 line is that triggers ManagedVM style deployment and not regular (classic) AppEngine deployment.

Is there is any way to generate app.yaml without env: 2 ?

ludoch commented 8 years ago

Do you have an appengine-web.xml file next to the web.XML? On Nov 11, 2015 10:36 PM, "Vadim Solovey" notifications@github.com wrote:

When running mvn gcloud:deploy, it generates app.yaml as following:

runtime: java env: 2 api_version: 1 threadsafe: True handlers:

  • url: .* script: dynamic

The problem with env: 2 line is that triggers ManagedVM style deployment and not regular (classic) AppEngine deployment.

Is there is any way to generate app.yaml without env: 2 ?

— Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gcloud-maven-plugin/issues/61.

spark2ignite commented 8 years ago

Yes, I do.

ludoch commented 8 years ago

And it contains

true? If you could zip a small web project that can reproduce the issue, I could push an update soon.... Thanks On Nov 11, 2015 11:53 PM, "Vadim Solovey" notifications@github.com wrote: > Yes, I do. > > — > Reply to this email directly or view it on GitHub > https://github.com/GoogleCloudPlatform/gcloud-maven-plugin/issues/61#issuecomment-155934820 > .
spark2ignite commented 8 years ago

No, it doesn't contain the "true". However, because of the env:2 it seems like with latest Google Cloud SDK, it triggers MVM deployment.

ludoch commented 8 years ago

can you check your pom.xml and see if it has

war

if the packaging is a "jar" that would trigger this code path. Otther trigger is the lack of the file appengine-web.xml in your source WEB-INF of the project. Let me know.

spark2ignite commented 8 years ago

Yes, the pom.xml does have a war reference (attached).

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>selectmediaservers</groupId>
    <artifactId>selectmediaservers</artifactId>
    <version>1</version>
    <packaging>war</packaging>
    <properties>
    <appengine.target.version>1.9.22</appengine.target.version>
    <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
  </properties>

    <build>
    <directory>${project.basedir}/Server/Cloud/selectmediaservers/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <sourceDirectory>Server/Cloud/selectmediaservers</sourceDirectory>

    <plugins>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.5</version>
            <configuration>
        <webXml>${project.basedir}/Server/Cloud/selectmediaservers/war/WEB-INF/web.xml</webXml>
        <warSourceDirectory>${project.basedir}/Server/Cloud/selectmediaservers/war</warSourceDirectory>
         <webResources>
                <resource>
                    <directory>${project.basedir}/Server/Cloud/selectmediaservers/war</directory>
                    <filtering>true</filtering>
                    <includes>
                        <include>${project.basedir}/Server/Cloud/selectmediaservers/war/WEB-INF/appengine-web.xml</include>
                        <include>${project.basedir}/Server/Cloud/selectmediaservers/war/WEB-INF/web.xml</include>
                    </includes>
                </resource>
            </webResources>
            </configuration>
        </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>gcloud-maven-plugin</artifactId>
                <version>2.0.9.72.v20150804</version>
                <configuration>
                    <gcloud_directory>${gcloud.directory}</gcloud_directory>
                    <gcloud_verbosity>debug</gcloud_verbosity>
                    <set_default>false</set_default>
          <max_module_instances>2</max_module_instances>
                    <log_level>info</log_level>
                    <version>${VER}</version>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-bigquery</artifactId>
            <version>v2-rev208-1.20.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.9.20</version>
        </dependency>

        <!-- test-->
        <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>1.9.25</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>1.9.25</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>gcloud-maven-plugin</artifactId>
            <version>2.0.9.72.v20150804</version>
        </dependency>
        </dependencies>
</project>

There is a appengine-web.xml in the WEB-INF folder:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

    <application>selectmediaqa</application>

    <module>default</module>

    <version>1-0-8-5</version>

    <!--Allows App Engine to send multiple requests to one instance in parallel: -->
    <threadsafe>true</threadsafe>

    <!--Enable The MySQL Connector/J Google App Engine: -->
    <use-google-connector-j>true</use-google-connector-j>

    <!-- Configure java.util.logging -->
    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
    </system-properties>

    <instance-class>F1</instance-class>
    <automatic-scaling>
        <min-idle-instances>1</min-idle-instances> <!-- ‘automatic’ is the default value. -->
        <max-idle-instances>2</max-idle-instances> <!-- ‘automatic’ is the default value. -->
        <min-pending-latency>1000ms</min-pending-latency>
        <max-pending-latency>automatic</max-pending-latency>
        <max-concurrent-requests>10</max-concurrent-requests>
    </automatic-scaling>

    <!-- HTTP Sessions are disabled by default. To enable HTTP sessions specify: 
        <sessions-enabled>true</sessions-enabled> It's possible to reduce request 
        latency by configuring your application to asynchronously write HTTP session 
        data to the datastore: <async-session-persistence enabled="true" /> With 
        this feature enabled, there is a very small chance your app will see stale 
        session data. For details, see http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions 
    -->

</appengine-web-app>
ludoch commented 8 years ago

I see Server/Cloud/selectmediaservers

do you have under it: src/main/webapp/WEB-INF/appengine-web.xml ?

ludoch commented 8 years ago

haha I see this:${project.basedir}/Server/Cloud/selectmediaservers/war/WEB-INF/appengine-web.xml so it is not where the plugin expects it... I need to fix that. Also, I see you are mixing gae versions (1.9.22, 1.9.25, 1.9.20): it would be best to depend only on a single (latest 1.9.28) Also, I see a old maven plugin dep: 2.0.9.72.v20150804 for test? Not sure why. Anyway, I think I understand the issue

spark2ignite commented 8 years ago

Indeed, here is where the appengine-web.xml is:

screen shot 2015-11-13 at 07 48 51

The 2.0.9.72.v20150804 version is used for test only. We need to fix mixing GAE versions.

Looking forward for a fix,

Thanks!

ludoch commented 8 years ago

We should have a fix ver soon. Thanks a lot for sharing the pom!

ludoch commented 8 years ago

will push the fix in version 2.0.9.86.v20151113 might be reachable later today, pending maven repos caching update.

spark2ignite commented 8 years ago

Awesome! Thanks a lot!

ludoch commented 8 years ago

Let me know when it works for you.

ludoch commented 8 years ago

I see it now at https://repo1.maven.org/maven2/com/google/appengine/gcloud-maven-plugin/2.0.9.86.v20151113/

JamesXNelson commented 8 years ago

Big +1 for the comment on required <packaging>war</packaging>; I had adapted another module and forget to twiddle that bit.

Thx.

JamesXNelson commented 8 years ago

Perhaps there can be an extra warning emitted if app.yaml has env: 2 then check if appengine-web.xml exists, and pom is using jar packaging.

ludoch commented 8 years ago

It seems you are using an old plugin version... Which version do you see in the pom.xml? Latest is 2.0.9.90.v20151210 or above... I't a good idea to keep updating to the latest one possible as the Cloud SDK +Maven plugin is still under active development.

On Sat, Jan 9, 2016 at 6:35 AM, James Nelson notifications@github.com wrote:

Perhaps there can be an extra warning emitted if app.yaml has env: 2 and appengine-web.xml both exist?

— Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gcloud-maven-plugin/issues/61#issuecomment-170243888 .

JamesXNelson commented 8 years ago

I am using that version (.90) with <packaging>war</packaging>, and it works perfectly for me.