Skip to content

Commit 349e84a

Browse files
committed
OSD-24275: Attempt to fetch and cache machineCidr at Init. Update comments.
1 parent 82be7bf commit 349e84a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pkg/webhooks/ingresscontroller/ingresscontroller.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ func (wh *IngressControllerWebhook) authorized(request admissionctl.Request) adm
177177
}
178178

179179
/* TODO:
180-
* 1) ONLY check for privatelink clusters? How?
181-
* 2) HCP vs Classic, etc.. ...any other cluster type this should apply to? Is this handled by the
182-
* HypershiftEnabled vs ClassicEnabled flags set in this module? Currently HCP disabled.
183-
* If HCP is to be enabled for allowed source ranges, should this part of a 2nd ingress validator to
184-
* allow separation of validations between cluster install types? Is there a run time method available
185-
* to this validator to determine classic vs hcp?
186-
* 3) What other specifics should be checked here for this cidr check to be applicable?m
180+
* - HypershiftEnabled is currently set to false/disabled.
181+
* If HCP is to be enabled for allowed source ranges, should this part of a 2nd ingress validator to
182+
* allow separation of validations between cluster install types? ...or if there's a reliable run time method available
183+
* to this validator to determine classic vs hcp they can remain in the single webhook(?)
184+
* - Classic vs HCP could likely share some of the network funcions, but will need slightly
185+
* different logic as well as permissions fetching the network config info from different
186+
* source (configmap) locations and config formats(?).
187187
*/
188188
// Only check for machine cidr in allowed ranges if creating or updating resource...
189189
reqOp := request.AdmissionRequest.Operation
@@ -279,7 +279,7 @@ func (wh *IngressControllerWebhook) checkAllowsMachineCIDR(ipRanges []operatorv1
279279
// Note: From docs it appears a missing ASR value/attr allows all. However...
280280
// once ASR values have been added to an ingresscontroller, later deleting all the ASRs can expose an issue
281281
// where the IGC will remaining in progressing state indefinitely.
282-
// For now return Allowed with a warning?
282+
// For now return Allowed, but with a warning?
283283
if ipRanges == nil || len(ipRanges) <= 0 {
284284
return admissionctl.Allowed("Allowing empty 'AllowedSourceRanges'. Populate this value if operator remains in 'progressing' state")
285285
}
@@ -370,8 +370,12 @@ func NewWebhook() *IngressControllerWebhook {
370370
log.Error(err, "Fail adding corev1 scheme to IngressControllerWebhook")
371371
os.Exit(1)
372372
}
373-
return &IngressControllerWebhook{
373+
wh := &IngressControllerWebhook{
374374
s: *scheme,
375375
kubeClient: nil,
376376
}
377+
// Try to populate machine cidr at init. If this fails it will try again on the
378+
// first update/create request involving the default ingress controller.
379+
wh.getMachineCIDR()
380+
return wh
377381
}

0 commit comments

Comments
 (0)