Skip to content

Commit

Permalink
Merge pull request #310 from tremes/hostsubnet
Browse files Browse the repository at this point in the history
Bug 1915188: Remove HostSubnet anonymization
  • Loading branch information
openshift-merge-robot committed Jan 12, 2021
2 parents 710c942 + bcc8009 commit f768b31
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 142 deletions.
Expand Up @@ -2,21 +2,21 @@
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-iffptmb-f76d1-nhwgd-master-0",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-iffptmb-f76d1-nhwgd-master-0",
"uid": "ba02b433-fe1c-4558-bc30-47c1245cc7e8",
"resourceVersion": "3259",
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-master-0",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-master-0",
"uid": "66cb1cad-f8d8-4467-a19d-26462eb75c1f",
"resourceVersion": "3424",
"generation": 1,
"creationTimestamp": "2020-12-02T13:47:00Z",
"creationTimestamp": "2021-01-12T07:57:08Z",
"annotations": {
"pod.network.openshift.io/node-uid": "d392507b-5c7f-4332-8400-f0cb3ae2ea13"
"pod.network.openshift.io/node-uid": "3829f864-4ae3-4ed4-b3da-fc7be1c25ede"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2020-12-02T13:47:00Z",
"time": "2021-01-12T07:57:08Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
Expand All @@ -32,7 +32,7 @@
}
]
},
"host": "ci-ln-iffptmb-f76d1-nhwgd-master-0",
"hostIP": "xxxxxxxx",
"subnet": "xxxxxxxxxxxxx"
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-master-0",
"hostIP": "10.0.0.4",
"subnet": "10.130.0.0/23"
}
Expand Up @@ -2,21 +2,21 @@
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-iffptmb-f76d1-nhwgd-master-1",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-iffptmb-f76d1-nhwgd-master-1",
"uid": "8fb03f7e-daee-4ee7-85ea-c9e593f1df45",
"resourceVersion": "3300",
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-master-1",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-master-1",
"uid": "32f1dd3a-f095-41dc-a898-92764a13d7ed",
"resourceVersion": "3390",
"generation": 1,
"creationTimestamp": "2020-12-02T13:47:01Z",
"creationTimestamp": "2021-01-12T07:57:07Z",
"annotations": {
"pod.network.openshift.io/node-uid": "ac4124f9-6413-43b7-874f-143d28d26515"
"pod.network.openshift.io/node-uid": "41c67588-d3ea-4613-a57b-fb2d481a0436"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2020-12-02T13:47:01Z",
"time": "2021-01-12T07:57:07Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
Expand All @@ -32,7 +32,7 @@
}
]
},
"host": "ci-ln-iffptmb-f76d1-nhwgd-master-1",
"hostIP": "xxxxxxxx",
"subnet": "xxxxxxxxxxxxx"
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-master-1",
"hostIP": "10.0.0.5",
"subnet": "10.129.0.0/23"
}
Expand Up @@ -2,21 +2,21 @@
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-iffptmb-f76d1-nhwgd-master-2",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-iffptmb-f76d1-nhwgd-master-2",
"uid": "f4ee1029-f09c-42cf-a2ef-2a10361de269",
"resourceVersion": "3284",
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-master-2",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-master-2",
"uid": "d98cb801-bff4-440d-a8cb-366fbd05c52a",
"resourceVersion": "3366",
"generation": 1,
"creationTimestamp": "2020-12-02T13:47:01Z",
"creationTimestamp": "2021-01-12T07:57:07Z",
"annotations": {
"pod.network.openshift.io/node-uid": "c12a71e5-ec7e-4534-99b0-fdd027d74460"
"pod.network.openshift.io/node-uid": "ebe27b4e-8bca-4350-b3fa-f61c57e8df41"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2020-12-02T13:47:01Z",
"time": "2021-01-12T07:57:07Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
Expand All @@ -32,7 +32,7 @@
}
]
},
"host": "ci-ln-iffptmb-f76d1-nhwgd-master-2",
"hostIP": "xxxxxxxx",
"subnet": "xxxxxxxxxxxxx"
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-master-2",
"hostIP": "10.0.0.3",
"subnet": "10.128.0.0/23"
}
Expand Up @@ -2,21 +2,21 @@
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-iffptmb-f76d1-nhwgd-worker-b-56nwr",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-iffptmb-f76d1-nhwgd-worker-b-56nwr",
"uid": "dd0abb76-6e1f-4e86-b8c1-4047d1d4da51",
"resourceVersion": "17494",
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-b-q59xn",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-worker-b-q59xn",
"uid": "fe6b6d51-bbea-4ab5-9f28-3f4e764e7082",
"resourceVersion": "18347",
"generation": 1,
"creationTimestamp": "2020-12-02T13:55:23Z",
"creationTimestamp": "2021-01-12T08:05:03Z",
"annotations": {
"pod.network.openshift.io/node-uid": "98b24621-4b5a-41fe-82a8-c5992f66662d"
"pod.network.openshift.io/node-uid": "75cdc5fb-5d09-4b73-9ac7-0adaffda5f94"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2020-12-02T13:55:23Z",
"time": "2021-01-12T08:05:03Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
Expand All @@ -32,7 +32,7 @@
}
]
},
"host": "ci-ln-iffptmb-f76d1-nhwgd-worker-b-56nwr",
"hostIP": "xxxxxxxxx",
"subnet": "xxxxxxxxxxxxx"
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-b-q59xn",
"hostIP": "10.0.32.2",
"subnet": "10.129.2.0/23"
}
@@ -0,0 +1,38 @@
{
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-c-7wf2t",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-worker-c-7wf2t",
"uid": "51000dc6-803d-4371-97a5-6b18f077ccbf",
"resourceVersion": "16216",
"generation": 1,
"creationTimestamp": "2021-01-12T08:03:43Z",
"annotations": {
"pod.network.openshift.io/node-uid": "69a66671-6526-4045-8e3f-910a51855c0a"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2021-01-12T08:03:43Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
"f:hostIP": {},
"f:metadata": {
"f:annotations": {
".": {},
"f:pod.network.openshift.io/node-uid": {}
}
},
"f:subnet": {}
}
}
]
},
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-c-7wf2t",
"hostIP": "10.0.32.3",
"subnet": "10.131.0.0/23"
}
@@ -0,0 +1,38 @@
{
"kind": "HostSubnet",
"apiVersion": "network.openshift.io/v1",
"metadata": {
"name": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-d-7jz4q",
"selfLink": "/apis/network.openshift.io/v1/hostsubnets/ci-ln-h9vpcgk-f76d1-8zsf5-worker-d-7jz4q",
"uid": "d9dbd4aa-f4d3-4281-81dd-96d7e479ec6f",
"resourceVersion": "17300",
"generation": 1,
"creationTimestamp": "2021-01-12T08:04:31Z",
"annotations": {
"pod.network.openshift.io/node-uid": "de6cbeb6-1457-4074-8175-b0b9cc08d56b"
},
"managedFields": [
{
"manager": "openshift-sdn-controller",
"operation": "Update",
"apiVersion": "network.openshift.io/v1",
"time": "2021-01-12T08:04:31Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:host": {},
"f:hostIP": {},
"f:metadata": {
"f:annotations": {
".": {},
"f:pod.network.openshift.io/node-uid": {}
}
},
"f:subnet": {}
}
}
]
},
"host": "ci-ln-h9vpcgk-f76d1-8zsf5-worker-d-7jz4q",
"hostIP": "10.0.32.4",
"subnet": "10.128.2.0/23"
}

