Earlier this year Python 2 entered End of Life — and Splunk has already released versions of Splunk Cloud and Splunk Enterprise that provide a Python 3 runtime. As the developer of an app that is published to Splunkbase, if your app contains Python code, you need to update it to work with Python 3 and Splunk Enterprise 8.0 by July 1, 2020 as the Splunk Enterprise and Splunk Cloud releases after that date will no longer support the Python 2 runtime. You may be wondering: what is the easiest way to migrate my app and my app’s customers to Python 3 and Splunk 8.0?
You can of course upgrade your app directly to Python 3. If you take this path, your app will only be compatible with Splunk Enterprise 8.0 — customers on Splunk Enterprise 7.x will not be able to use these versions of your app. This means that they will need to follow a more complicated upgrade process in order to update Splunk Enterprise and your app in the future. To help you make an informed decision, you can see how many customers are using your app on specific versions of the Splunk Enterprise platform by consulting the “View Analytics” page of your app’s listing on Splunkbase.
Because of this extra complexity for our shared customers, we strongly recommend creating a release of your app that is cross-compatible with both Python 2 and Python 3 (using libraries like Six, Futurize, or 2to3), with one or more versions of Splunk Enterprise 7.2 or above, and with Splunk Enterprise 8.0. If you take this approach, your customers will simply need to update their installation of your app to its latest release, then update their Splunk Cloud installation to 8.0 without having to worry about Python compatibility along the way; the app will just work. You can learn more here about the Splunk Enterprise migration process for Python 3.
Whichever approach you take, Splunk has compiled a handy Python migration checklist for you to use during your upgrade process. The detailed list can be found here. It includes common issues such as:
- Working with and converting between different string types
- New ways of working with integers
- Replacing sorted() for list.sort()
- Impact of module changes
- And more!
Testing Your New Release
If you are following our recommendation above and making your app cross-compatible with both versions of Python, you will need to test your application in at least two Splunk Enterprise test deployments:
- Use a Splunk Enterprise 7.2 or later deployment to test that your app runs as expected with a Python 2 runtime. A Splunk Enterprise 7.2 or later will force your entire application to run in Python 2.
- Use a Splunk Enterprise 8.0 deployment with specific configuration settings to force your application to run in Python
You have two options:
1. Set python.version=python3 in server.conf’s [general] stanza to force all scripts in all applications to run in Python 3 only. You can learn more about using server.conf to force a Python 3 runtime for all scripts in a Splunk Enterprise deployment here.
2. Set python.version=python3 in the appropriate stanza of every .conf file that specifies Python scripts in your application. You can learn more about using script-level Python interpreter settings here.
If you are creating an app that only runs in Python 3, you will only need a test environment for Splunk Enterprise 8.0.
Note: Keep in mind that if your app uses Python that runs in the appserver, such as in the module system, you will not be able to select which Python runtime will be used for these scripts. Splunk Enterprise versions previous to Splunk Enterprise 8.0 will always attempt to run these scripts with Python 2, and Splunk Enterprise 8.0 will always attempt to run these scripts with Python 3. More information is available here. Because of this, any app that you upload to Splunkbase and flag as 8.0 compatible must be Python 3 compatible.
Validating Your New Release
You can use the following Splunk-built tools to validate that your app is ready for Splunk Enterprise 8.0. At the same time, to expand your potential user base for your new release, you should also validate your app’s compatibility with Splunk Cloud:
- First, the Splunk Platform Upgrade Readiness App will let you know where exactly in your app you use features of the Splunk Enterprise platform that are deprecated in Splunk 8.0 and which lines of your Python scripts are incompatible with Python 2. Simply install the Splunk Platform Upgrade Readiness App into a local Splunk Enterprise deployment alongside your app to get a report of potential concerns you need to address. Remember: even after using this tool, you will still need to thoroughly test your app with Splunk 8.0 to confirm compatibility. To learn more, check out this link.
- Next, Splunk AppInspect’s API will validate any additional issues your app may encounter with the Splunk Cloud Vetting process. The AppInspect API is the tool that our Cloud Vetting team uses to identify potential security or operational issues in apps that customers want to run in Splunk Cloud. Cloud Vetting approval is required before your app can be installed in Splunk Cloud, so learning about any potential issues before uploading your app to Splunkbase can help you address them earlier. You can learn more about AppInspect here and about the Cloud Vetting process in general here.
Finally, upload the new release of your app to Splunkbase and indicate that it is compatible with Splunk Enterprise 8.0. The process is documented at this link.
If you have any questions, reach out to us at firstname.lastname@example.org
Splunk Python Migration Team