Skip to content

Commit b638509

Browse files
author
dantiandb
committed
fix bug where maintenance exclusions were not set independently
1 parent ea2fa6d commit b638509

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ spec:
6060
properties:
6161
addonsConfig:
6262
description: AddonsConfig represents the configuration options for
63-
GKE cluster add ons.
63+
GKE cluster add-ons.
6464
properties:
6565
dnsCacheConfig:
6666
description: DNSCacheConfig represents a configuration for NodeLocalDNS,
@@ -424,7 +424,7 @@ spec:
424424
workloadIdentityConfig:
425425
description: WorkloadIdentityConfig represents configuration options
426426
for the use of Kubernetes Service Accounts in GCP IAM policies.
427-
This feature is diabled if this field is not specified.
427+
This feature is disabled if this field is not specified.
428428
properties:
429429
workloadPool:
430430
description: WorkloadPool represents the node pool to attach all

exp/api/v1beta1/gcpmanagedcontrolplane_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type GCPManagedControlPlaneSpec struct {
6060
// Endpoint represents the endpoint used to communicate with the control plane.
6161
// +optional
6262
Endpoint clusterv1.APIEndpoint `json:"endpoint"`
63-
// AddonsConfig represents the configuration options for GKE cluster add ons.
63+
// AddonsConfig represents the configuration options for GKE cluster add-ons.
6464
// +optional
6565
AddonsConfig *AddonsConfig `json:"addonsConfig,omitempty"`
6666
// LoggingConfig represents the configuration options for GKE cluster logging.
@@ -79,7 +79,7 @@ type GCPManagedControlPlaneSpec struct {
7979
// +optional
8080
PrivateClusterConfig *PrivateClusterConfig `json:"privateClusterConfig,omitempty"`
8181
// WorkloadIdentityConfig represents configuration options for the use of Kubernetes Service Accounts in GCP IAM
82-
// policies. This feature is diabled if this field is not specified.
82+
// policies. This feature is disabled if this field is not specified.
8383
// +optional
8484
WorkloadIdentityConfig *WorkloadIdentityConfig `json:"workloadIdentityConfig,omitempty"`
8585
// ResourceLabels represents the resource labels for the GKE cluster to use to annotate any related
@@ -279,7 +279,7 @@ const (
279279
NoMinorOrNodeUpgrades MaintenanceExclusionOption = "no-minor-or-node-upgrades"
280280
)
281281

282-
// AddonsConfig contains configurations for various add ons available to run in the GKE cluster.
282+
// AddonsConfig contains configurations for various add-ons available to run in the GKE cluster.
283283
type AddonsConfig struct {
284284
// DNSCacheConfig represents a configuration for NodeLocalDNS, a dns cache running on GKE cluster nodes
285285
// If omitted it is disabled by default.

exp/api/v1beta1/types.go

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,23 @@ func ConvertToSdkMaintenancePolicy(policy *MaintenancePolicy) (*containerpb.Main
191191
}
192192
exclusions[k] = tw
193193
}
194+
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
195+
MaintenanceExclusions: exclusions,
196+
}
194197
}
195198

196199
if policy.DailyMaintenanceWindow != nil {
197-
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
198-
Policy: &containerpb.MaintenanceWindow_DailyMaintenanceWindow{
199-
DailyMaintenanceWindow: &containerpb.DailyMaintenanceWindow{
200-
StartTime: policy.DailyMaintenanceWindow.StartTime,
201-
},
200+
dailyMaintenanceWindowPolicy := &containerpb.MaintenanceWindow_DailyMaintenanceWindow{
201+
DailyMaintenanceWindow: &containerpb.DailyMaintenanceWindow{
202+
StartTime: policy.DailyMaintenanceWindow.StartTime,
202203
},
203-
MaintenanceExclusions: exclusions,
204+
}
205+
if maintenancePolicy.Window == nil {
206+
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
207+
Policy: dailyMaintenanceWindowPolicy,
208+
}
209+
} else {
210+
maintenancePolicy.Window.Policy = dailyMaintenanceWindowPolicy
204211
}
205212
}
206213

@@ -209,14 +216,18 @@ func ConvertToSdkMaintenancePolicy(policy *MaintenancePolicy) (*containerpb.Main
209216
if err != nil {
210217
return nil, err
211218
}
212-
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
213-
Policy: &containerpb.MaintenanceWindow_RecurringWindow{
214-
RecurringWindow: &containerpb.RecurringTimeWindow{
215-
Window: tw,
216-
Recurrence: policy.RecurringMaintenanceWindow.Recurrence,
217-
},
219+
recurringWindowPolicy := &containerpb.MaintenanceWindow_RecurringWindow{
220+
RecurringWindow: &containerpb.RecurringTimeWindow{
221+
Window: tw,
222+
Recurrence: policy.RecurringMaintenanceWindow.Recurrence,
218223
},
219-
MaintenanceExclusions: exclusions,
224+
}
225+
if maintenancePolicy.Window == nil {
226+
maintenancePolicy.Window = &containerpb.MaintenanceWindow{
227+
Policy: recurringWindowPolicy,
228+
}
229+
} else {
230+
maintenancePolicy.Window.Policy = recurringWindowPolicy
220231
}
221232
}
222233

0 commit comments

Comments
 (0)