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

Update revision matching logic #142

Merged
merged 1 commit into from
Mar 17, 2022
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
14 changes: 12 additions & 2 deletions framework/bootstrap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,19 @@ func (env *Environment) IstioRev() string {
return env.Config.Global.IstioRev
}

// RevInScope check revision
// when StrictRev is true, return true if revision equals global.IstioRev
// when StrictRev is false, return true if revision equals global.IstioRev or revision is empty or global.IstioRev is empty
func (env *Environment) RevInScope(rev string) bool {

if env == nil || env.Config == nil || env.Config.Global == nil {
return rev == ""
return true
}
return env.Config.Global.IstioRev == rev || (rev == "" && !env.Config.Global.StrictRev)

if env.Config.Global.StrictRev {
return env.Config.Global.IstioRev == rev
} else {
return env.Config.Global.IstioRev == rev || rev == "" || env.Config.Global.IstioRev == ""
}

}
5 changes: 4 additions & 1 deletion framework/controllers/destinationrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func (r *DestinationRuleReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er
}
}

if !model.LabelMatchIstioRev(instance.Labels, r.Env.IstioRev()) {
istioRev := model.IstioRevFromLabel(instance.Labels)
if !r.Env.RevInScope(istioRev) {
log.Debugf("existing destinationRule %v istiorev %s but out %s, skip ...",
req.NamespacedName, istioRev, r.Env.IstioRev())
return ctrl.Result{}, nil
}
log.Infof("get destinationRule, %s", instance.Name)
Expand Down
6 changes: 5 additions & 1 deletion framework/controllers/virtualservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ func (r *VirtualServiceReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
return reconcile.Result{}, err
}
}
if !model.LabelMatchIstioRev(instance.Labels, r.Env.IstioRev()) {

istioRev := model.IstioRevFromLabel(instance.Labels)
if !r.Env.RevInScope(istioRev) {
log.Debugf("existing virtualService %v istiorev %s but out %s, skip ...",
req.NamespacedName, istioRev, r.Env.IstioRev())
return ctrl.Result{}, nil
}

Expand Down