Skip to content

Commit

Permalink
Remove Ingress type from healthcheck description
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSawicki committed Apr 18, 2023
1 parent 181f768 commit ac70f99
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 35 deletions.
6 changes: 0 additions & 6 deletions pkg/healthchecks/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,10 @@ func (h *HealthChecks) generateHealthcheckInfo(sp utils.ServicePort, iLB bool) h
serviceInfo = healthcheck.ServiceInfo(sp.ID.Service)
}

ingressType := healthcheck.ExternalLB
if iLB {
ingressType = healthcheck.InternalLB
}

return healthcheck.HealthcheckInfo{
ClusterInfo: h.clusterInfo,
ServiceInfo: serviceInfo,
HealthcheckConfig: healthcheck.DefaultHC,
IngressType: ingressType,
}
}

Expand Down
21 changes: 7 additions & 14 deletions pkg/healthchecks/healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,9 @@ func TestRolloutUpdateCustomHCDescription(t *testing.T) {
outputBCHCWithFlag := getSingletonHealthcheck(t, fakeGCE)

wantDesc := healthcheck.HealthcheckDesc{
K8sCluster: fmt.Sprintf("/locations/%s/clusters/%s", gce.DefaultTestClusterValues().Region, gce.DefaultTestClusterValues().ClusterName),
K8sResource: fmt.Sprintf("/namespaces/%s/services/%s", defaultBackendSvc.Namespace, defaultBackendSvc.Name),
K8sResourceDependency: "Ingress External Load Balancer",
Config: "BackendConfig",
K8sCluster: fmt.Sprintf("/locations/%s/clusters/%s", gce.DefaultTestClusterValues().Region, gce.DefaultTestClusterValues().ClusterName),
K8sResource: fmt.Sprintf("/namespaces/%s/services/%s", defaultBackendSvc.Namespace, defaultBackendSvc.Name),
Config: "BackendConfig",
}
bytes, err := json.MarshalIndent(wantDesc, "", " ")
if err != nil {
Expand Down Expand Up @@ -1373,22 +1372,16 @@ func TestSyncServicePort(t *testing.T) {
tc.desc = tc.desc + " with updateHCDescription"
copyOfWant := *tc.wantComputeHC
if tc.sp.BackendConfig != nil {
var wantLocation, wantIngressType string
var wantLocation string
if tc.regionalCluster {
wantLocation = gce.DefaultTestClusterValues().Region
} else {
wantLocation = gce.DefaultTestClusterValues().ZoneName
}
if tc.sp.L7ILBEnabled {
wantIngressType = "Ingress Internal Load Balancer"
} else {
wantIngressType = "Ingress External Load Balancer"
}
wantDesc := healthcheck.HealthcheckDesc{
K8sCluster: fmt.Sprintf("/locations/%s/clusters/%s", wantLocation, gce.DefaultTestClusterValues().ClusterName),
K8sResource: fmt.Sprintf("/namespaces/%s/services/%s", defaultBackendSvc.Namespace, defaultBackendSvc.Name),
K8sResourceDependency: healthcheck.IngressType(wantIngressType),
Config: "BackendConfig",
K8sCluster: fmt.Sprintf("/locations/%s/clusters/%s", wantLocation, gce.DefaultTestClusterValues().ClusterName),
K8sResource: fmt.Sprintf("/namespaces/%s/services/%s", defaultBackendSvc.Namespace, defaultBackendSvc.Name),
Config: "BackendConfig",
}
bytes, err := json.MarshalIndent(wantDesc, "", " ")
if err != nil {
Expand Down
16 changes: 3 additions & 13 deletions pkg/utils/healthcheck/healthcheckdesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,16 @@ const (
BackendConfigHC HealthcheckConfig = "BackendConfig"
)

type IngressType string

const (
InternalLB IngressType = "Ingress Internal Load Balancer"
ExternalLB IngressType = "Ingress External Load Balancer"
)

type HealthcheckInfo struct {
ClusterInfo
ServiceInfo
HealthcheckConfig
IngressType
}

type HealthcheckDesc struct {
K8sCluster string
K8sResource string
K8sResourceDependency IngressType
Config HealthcheckConfig
K8sCluster string
K8sResource string
Config HealthcheckConfig
}

func (i *ClusterInfo) generateClusterDescription() string {
Expand All @@ -80,7 +71,6 @@ func (i *HealthcheckInfo) GenerateHealthcheckDescription() string {
desc := HealthcheckDesc{}
desc.K8sCluster = i.ClusterInfo.generateClusterDescription()
desc.K8sResource = i.ServiceInfo.generateK8sResourceDescription()
desc.K8sResourceDependency = i.IngressType
desc.Config = i.HealthcheckConfig
json, err := json.MarshalIndent(desc, "", " ")
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/utils/healthcheck/healthcheckdesc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ func TestGenerateHealthcheckDescription(t *testing.T) {
ClusterInfo: clusterInfo,
ServiceInfo: serviceInfo,
HealthcheckConfig: hcConfig,
IngressType: InternalLB,
}
expectedDescription := "" +
"{\n" +
" \"K8sCluster\": \"/locations/pl-central7/clusters/cluster-name\",\n" +
" \"K8sResource\": \"/namespaces/testNamespace/services/service-name\",\n" +
" \"K8sResourceDependency\": \"Ingress Internal Load Balancer\",\n" +
" \"Config\": \"Default\"\n" +
"}"

Expand Down

0 comments on commit ac70f99

Please sign in to comment.