Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ approvers:
- candita
- rfredette
- alebedev87
- lmzuccarelli
reviewers:
- ironcladlou
- knobunc
Expand All @@ -22,4 +23,5 @@ reviewers:
- candita
- rfredette
- alebedev87
- lmzuccarelli
component: Routing
4 changes: 2 additions & 2 deletions pkg/operator/controller/dns/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (r *reconciler) publishRecordToZones(zones []configv1.DNSZone, record *iov1
Conditions: []iov1.DNSZoneCondition{condition},
})
}
return mergeStatuses(record.Status.DeepCopy().Zones, statuses), result
return mergeStatuses(zones, record.Status.DeepCopy().Zones, statuses), result
}

// recordIsAlreadyPublishedToZone returns a Boolean value indicating whether the
Expand Down Expand Up @@ -357,7 +357,7 @@ func (r *reconciler) delete(record *iov1.DNSRecord) error {

// mergeStatuses updates or extends the provided slice of statuses with the
// provided updates and returns the resulting slice.
func mergeStatuses(statuses, updates []iov1.DNSZoneStatus) []iov1.DNSZoneStatus {
func mergeStatuses(zones []configv1.DNSZone, statuses, updates []iov1.DNSZoneStatus) []iov1.DNSZoneStatus {
var additions []iov1.DNSZoneStatus
for i, update := range updates {
add := true
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/controller/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func New(mgr manager.Manager, config Config) (controller.Controller, error) {
if err := c.Watch(&source.Kind{Type: &corev1.Service{}}, enqueueRequestForOwningIngressController(config.Namespace)); err != nil {
return nil, err
}
// add watch for changes in DNS config
if err := c.Watch(&source.Kind{Type: &configv1.DNS{}}, handler.EnqueueRequestsFromMapFunc(reconciler.ingressConfigToIngressController)); err != nil {
return nil, err
}
if err := c.Watch(&source.Kind{Type: &iov1.DNSRecord{}}, &handler.EnqueueRequestForOwner{OwnerType: &operatorv1.IngressController{}}); err != nil {
return nil, err
}
Expand Down
28 changes: 27 additions & 1 deletion pkg/operator/controller/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ func getEventsByReason(events []corev1.Event, component, reason string) []corev1
}

func computeDNSStatus(ic *operatorv1.IngressController, wildcardRecord *iov1.DNSRecord, dnsConfig *configv1.DNS) []operatorv1.OperatorCondition {

if dnsConfig.Spec.PublicZone == nil && dnsConfig.Spec.PrivateZone == nil {
return []operatorv1.OperatorCondition{
{
Expand Down Expand Up @@ -711,7 +712,11 @@ func computeDNSStatus(ic *operatorv1.IngressController, wildcardRecord *iov1.DNS
for _, zone := range wildcardRecord.Status.Zones {
for _, cond := range zone.Conditions {
if cond.Type == iov1.DNSRecordFailedConditionType && cond.Status == string(operatorv1.ConditionTrue) {
failedZones = append(failedZones, zone.DNSZone)
// check to see if the zone is in the dnsConfig.Spec
// fix:BZ1942657 - relates to status changes when updating DNS PrivateZone config
if checkZoneInConfig(dnsConfig, zone.DNSZone) {
failedZones = append(failedZones, zone.DNSZone)
}
}
}
}
Expand All @@ -735,3 +740,24 @@ func computeDNSStatus(ic *operatorv1.IngressController, wildcardRecord *iov1.DNS

return conditions
}

// checkZoneInConfig - private utility to check for a zone in the current config
func checkZoneInConfig(dnsConfig *configv1.DNS, zone configv1.DNSZone) bool {
Comment thread
lmzuccarelli marked this conversation as resolved.

Comment thread
lmzuccarelli marked this conversation as resolved.
Outdated
// check PrivateZone settings only
// check for private zone ID
if dnsConfig.Spec.PrivateZone != nil && dnsConfig.Spec.PrivateZone.ID != "" && zone.ID != "" {
if dnsConfig.Spec.PrivateZone.ID == zone.ID {
return true
}
}

// check for private zone Tags
if dnsConfig.Spec.PrivateZone != nil && dnsConfig.Spec.PrivateZone.Tags["Name"] != "" && zone.Tags["Name"] != "" {
if dnsConfig.Spec.PrivateZone.Tags["Name"] == zone.Tags["Name"] {
return true
}
}

return false
}
102 changes: 102 additions & 0 deletions test/e2e/dns_ingressdegrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// +build e2e

package e2e

import (
"context"
"fmt"
"os"
"testing"

configv1 "github.com/openshift/api/config/v1"
operatorclient "github.com/openshift/cluster-ingress-operator/pkg/operator/client"

"sigs.k8s.io/controller-runtime/pkg/client/config"

"k8s.io/apimachinery/pkg/types"
)

// TestIngressStatus - degrade/restore status via DNS config
// This test will check the ingress status
//
// Steps :-
// 1. initial check - should be false
// 2. update the DNS private zone tags to unknown value
// 3. check the status should have degraded to true
// 4. re-instate the original condition
// 5. check the status should have degraded to false
func TestIngressStatus(t *testing.T) {
kubeConfig, err := config.GetConfig()
if err != nil {
fmt.Printf("failed to get kube config: %s\n", err)
os.Exit(1)
Comment thread
frobware marked this conversation as resolved.
Outdated
}
kubeClient, err := operatorclient.NewClient(kubeConfig)
Comment thread
lmzuccarelli marked this conversation as resolved.
if err != nil {
t.Errorf("failed to create kube client: %v", err)
Comment thread
frobware marked this conversation as resolved.
Outdated
}
kclient = kubeClient
Comment thread
frobware marked this conversation as resolved.
Outdated

if err := kclient.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, &dnsConfig); err != nil {
t.Errorf("failed to get DNS config: %v", err)
}

// step 1
expected := []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue},
{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse},
}
if err := waitForClusterOperatorConditions(t, kclient, expected...); err != nil {
t.Errorf("did not get expected available condition: %v", err)
}

// step 2
updCfg := dnsConfig.DeepCopy()
updateDNSConfig(true, updCfg)
if err := kclient.Update(context.TODO(), updCfg); err != nil {
t.Errorf("failed to get DNS config: %v", err)
}

// step 3
expected = []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorDegraded, Status: configv1.ConditionTrue},
}
if err := waitForClusterOperatorConditions(t, kclient, expected...); err != nil {
t.Errorf("did not get expected available condition: %v", err)
}

// step 4
updateDNSConfig(false, updCfg)
if err := kclient.Update(context.TODO(), updCfg); err != nil {
t.Errorf("failed to get DNS config: %v", err)
}

// step 5
expected = []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue},
{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse},
}
if err := waitForClusterOperatorConditions(t, kclient, expected...); err != nil {
t.Errorf("did not get expected available condition: %v", err)
}
}

// updateDNSConfig - utility to set/unset PrivateZone Tags/ID
func updateDNSConfig(set bool, dnsConfig *configv1.DNS) {
if dnsConfig.Spec.PrivateZone.ID != "" {
if set {
dnsConfig.Spec.PrivateZone.ID = "error-" + dnsConfig.Spec.PrivateZone.ID
} else {
// remove 'error-' from prefix
dnsConfig.Spec.PrivateZone.ID = dnsConfig.Spec.PrivateZone.ID[6:]
}
}
if dnsConfig.Spec.PrivateZone.Tags["Name"] != "" {
if set {
dnsConfig.Spec.PrivateZone.Tags["Name"] = "error-" + dnsConfig.Spec.PrivateZone.Tags["Name"]
} else {
// remove 'error-' from prefix
dnsConfig.Spec.PrivateZone.Tags["Name"] = dnsConfig.Spec.PrivateZone.Tags["Name"][6:]
}
}
}