Skip to content

Commit fd5f64d

Browse files
authored
Merge pull request #625 from kisieland/img-link-search
Support owner references that point directly to instanceGroupManagers.
2 parents 9da0573 + 2e46568 commit fd5f64d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

cmd/gcp-controller-manager/node_csr_approver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,11 @@ func checkInstanceReferrers(ctx *controllerContext, instance *compute.Instance,
743743
for _, ig := range clusterInstanceGroupUrls {
744744
// GKE's cluster.NodePools[].instanceGroupUrls are of the form:
745745
// https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instanceGroupManagers/instance-group-1.
746-
// Where as instance referrers are of the form:
746+
// Where as instance referrers are one of the forms:
747+
// https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instanceGroupManagers/instance-group-1.
747748
// https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instanceGroups/instance-group-1.
748-
// With the string replace below we convert them to the same form.
749+
// We pass the string as it is for the first kind and use a string replace below we convert them to the second form.
750+
clusterInstanceGroupMap[ig] = true
749751
clusterInstanceGroupMap[strings.Replace(ig, "/instanceGroupManagers/", "/instanceGroups/", 1)] = true
750752
}
751753

cmd/gcp-controller-manager/node_csr_approver_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,29 @@ func TestCheckInstanceReferrersBackOff(t *testing.T) {
14611461
},
14621462
wantOK: true,
14631463
},
1464+
{
1465+
desc: "match found for instanceGroupManagers",
1466+
clusterInstanceGroupUrls: []string{
1467+
"https://www.googleapis.com/compute/v1/projects/p1/zones/z1/instanceGroupManagers/ig1",
1468+
},
1469+
instance: &compute.Instance{
1470+
Name: "i1",
1471+
Zone: "https://www.googleapis.com/compute/v1/projects/p1/zones/z1",
1472+
},
1473+
projectID: "z1",
1474+
gceClientHandler: func() func(rw http.ResponseWriter, req *http.Request) {
1475+
return func(rw http.ResponseWriter, req *http.Request) {
1476+
json.NewEncoder(rw).Encode(compute.InstanceListReferrers{
1477+
Items: []*compute.Reference{
1478+
{
1479+
Referrer: "https://www.googleapis.com/compute/v1/projects/p1/zones/z1/instanceGroupManagers/ig1",
1480+
},
1481+
},
1482+
})
1483+
}
1484+
},
1485+
wantOK: true,
1486+
},
14641487
{
14651488
desc: "match not found",
14661489
clusterInstanceGroupUrls: []string{

0 commit comments

Comments
 (0)