Skip to content

Commit

Permalink
Fix issue creating PKS cluster
Browse files Browse the repository at this point in the history
Fix validation of port and worker instances fields
When pks provisioning/destroy task fails notify the caller with STARTED
stage
Set pks properties to compute state when creating a new cluster

Change-Id: Idc6033b628dad0dbea8c996aebce8b947b9e9843
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/38464
Closures-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Lazarin Lazarov <[email protected]>
  • Loading branch information
lazarin committed Jul 13, 2018
1 parent 70ec8ba commit 742d5ab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ private void validate(RequestContext ctx) {
AssertUtil.assertNotNull(cluster.parameters, "cluster parameters");
AssertUtil.assertNotEmpty((String) cluster.parameters.get(PKS_MASTER_HOST_FIELD),
"master host address");
AssertUtil.assertNotEmpty((String) cluster.parameters.get(PKS_MASTER_PORT_FIELD),
AssertUtil.assertNotNull(cluster.parameters.get(PKS_MASTER_PORT_FIELD),
"master host port");
AssertUtil.assertNotEmpty((String) cluster.parameters.get(PKS_WORKER_INSTANCES_FIELD),
AssertUtil.assertNotNull(cluster.parameters.get(PKS_WORKER_INSTANCES_FIELD),
"worker instances");
break;
case RESIZE_CLUSTER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import static java.util.EnumSet.of;

import static com.vmware.admiral.adapter.pks.PKSConstants.PKS_CLUSTER_NAME_PROP_NAME;
import static com.vmware.admiral.adapter.pks.PKSConstants.PKS_CLUSTER_UUID_PROP_NAME;
import static com.vmware.admiral.adapter.pks.PKSConstants.PKS_ENDPOINT_PROP_NAME;

import java.net.HttpURLConnection;
import java.net.URI;
Expand Down Expand Up @@ -651,10 +653,18 @@ private void createHostInCluster(Operation post) {
PropertyUtils.getPropertyString(hostSpec.hostState.customProperties,
ContainerHostService.CUSTOM_PROPERTY_HOST_ALIAS)
.orElse(null));
map.put(PKS_ENDPOINT_PROP_NAME,
PropertyUtils.getPropertyString(hostSpec.hostState.customProperties,
PKS_ENDPOINT_PROP_NAME)
.orElse(null));
map.put(PKS_CLUSTER_NAME_PROP_NAME,
PropertyUtils.getPropertyString(hostSpec.hostState.customProperties,
PKS_CLUSTER_NAME_PROP_NAME)
.orElse(null));
map.put(PKS_CLUSTER_UUID_PROP_NAME,
PropertyUtils.getPropertyString(hostSpec.hostState.customProperties,
PKS_CLUSTER_UUID_PROP_NAME)
.orElse(null));

sendWithDeferredResult(
Operation.createPut(UriUtils.buildUri(getHost(), ContainerHostService.SELF_LINK))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ private void createPKSClusterProvisioningTask(RequestBrokerState state) {
task.documentSelfLink = getSelfId();
task.serviceTaskCallback = ServiceTaskCallback.create(
state.documentSelfLink, TaskStage.STARTED, SubStage.COMPLETED,
TaskStage.FAILED, SubStage.REQUEST_FAILED);
TaskStage.STARTED, SubStage.REQUEST_FAILED);
task.customProperties = state.customProperties;
task.endpointLink = state.getCustomProperty(PKSConstants.PKS_ENDPOINT_PROP_NAME);
task.tenantLinks = state.tenantLinks;
Expand Down Expand Up @@ -1389,7 +1389,7 @@ private void createPKSClusterRemovalTasks(RequestBrokerState state, boolean clea
task.documentSelfLink = getSelfId();
task.serviceTaskCallback = ServiceTaskCallback.create(state.documentSelfLink,
TaskStage.STARTED, errorState ? SubStage.ERROR : SubStage.COMPLETED,
TaskStage.FAILED, SubStage.ERROR);
TaskStage.STARTED, SubStage.ERROR);

task.customProperties = state.customProperties;
task.endpointLink = state.getCustomProperty(PKSConstants.PKS_ENDPOINT_PROP_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption.STORE_ONLY;
import static com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.AUTO_MERGE_IF_NOT_NULL;
import static com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.REQUIRED;
import static com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.SINGLE_ASSIGNMENT;

import java.net.URI;
import java.util.Arrays;
Expand Down Expand Up @@ -63,10 +62,9 @@ public static class PKSClusterRemovalTaskState extends
com.vmware.admiral.service.common.TaskServiceDocument<PKSClusterRemovalTaskState.SubStage> {

/**
* (Required) PKS endpoint self link.
* PKS endpoint self link.
*/
@PropertyOptions(usage = { REQUIRED, SINGLE_ASSIGNMENT, AUTO_MERGE_IF_NOT_NULL },
indexing = STORE_ONLY)
@PropertyOptions(usage = { AUTO_MERGE_IF_NOT_NULL }, indexing = STORE_ONLY)
public String endpointLink;
/**
* (Required) The resource on which the given operation will be applied
Expand Down

0 comments on commit 742d5ab

Please sign in to comment.