This file was deleted.

This file was deleted.

11 changes: 1 addition & 10 deletions pkg/gather/clusterconfig/host_subnets.go
Expand Up @@ -48,20 +48,11 @@ func gatherHostSubnet(ctx context.Context, networkClient networkv1client.Network
return records, nil
}

// HostSubnetAnonymizer implements HostSubnet serialization wiht anonymization
// HostSubnetAnonymizer implements HostSubnet serialization
type HostSubnetAnonymizer struct{ networkv1.HostSubnet }

// Marshal implements HostSubnet serialization
func (a HostSubnetAnonymizer) Marshal(_ context.Context) ([]byte, error) {
a.HostSubnet.HostIP = anonymizeString(a.HostSubnet.HostIP)
a.HostSubnet.Subnet = anonymizeString(a.HostSubnet.Subnet)

for i, s := range a.HostSubnet.EgressIPs {
a.HostSubnet.EgressIPs[i] = networkv1.HostSubnetEgressIP(anonymizeString(string(s)))
}
for i, s := range a.HostSubnet.EgressCIDRs {
a.HostSubnet.EgressCIDRs[i] = networkv1.HostSubnetEgressCIDR(anonymizeString(string(s)))
}
return runtime.Encode(networkSerializer.LegacyCodec(networkv1.SchemeGroupVersion), &a.HostSubnet)
}

Expand Down
20 changes: 4 additions & 16 deletions pkg/gather/clusterconfig/host_subnets_test.go
Expand Up @@ -39,11 +39,11 @@ func TestGatherHostSubnet(t *testing.T) {
if err != nil {
t.Fatalf("failed to decode object: %v", err)
}
if gatheredHostSubnet.HostIP != "xxxxxxxx" {
t.Fatalf("Host IP is not anonymized %s", gatheredHostSubnet.HostIP)
if gatheredHostSubnet.HostIP != testHostSubnet.HostIP {
t.Fatalf("Unexpected Host IP value %s", gatheredHostSubnet.HostIP)
}
if gatheredHostSubnet.Subnet != "xxxxxxxxxxx" {
t.Fatalf("Host Subnet is not anonymized %s", gatheredHostSubnet.Subnet)
if gatheredHostSubnet.Subnet != testHostSubnet.Subnet {
t.Fatalf("Unexpected Subnet value %s", gatheredHostSubnet.Subnet)
}
if len(gatheredHostSubnet.EgressIPs) != len(testHostSubnet.EgressIPs) {
t.Fatalf("unexpected number of egress IPs gathered %s", gatheredHostSubnet.EgressIPs)
Expand All @@ -52,16 +52,4 @@ func TestGatherHostSubnet(t *testing.T) {
if len(gatheredHostSubnet.EgressCIDRs) != len(testHostSubnet.EgressCIDRs) {
t.Fatalf("unexpected number of egress CIDRs gathered %s", gatheredHostSubnet.EgressCIDRs)
}

for _, ip := range gatheredHostSubnet.EgressIPs {
if ip != "xxxxxxxx" {
t.Fatalf("Egress IP is not anonymized %s", ip)
}
}

for _, cidr := range gatheredHostSubnet.EgressCIDRs {
if cidr != "xxxxxxxxxxx" {
t.Fatalf("Egress CIDR is not anonymized %s", cidr)
}
}
}

0 comments on commit f768b31

Please sign in to comment.