Skip to content

Commit

Permalink
fix bug where maintenance exclusions were not set independently
Browse files Browse the repository at this point in the history
  • Loading branch information
dantiandb committed Oct 17, 2023
1 parent ea2fa6d commit b638509
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
properties:
addonsConfig:
description: AddonsConfig represents the configuration options for
GKE cluster add ons.
GKE cluster add-ons.
properties:
dnsCacheConfig:
description: DNSCacheConfig represents a configuration for NodeLocalDNS,
Expand Down Expand Up @@ -424,7 +424,7 @@ spec:
workloadIdentityConfig:
description: WorkloadIdentityConfig represents configuration options
for the use of Kubernetes Service Accounts in GCP IAM policies.
This feature is diabled if this field is not specified.
This feature is disabled if this field is not specified.
properties:
workloadPool:
description: WorkloadPool represents the node pool to attach all
Expand Down
6 changes: 3 additions & 3 deletions exp/api/v1beta1/gcpmanagedcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type GCPManagedControlPlaneSpec struct {
// Endpoint represents the endpoint used to communicate with the control plane.
// +optional
Endpoint clusterv1.APIEndpoint `json:"endpoint"`
// AddonsConfig represents the configuration options for GKE cluster add ons.
// AddonsConfig represents the configuration options for GKE cluster add-ons.
// +optional
AddonsConfig *AddonsConfig `json:"addonsConfig,omitempty"`
// LoggingConfig represents the configuration options for GKE cluster logging.
Expand All @@ -79,7 +79,7 @@ type GCPManagedControlPlaneSpec struct {
// +optional
PrivateClusterConfig *PrivateClusterConfig `json:"privateClusterConfig,omitempty"`
// WorkloadIdentityConfig represents configuration options for the use of Kubernetes Service Accounts in GCP IAM
// policies. This feature is diabled if this field is not specified.
// policies. This feature is disabled if this field is not specified.
// +optional
WorkloadIdentityConfig *WorkloadIdentityConfig `json:"workloadIdentityConfig,omitempty"`
// ResourceLabels represents the resource labels for the GKE cluster to use to annotate any related
Expand Down Expand Up @@ -279,7 +279,7 @@ const (
NoMinorOrNodeUpgrades MaintenanceExclusionOption = "no-minor-or-node-upgrades"
)

// AddonsConfig contains configurations for various add ons available to run in the GKE cluster.
// AddonsConfig contains configurations for various add-ons available to run in the GKE cluster.
type AddonsConfig struct {
// DNSCacheConfig represents a configuration for NodeLocalDNS, a dns cache running on GKE cluster nodes
// If omitted it is disabled by default.
Expand Down
37 changes: 24 additions & 13 deletions exp/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,23 @@ func ConvertToSdkMaintenancePolicy(policy *MaintenancePolicy) (*containerpb.Main
}
exclusions[k] = tw
}
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
MaintenanceExclusions: exclusions,
}
}

if policy.DailyMaintenanceWindow != nil {
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
Policy: &containerpb.MaintenanceWindow_DailyMaintenanceWindow{
DailyMaintenanceWindow: &containerpb.DailyMaintenanceWindow{
StartTime: policy.DailyMaintenanceWindow.StartTime,
},
dailyMaintenanceWindowPolicy := &containerpb.MaintenanceWindow_DailyMaintenanceWindow{
DailyMaintenanceWindow: &containerpb.DailyMaintenanceWindow{
StartTime: policy.DailyMaintenanceWindow.StartTime,
},
MaintenanceExclusions: exclusions,
}
if maintenancePolicy.Window == nil {
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
Policy: dailyMaintenanceWindowPolicy,
}
} else {
maintenancePolicy.Window.Policy = dailyMaintenanceWindowPolicy
}
}

Expand All @@ -209,14 +216,18 @@ func ConvertToSdkMaintenancePolicy(policy *MaintenancePolicy) (*containerpb.Main
if err != nil {
return nil, err
}
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
Policy: &containerpb.MaintenanceWindow_RecurringWindow{
RecurringWindow: &containerpb.RecurringTimeWindow{
Window: tw,
Recurrence: policy.RecurringMaintenanceWindow.Recurrence,
},
recurringWindowPolicy := &containerpb.MaintenanceWindow_RecurringWindow{
RecurringWindow: &containerpb.RecurringTimeWindow{
Window: tw,
Recurrence: policy.RecurringMaintenanceWindow.Recurrence,
},
MaintenanceExclusions: exclusions,
}
if maintenancePolicy.Window == nil {
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
Policy: recurringWindowPolicy,
}
} else {
maintenancePolicy.Window.Policy = recurringWindowPolicy
}
}

Expand Down

0 comments on commit b638509

Please sign in to comment.