Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add retry on api-endpoint change #1577

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions manifests/claudie/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: ghcr.io/berops/claudie/ansibler
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/autoscaler-adapter
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/builder
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/claudie-operator
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/kube-eleven
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/kuber
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/manager
newTag: 5b997a0-3111
newTag: 458afc2-3119
- name: ghcr.io/berops/claudie/terraformer
newTag: 5b997a0-3111
newTag: 458afc2-3119
2 changes: 1 addition & 1 deletion manifests/testing-framework/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ secretGenerator:

images:
- name: ghcr.io/berops/claudie/testing-framework
newTag: 14c6514-3116
newTag: 458afc2-3119
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func autoscaledEvents(diff nodeDiffResult, desired *spec.Clusters) []*spec.TaskE
Node: node,
}},
},
OnError: &spec.RetryStrategy{Repeat: true},
})
}

Expand Down
29 changes: 29 additions & 0 deletions services/manager/internal/service/schedule_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/berops/claudie/internal/utils"
"github.com/berops/claudie/proto/pb/spec"
utils2 "github.com/berops/claudie/services/ansibler/server/utils"
"github.com/berops/claudie/services/manager/internal/store"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -280,6 +281,7 @@ func Diff(current, desired *spec.K8Scluster, currentLbs, desiredLbs []*spec.LBcl
Lbs: &spec.LoadBalancers{Clusters: irLbs},
},
},
OnError: &spec.RetryStrategy{Repeat: true},
})
}

Expand All @@ -297,6 +299,7 @@ func Diff(current, desired *spec.K8Scluster, currentLbs, desiredLbs []*spec.LBcl
Node: node,
}},
},
OnError: &spec.RetryStrategy{Repeat: true},
})
}

Expand Down Expand Up @@ -348,6 +351,9 @@ func Diff(current, desired *spec.K8Scluster, currentLbs, desiredLbs []*spec.LBcl
return nil
}(),
},
OnError: &spec.RetryStrategy{
Repeat: ApiEndpointChanged(currentLbs, desiredLbs),
},
})
}

Expand Down Expand Up @@ -802,3 +808,26 @@ func labelsTaintsAnnotationsDiff(current, desired *spec.K8Scluster) bool {
}
return false
}

func ApiEndpointChanged(current, desired []*spec.LBcluster) bool {
var lbs []*utils2.LBClusterData

c := make(map[string]*spec.LBcluster)
for _, l := range current {
c[l.ClusterInfo.Name] = l
}

for _, l := range desired {
lbs = append(lbs, &utils2.LBClusterData{
CurrentLbCluster: c[l.ClusterInfo.Name],
DesiredLbCluster: l,
})
}

for _, l := range lbs {
if l.APIEndpointState() != utils2.NoChange {
return true
}
}
return false
}
1 change: 1 addition & 0 deletions services/manager/internal/service/schedule_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ func TestDiff(t *testing.T) {
{
ClusterInfo: &spec.ClusterInfo{Name: "test1"},
TargetedK8S: "k8s",
Dns: &spec.DNS{},
Roles: []*spec.Role{
{
Name: "api-server",
Expand Down