Skip to content

Commit

Permalink
Merge pull request #90 from alibaba/tengine-ingress-3.1.0
Browse files Browse the repository at this point in the history
Watch changes in Ingress and Secrets and do rolling upgrades in one time
  • Loading branch information
lianglli authored Oct 23, 2023
2 parents 2562958 + 6134c1f commit b592311
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions internal/ingress/annotations/gray/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ const (
)

const (
// Index empty
PodIndexEmpty = -1
// Gray process is not start
PodIndexEmpty = 0
// Gary process is done
PodIndexDone = -1
)

// Config returns gray configuration for an Ingress rule
Expand Down
9 changes: 8 additions & 1 deletion internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import (
"k8s.io/ingress-nginx/internal/file"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations"
ing_gray "k8s.io/ingress-nginx/internal/ingress/annotations/gray"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
"k8s.io/ingress-nginx/internal/ingress/controller/ingressclass"
Expand All @@ -65,6 +66,7 @@ import (
"k8s.io/ingress-nginx/internal/ingress/metric"
"k8s.io/ingress-nginx/internal/ingress/resolver"
"k8s.io/ingress-nginx/internal/ingress/secannotations"
sec_gray "k8s.io/ingress-nginx/internal/ingress/secannotations/secretgray"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/internal/nginx"
)
Expand Down Expand Up @@ -1508,7 +1510,8 @@ func (s *k8sStore) verifyIngressReferrer(key string, anns *annotations.Ingress)
return true
}

ingReferrers := strings.Split(s.GetBackendConfiguration().IngressReferrer, ",")
cfg := s.GetBackendConfiguration()
ingReferrers := strings.Split(cfg.IngressReferrer, ",")
for _, ingReferrer := range ingReferrers {
if ingReferrer == anns.Referrer.IngReferrer {
return true
Expand All @@ -1530,6 +1533,8 @@ func (s *k8sStore) GetIngressGrayStatus(key string, anns *annotations.Ingress) (
ingGrayIndex := int32(anns.IngGray.IngGrayIndex)
if !anns.IngGray.IngGrayFlag {
gray.Type = ingress.Active
} else if ingGrayIndex == ing_gray.PodIndexDone {
gray.Type = ingress.Active
} else if ingGrayIndex > 0 && podOrdinal >= 0 && podOrdinal < ingGrayIndex {
gray.Type = ingress.ActiveGray
} else {
Expand Down Expand Up @@ -1559,6 +1564,8 @@ func (s *k8sStore) GetSecretGrayStatus(key string) (ingress.SecretGray, error) {
secGrayIndex := int32(anns.SecretGray.SecGrayIndex)
if !anns.SecretGray.SecGrayFlag {
gray.Type = ingress.Active
} else if secGrayIndex == sec_gray.PodIndexDone {
gray.Type = ingress.Active
} else if secGrayIndex > 0 && podOrdinal >= 0 && podOrdinal < secGrayIndex {
gray.Type = ingress.ActiveGray
} else {
Expand Down
6 changes: 4 additions & 2 deletions internal/ingress/secannotations/secretgray/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ const (
)

const (
// Index empty
PodIndexEmpty = -1
// Gray process is not start
PodIndexEmpty = 0
// Gary process is done
PodIndexDone = -1
)

// Config returns gray configuration for an Secret
Expand Down

0 comments on commit b592311

Please sign in to comment.