Skip to content

Commit

Permalink
update service list to show correct "success" status for "ExternalNam…
Browse files Browse the repository at this point in the history
…e" (#5010)

* update service list to show correct "success" status when service type is "ExternalName"; patch for #4736

Signed-off-by: mystic knight <techguru@byiq.com>

* reformat code per guidance from CI style checks

Signed-off-by: mystic knight <techguru@byiq.com>

* reformat code per guidance from CI style checks; use switch statement instead of nested if for longer term resilience

Signed-off-by: mystic knight <techguru@byiq.com>

* eliminate fall-through per style guidance from CI

Signed-off-by: mystic knight <techguru@byiq.com>

* eliminate parenthesis per style guidance from CI

Signed-off-by: mystic knight <techguru@byiq.com>
  • Loading branch information
PaulCharlton committed Mar 16, 2020
1 parent b585fea commit 7188d81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/backend/resource/service/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Service struct {
// Label selector of the service.
Selector map[string]string `json:"selector"`

// Type determines how the service will be exposed. Valid options: ClusterIP, NodePort, LoadBalancer
// Type determines how the service will be exposed. Valid options: ClusterIP, NodePort, LoadBalancer, ExternalName
Type v1.ServiceType `json:"type"`

// ClusterIP is usually assigned by the master. Valid values are None, empty string (""), or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,32 @@ export class ServiceListComponent extends ResourceListWithStatuses<ServiceList,
}

isInPendingState(resource: Service): boolean {
return (
!resource.clusterIP ||
(resource.type === 'LoadBalancer' && resource.externalEndpoints.length === 0)
);
return !this.isInSuccessState(resource);
}

/**
* Service is in success state if cluster IP is defined and service type is LoadBalancer and
* external endpoints exist.
* Success state of a Service depends on the type of service
* https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
* ClusterIP: ClusterIP is defined
* NodePort: ClusterIP is defined
* LoadBalancer: ClusterIP is defined __and__ external endpoints exist
* ExternalName: true
*/
isInSuccessState(resource: Service): boolean {
return !this.isInPendingState(resource);
switch (resource.type) {
case 'ExternalName':
return true;
case 'LoadBalancer':
if (resource.externalEndpoints.length === 0) {
return false;
}
break;
case 'ClusterIP':
case 'NodePort':
default:
break;
}
return resource.clusterIP.length > 0;
}

getDisplayColumns(): string[] {
Expand Down

0 comments on commit 7188d81

Please sign in to comment.