-
Notifications
You must be signed in to change notification settings - Fork 83
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
process gtps as soon they are applied #223
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,17 +3,18 @@ package clusters | |||||
import ( | ||||||
"context" | ||||||
"errors" | ||||||
"sync" | ||||||
"time" | ||||||
|
||||||
argo "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" | ||||||
"github.com/istio-ecosystem/admiral/admiral/pkg/apis/admiral/v1" | ||||||
v1 "github.com/istio-ecosystem/admiral/admiral/pkg/apis/admiral/v1" | ||||||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/admiral" | ||||||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/common" | ||||||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/istio" | ||||||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/secret" | ||||||
log "github.com/sirupsen/logrus" | ||||||
k8sAppsV1 "k8s.io/api/apps/v1" | ||||||
k8s "k8s.io/client-go/kubernetes" | ||||||
"sync" | ||||||
"time" | ||||||
) | ||||||
|
||||||
type RemoteController struct { | ||||||
|
@@ -180,14 +181,17 @@ func (dh *DependencyHandler) Deleted(obj *v1.Dependency) { | |||||
|
||||||
func (gtp *GlobalTrafficHandler) Added(obj *v1.GlobalTrafficPolicy) { | ||||||
log.Infof(LogFormat, "Added", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") | ||||||
HandleEventForGlobalTrafficPolicy(admiral.Add, obj, gtp.RemoteRegistry, gtp.ClusterID) | ||||||
} | ||||||
|
||||||
func (gtp *GlobalTrafficHandler) Updated(obj *v1.GlobalTrafficPolicy) { | ||||||
log.Infof(LogFormat, "Updated", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") | ||||||
HandleEventForGlobalTrafficPolicy(admiral.Update, obj, gtp.RemoteRegistry, gtp.ClusterID) | ||||||
} | ||||||
|
||||||
func (gtp *GlobalTrafficHandler) Deleted(obj *v1.GlobalTrafficPolicy) { | ||||||
log.Infof(LogFormat, "Deleted", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") | ||||||
HandleEventForGlobalTrafficPolicy(admiral.Delete, obj, gtp.RemoteRegistry, gtp.ClusterID) | ||||||
} | ||||||
|
||||||
func (pc *DeploymentHandler) Added(obj *k8sAppsV1.Deployment) { | ||||||
|
@@ -243,3 +247,19 @@ func HandleEventForDeployment(event admiral.EventType, obj *k8sAppsV1.Deployment | |||||
// Use the same function as added deployment function to update and put new service entry in place to replace old one | ||||||
modifyServiceEntryForNewServiceOrPod(event, env, globalIdentifier, remoteRegistry) | ||||||
} | ||||||
|
||||||
// HandleEventForGlobalTrafficPolicy processes all the events related to GTPs | ||||||
func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTrafficPolicy, remoteRegistry *RemoteRegistry, clusterName string) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't an error for error case would help the function ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can a few test cases be added for |
||||||
|
||||||
globalIdentifier := common.GetGtpIdentity(gtp) | ||||||
|
||||||
if len(globalIdentifier) == 0 { | ||||||
log.Infof(LogFormat, "Event", "globaltrafficpolicy", gtp.Name, clusterName, "Skipped as '"+common.GetWorkloadIdentifier()+" was not found', namespace="+gtp.Namespace) | ||||||
return | ||||||
} | ||||||
|
||||||
env := common.GetGtpEnv(gtp) | ||||||
|
||||||
// Use the same function as added deployment function to update and put new service entry in place to replace old one | ||||||
modifyServiceEntryForNewServiceOrPod(event, env, globalIdentifier, remoteRegistry) | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will an assignment of
_ = HandleEventForGlobalTrafficPolicy(..)
help to prevent warning from Github Actions?