On Tue, May 26, 2015 at 2:12 PM, Rajkumar Rajaratnam <rajkum...@wso2.com> wrote:
> I found that network partitions can be removed even if they are used in an > application. Better to fix this. > This can be fixed using getApplications() and getApplicationNetworkPartitions(String applicationId) web service of AS. I attached a sample fix. Please improve/test and commit. Thanks. > > Thanks. > > On Tue, May 26, 2015 at 2:08 PM, Imesh Gunaratne <im...@apache.org> wrote: > >> I did an end to end test with Kubernetes, single-cartridge application >> and found the below error in PCA when un-deploying the application: >> >> [2015-05-26 06:44:40,038] ERROR {eventsubscriber.py:run} - Error >> processing 'ApplicationSignUpRemovedEvent' event >> Traceback (most recent call last): >> File >> "/mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/modules/subscriber/eventsubscriber.py", >> line 103, in run >> handler(event_msg) >> File "agent.py", line 294, in on_application_signup_removed >> self.__event_handler.on_application_signup_removed_event(event_obj) >> File >> "/mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/modules/event/eventhandler.py", >> line 351, in on_application_signup_removed_event >> " [application ID] " + application_signup_removal_event.applicationId >> TypeError: cannot concatenate 'str' and 'int' objects >> >> On Mon, May 25, 2015 at 4:10 PM, Lahiru Sandaruwan <lahi...@wso2.com> >> wrote: >> >>> Hi All, >>> >>> This thread is for discussion of the second release candidate of Apache >>> Stratos 4.1.0. Please use this thread for discussion of issues >>> uncovered in the RC, questions you may have about the RC, etc. >>> >>> *RC release packs:* >>> *https://dist.apache.org/repos/dist/dev/stratos/4.1.0-rc2/ >>> <https://dist.apache.org/repos/dist/dev/stratos/4.1.0-rc2/>* >>> >>> *The tag to be voted upon:* >>> >>> https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=commit;h=c3122516b83039552606f3baaa55fbcf95511162 >>> >>> *Git tag (4.1.0-rc2) tree view:* >>> >>> https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=tree;h=d1c97b1b68a04b1b7f8811034e096f0c7a95e0e4;hb=c3122516b83039552606f3baaa55fbcf95511162 >>> >>> *Stratos KEYS file containing PGP keys we use to sign the release:* >>> https://dist.apache.org/repos/dist/dev/stratos/4.1.0-rc2/KEYS >>> >>> Thanks. >>> >>> -- >>> -- >>> Lahiru Sandaruwan >>> Committer and PMC member, Apache Stratos, >>> Senior Software Engineer, >>> WSO2 Inc., http://wso2.com >>> lean.enterprise.middleware >>> >>> phone: +94773325954 >>> email: lahi...@wso2.com blog: http://lahiruwrites.blogspot.com/ >>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146 >>> >>> >> >> >> -- >> Imesh Gunaratne >> >> Senior Technical Lead, WSO2 >> Committer & PMC Member, Apache Stratos >> > > > > -- > Rajkumar Rajaratnam > Committer & PMC Member, Apache Stratos > Software Engineer, WSO2 > > Mobile : +94777568639 > Blog : rajkumarr.com > -- Rajkumar Rajaratnam Committer & PMC Member, Apache Stratos Software Engineer, WSO2 Mobile : +94777568639 Blog : rajkumarr.com
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index dbcf072..181ea7b 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -2616,9 +2616,30 @@ public class StratosApiV41Utils { public static void removeNetworkPartition(String networkPartitionId) throws RestAPIException, CloudControllerServiceNetworkPartitionNotExistsExceptionException { try { + ApplicationContext[] applicationContexts = AutoscalerServiceClient.getInstance().getApplications(); + if (applicationContexts != null) { + for (ApplicationContext applicationContext : applicationContexts) { + if (applicationContext != null) { + String[] networkPartitions = AutoscalerServiceClient.getInstance().getApplicationNetworkPartitions(applicationContext.getApplicationId()); + if (networkPartitions != null) { + for (int i = 0; i < networkPartitions.length; i++) { + if (networkPartitions[i] == networkPartitionId) { + String message = String.format("Cannot remove the network partition %s, since it is used in some applications", networkPartitionId); + log.error(message); + throw new RestAPIException(message); + } + } + } + } + } + } CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance(); serviceClient.removeNetworkPartition(networkPartitionId); - } catch (RemoteException e) { + } catch (AutoscalerServiceAutoScalerExceptionException e) { + String message = e.getMessage(); + log.error(message); + throw new RestAPIException(message, e); + } catch (RemoteException e) { String message = e.getMessage(); log.error(message); throw new RestAPIException(message, e);