-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tolerate non zonal NEG included in the AggregatedList API response #820
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,23 @@ limitations under the License. | |
package types | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" | ||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" | ||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" | ||
"google.golang.org/api/compute/v1" | ||
"k8s.io/klog" | ||
"k8s.io/legacy-cloud-providers/gce" | ||
) | ||
|
||
const ( | ||
// aggregatedListZonalKeyPrefix is the prefix for the zonal key from AggregatedList | ||
aggregatedListZonalKeyPrefix = "zones" | ||
// aggregatedListGlobalKey is the global key from AggregatedList | ||
aggregatedListGlobalKey = "global" | ||
) | ||
|
||
// NewAdapter takes a Cloud and returns a NetworkEndpointGroupCloud. | ||
func NewAdapter(g *gce.Cloud) NetworkEndpointGroupCloud { | ||
return &cloudProviderAdapter{ | ||
|
@@ -72,10 +79,19 @@ func (a *cloudProviderAdapter) AggregatedListNetworkEndpointGroup() (map[string] | |
} | ||
ret := map[string][]*compute.NetworkEndpointGroup{} | ||
for key, byZone := range all { | ||
// key is "zones/<zone name>" | ||
// key is scope | ||
// zonal key is "zones/<zone name>" | ||
// regional key is "regions/<region name>" | ||
// global key is "global" | ||
// TODO: use cloud provider meta.KeyType and scope name as key | ||
parts := strings.Split(key, "/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log.V(4) the parts |
||
if len(parts) != 2 { | ||
return nil, fmt.Errorf("invalid key for AggregatedListNetworkEndpointGroup: %q", key) | ||
if len(parts) == 1 && parts[0] == aggregatedListGlobalKey { | ||
klog.V(4).Infof("Ignoring key %q as it is global", key) | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should log at level V(3) |
||
} | ||
if len(parts) != 2 || parts[0] != aggregatedListZonalKeyPrefix { | ||
klog.Warningf("Key %q is not in a known format, ignoring", key) | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should definitely be logged as a warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning |
||
} | ||
zone := parts[1] | ||
ret[zone] = append(ret[zone], byZone...) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a documentation link