3

I try to use AppEngine's modules api for python to obtain the number of instances for a module that uses basic scaling. In my module's yaml file I have explicitly set the max_instances parameter. I expect that get_num_instances() will return that parameter's value.

The problem: Whenever I fire modules.get_num_instances(...), the method raises an InvalidVersionError.

My app has only one version, "v1". The error is raised when I set the version parameter to "v1" or even leave it to None (which according to the documentation takes the current version).

The moment I am calling get_num_instances() there are no active instances in that particular module. Does this make a difference?

I haven't found a way to call this method without raising the error. The issue appears in both GAE and dev_server. I 'm working with SDK version 1.9.18.

Update Here's the yaml file for the module

application: my_gae_app
module: my_module
version: v1
runtime: python27
api_version: 1
threadsafe: true
instance_class: B2
basic_scaling:
  max_instances: 3
  idle_timeout: 1m

inbound_services:
- warmup

skip_files:
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?tests$
- ^(.*/)?test$
- ^Makefile
- ^COPYING.LESSER
- ^README.md
- \.gitignore
- ^\.git/.*
- \.*\.lint$
- ^\localdata/.*

builtins:
- appstats: on #/_ah/stats/
- remote_api: on #/_ah/remote_api/
- deferred: on

handlers:
- url: /.*
  script: my_start_script.the_wsgi_app

libraries:
- name: jinja2
  version: "2.6"
- name: webapp2
  version: "2.5.2"
- name: markupsafe
  version: "0.15"
- name: webob
  version: "1.2.3"
- name: ssl
  version: latest

I 've tried calling get_num_instances() as follows:

  • get_num_instances(module='my_module', version='v1')
  • get_num_instances(module='my_module')
  • get_num_instances()

I also double checked the module name spelling, modules.get_modules() returns the name correctly. I did the same for version, modules.get_current_version_name() returns "v1".

Harshal Patil
  • 6,284
  • 8
  • 37
  • 55
Christos
  • 351
  • 1
  • 10
  • are you sure you're calling it on the right module? the "InvalidVersionError" is as much an indicator of wrong module as it is an indicator of wrong version – Patrice Feb 25 '15 at 14:57
  • I 'm also specifying the module's name passing the 'module' parameter to the method call. – Christos Feb 25 '15 at 15:05
  • could you update your question including the module's yaml configuration? That might help us pin-pointing the problem – marianosimone Feb 25 '15 at 15:42
  • Of course, I 'm sorry for not posting it in the first place. I updated the question. – Christos Feb 25 '15 at 16:25
  • I'm also experiencing the same problem. Even with modules that DO have instances running, I get InvalidVersionError. The only relevant discussion I found about it is: https://groups.google.com/forum/#!topic/google-appengine/PuUMW8aLknQ – marianosimone Feb 25 '15 at 17:39

1 Answers1

0

As stated on source code documentation [1] this method will only work for manual scaling instances. Automatic-scaled instances (including Basic Scaling) will throw that error.

[1] https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/modules/modules.py?r=411#236

Update: I got official confirmation from Google Cloud Support that indeed, this is a simply documentation error so as I assumed on my original answer, get_num_instances is meant to work only on manual scaled instances/modules/versions.

Layo
  • 667
  • 4
  • 15
  • hmm, this is a bit confusing. The online documentation states "Returns the number of instances that have been set for a given module and version. Valid only for manual or basic scaled modules." https://cloud.google.com/appengine/docs/python/modules/functions – Christos Mar 02 '15 at 12:42
  • I may be wrong but sometimes documentation is not up to date. To make sure, you can try reproducing the issue with manual scaling. if still not working this is definitely a bug that you can report on the [public issue tracker](https://code.google.com/p/googleappengine/wiki/FilingIssues?tm=3). – Layo Mar 03 '15 at 14:05
  • Sorry, I haven't had the time yet to test it with manual instances (manual scaling instances don't fit my usage scenario, any tests will be performed out of curiosity, so they are at the bottom of the priority list now). – Christos Mar 21 '15 at 09:27
  • 1
    @Christos I reproduced your issue for Basic Scaling. I tested the same over manual scaling instances and it worked just fine. As a result, I contacted GC Support. Check the update of my answer. – Layo Apr 29 '15 at 15:31