private async Task <GetClusterResult> GetClusterFromCloudServiceResource(CloudService cloudService, Resource clusterResource) { var clusterDetails = PayloadConverterClusters.CreateClusterDetailsFromRdfeResourceOutput( cloudService.GeoRegion, clusterResource); HDInsight.ClusterState clusterState = clusterDetails.State; Cluster clusterFromGetClusterCall = null; if (clusterState != HDInsight.ClusterState.Deleting && clusterState != HDInsight.ClusterState.DeletePending) { //we want to poll if we are either in error or unknown state. //this is so that we can get the extended error information. try { clusterFromGetClusterCall = this.SafeGetDataFromPassthroughResponse <Cluster>( await this.rdfeClustersRestClient.GetCluster( this.credentials.SubscriptionId.ToString(), this.GetCloudServiceName(cloudService.GeoRegion), this.credentials.DeploymentNamespace, clusterResource.Name, this.Context.CancellationToken)); clusterDetails = PayloadConverterClusters.CreateClusterDetailsFromGetClustersResult(clusterFromGetClusterCall); } catch (InvalidExpectedStatusCodeException ie) { //if we got a not found back that we means the RP has no record of this cluster. //It would happen if one of the basic validations fail, cluster dns name uniqueness if (ie.ReceivedStatusCode == HttpStatusCode.NotFound) { //We may sometimes have a record of the cluster on the server, //which means we can populate extended error information } } } clusterDetails.SubscriptionId = this.credentials.SubscriptionId; return(new GetClusterResult(clusterDetails, clusterFromGetClusterCall)); }
private async Task <GetIaasClusterResult> GetIaasClusterFromCloudServiceResource(CloudService cloudService, Resource clusterResource) { var clusterDetails = PayloadConverterIaasClusters.CreateClusterDetailsFromRdfeResourceOutput(cloudService.GeoRegion, clusterResource); HDInsight.ClusterState clusterState = clusterDetails.State; IaasCluster clusterFromGetClusterCall = null; if (clusterState != HDInsight.ClusterState.Deleting && clusterState != HDInsight.ClusterState.DeletePending) { //we want to poll if we are either in error or unknown state. //this is so that we can get the extended error information. try { PassthroughResponse response = await this.rdfeRestClient.GetCluster( this.credentials.SubscriptionId.ToString(), this.GetCloudServiceName(cloudService.GeoRegion), this.credentials.DeploymentNamespace, clusterResource.Name, this.Context.CancellationToken); clusterFromGetClusterCall = this.SafeGetDataFromPassthroughResponse <IaasCluster>(response); clusterDetails = PayloadConverterIaasClusters.CreateClusterDetailsFromGetClustersResult(clusterFromGetClusterCall); } catch (Exception) { // Ignore all exceptions. We don't want ListContainers to fail on customers for whatever reason. // If there is an issue with obtaining details about the cluster, mark the cluster in Error state with a generic error message clusterDetails.State = ClusterState.Error; if (clusterDetails.Error != null && string.IsNullOrEmpty(clusterDetails.Error.Message)) { clusterDetails.Error.Message = "Unexpected error occurred. Could not retrieve details about the cluster."; } } } clusterDetails.SubscriptionId = this.credentials.SubscriptionId; return(new GetIaasClusterResult(clusterDetails, clusterFromGetClusterCall)); }