Skip to content

Commit 5d5112f

Browse files
committed
use sets to track certs to install, revert to checking for installPlan
timeouts after API availability checks, add service FQDN to list of hostnames. Signed-off-by: Ankita Thomas <[email protected]>
1 parent 8083e10 commit 5d5112f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Diff for: pkg/controller/install/certresources.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
apierrors "k8s.io/apimachinery/pkg/api/errors"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414
"k8s.io/apimachinery/pkg/util/intstr"
15+
"k8s.io/apimachinery/pkg/util/sets"
1516
corev1ac "k8s.io/client-go/applyconfigurations/core/v1"
1617
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
1718

@@ -161,6 +162,7 @@ func HostnamesForService(serviceName, namespace string) []string {
161162
return []string{
162163
fmt.Sprintf("%s.%s", serviceName, namespace),
163164
fmt.Sprintf("%s.%s.svc", serviceName, namespace),
165+
fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, namespace),
164166
}
165167
}
166168

@@ -274,15 +276,15 @@ func shouldRotateCerts(certSecret *corev1.Secret, hosts []string) bool {
274276
func (i *StrategyDeploymentInstaller) ShouldRotateCerts(s Strategy) (bool, error) {
275277
strategy, ok := s.(*v1alpha1.StrategyDetailsDeployment)
276278
if !ok {
277-
return false, fmt.Errorf("attempted to install %s strategy with deployment installer", strategy.GetStrategyName())
279+
return false, fmt.Errorf("failed to install %s strategy with deployment installer: unsupported deployment install strategy", strategy.GetStrategyName())
278280
}
279281

280-
hasCerts := map[string]struct{}{}
282+
hasCerts := sets.New[string]()
281283
for _, c := range i.getCertResources() {
282-
hasCerts[c.getDeploymentName()] = struct{}{}
284+
hasCerts.Insert(c.getDeploymentName())
283285
}
284286
for _, sddSpec := range strategy.DeploymentSpecs {
285-
if _, ok := hasCerts[sddSpec.Name]; ok {
287+
if hasCerts.Has(sddSpec.Name) {
286288
certSecret, err := i.strategyClient.GetOpLister().CoreV1().SecretLister().Secrets(i.owner.GetNamespace()).Get(SecretName(ServiceName(sddSpec.Name)))
287289
if err == nil {
288290
if shouldRotateCerts(certSecret, HostnamesForService(ServiceName(sddSpec.Name), i.owner.GetNamespace())) {

Diff for: pkg/controller/operators/olm/operator.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -2207,18 +2207,18 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
22072207
return
22082208
}
22092209
if installErr := a.updateInstallStatus(out, installer, strategy, v1alpha1.CSVPhaseInstalling, v1alpha1.CSVReasonWaiting); installErr != nil {
2210-
// Set phase to failed if it's been a long time since the last transition (5 minutes)
2211-
if out.Status.LastTransitionTime != nil && a.now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
2212-
logger.Warn("install timed out")
2213-
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, "install timeout", now, a.recorder)
2214-
return
2215-
}
22162210
// Re-sync if kube-apiserver was unavailable
22172211
if apierrors.IsServiceUnavailable(installErr) {
22182212
logger.WithError(installErr).Info("could not update install status")
22192213
syncError = installErr
22202214
return
22212215
}
2216+
// Set phase to failed if it's been a long time since the last transition (5 minutes)
2217+
if out.Status.LastTransitionTime != nil && a.now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
2218+
logger.Warn("install timed out")
2219+
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, "install timeout", now, a.recorder)
2220+
return
2221+
}
22222222
}
22232223
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Infof("install strategy successful")
22242224

0 commit comments

Comments
 (0)