Skip to content

Commit

Permalink
Merge pull request #1538 from pkoshtavmware/AV-218385-master
Browse files Browse the repository at this point in the history
AV-218385 ChildVS Deletion should not update Gateway listener status
  • Loading branch information
apalsule authored Sep 20, 2024
2 parents 6c3884f + 99de1f1 commit 95a61bd
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 74 deletions.
3 changes: 2 additions & 1 deletion ako-gateway-api/nodes/avi_model_l7_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (o *AviObjectGraph) BuildChildVS(key string, routeModel RouteModel, parentN
childNode.EVHParent = false

childNode.ServiceMetadata = lib.ServiceMetadataObj{
Gateway: parentNsName,
Gateway: parentNsName,
HTTPRoute: routeModel.GetNamespace() + "/" + routeModel.GetName(),
}
childNode.ApplicationProfile = utils.DEFAULT_L7_APP_PROFILE
childNode.ServiceEngineGroup = lib.GetSEGName()
Expand Down
4 changes: 4 additions & 0 deletions ako-gateway-api/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func DequeueStatus(objIntf interface{}) error {
utils.AviLog.Debugf("key: %s, msg: unknown object received", option.Key)
return nil
}
if option.Options.ServiceMetadata.HTTPRoute != "" {
utils.AviLog.Debugf("key: %s, msg: Status update for ChildVs received", option.Options.ServiceMetadata.HTTPRoute)
return nil
}
if option.Op == lib.UpdateStatus {
obj.Update(option.Key, option)
} else if option.Op == lib.DeleteStatus {
Expand Down
78 changes: 39 additions & 39 deletions internal/cache/controller_obj_cache.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion internal/lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ type ServiceMetadataObj struct {
PoolRatio uint32 `json:"pool_ratio"`
PassthroughParentRef string `json:"passthrough_parent_ref"`
PassthroughChildRef string `json:"passthrough_child_ref"`
Gateway string `json:"gateway"` // ns/name
Gateway string `json:"gateway"` // ns/name
HTTPRoute string `json:"httproute"` // ns/name
InsecureEdgeTermAllow bool `json:"insecureedgetermallow"`
IsMCIIngress bool `json:"is_mci_ingress"`
}
Expand Down
2 changes: 1 addition & 1 deletion internal/rest/avi_datascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (rest *RestOperations) AviDSCacheAdd(rest_op *utils.RestOp, vsKey avicache.
if resp["pool_group_refs"] != nil {
pgs, _ := resp["pool_group_refs"].([]interface{})
for _, pg := range pgs {
pgUuid := avicache.ExtractUuid(pg.(string), "poolgroup-.*.#")
pgUuid := avicache.ExtractUUID(pg.(string), "poolgroup-.*.#")
pgName, found := rest.cache.PgCache.AviCacheGetNameByUuid(pgUuid)
if found {
poolgroups = append(poolgroups, pgName.(string))
Expand Down
6 changes: 3 additions & 3 deletions internal/rest/avi_obj_httpps.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,14 @@ func (rest *RestOperations) AviHTTPPolicyCacheAdd(rest_op *utils.RestOp, vsKey a
if rulemap["switching_action"] != nil {
switchAction := rulemap["switching_action"].(map[string]interface{})
if switchAction["pool_group_ref"] != nil {
pgUuid := avicache.ExtractUuid(switchAction["pool_group_ref"].(string), "poolgroup-.*.#")
pgUuid := avicache.ExtractUUID(switchAction["pool_group_ref"].(string), "poolgroup-.*.#")
// Search the poolName using this Uuid in the poolcache.
pgName, found := rest.cache.PgCache.AviCacheGetNameByUuid(pgUuid)
if found {
pgMembers = append(pgMembers, pgName.(string))
}
} else if switchAction["pool_ref"] != nil {
poolUuid := avicache.ExtractUuid(switchAction["pool_ref"].(string), "pool-.*.#")
poolUuid := avicache.ExtractUUID(switchAction["pool_ref"].(string), "pool-.*.#")
poolName, found := rest.cache.PoolCache.AviCacheGetNameByUuid(poolUuid)
if found {
poolMembers = append(poolMembers, poolName.(string))
Expand All @@ -409,7 +409,7 @@ func (rest *RestOperations) AviHTTPPolicyCacheAdd(rest_op *utils.RestOp, vsKey a
if pathMap["string_group_refs"] != nil {
sgRefs, _ := pathMap["string_group_refs"].([]interface{})
for _, sg := range sgRefs {
sgUuid := avicache.ExtractUuid(sg.(string), "stringgroup-.*.#")
sgUuid := avicache.ExtractUUID(sg.(string), "stringgroup-.*.#")
// Search the string group name using this Uuid in the string group cache.
sgName, found := rest.cache.StringGroupCache.AviCacheGetNameByUuid(sgUuid)
if found {
Expand Down
2 changes: 1 addition & 1 deletion internal/rest/avi_obj_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (rest *RestOperations) AviPoolCacheAdd(rest_op *utils.RestOp, vsKey avicach

var pkiKey avicache.NamespaceName
if pkiprof, ok := resp["pki_profile_ref"]; ok && pkiprof != "" {
pkiUuid := avicache.ExtractUuid(pkiprof.(string), "pkiprofile-.*.#")
pkiUuid := avicache.ExtractUUID(pkiprof.(string), "pkiprofile-.*.#")
pkiName, foundPki := rest.cache.PKIProfileCache.AviCacheGetNameByUuid(pkiUuid)
if foundPki {
pkiKey = avicache.NamespaceName{Namespace: lib.GetTenant(), Name: pkiName.(string)}
Expand Down
53 changes: 26 additions & 27 deletions internal/rest/avi_obj_vs.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (rest *RestOperations) AviVsCacheAdd(rest_op *utils.RestOp, key string) err
var vhParentKey interface{}
if found_parent {
// the uuid is expected to be in the format: "https://IP:PORT/api/virtualservice/virtualservice-88fd9718-f4f9-4e2b-9552-d31336330e0e#mygateway"
vs_uuid := avicache.ExtractUuid(vh_parent_uuid.(string), "virtualservice-.*.#")
vs_uuid := avicache.ExtractUUID(vh_parent_uuid.(string), "virtualservice-.*.#")
utils.AviLog.Debugf("key: %s, msg: extracted the vs uuid from parent ref: %s", key, vs_uuid)
// Now let's get the VS key from this uuid
var foundvscache bool
Expand Down Expand Up @@ -757,10 +757,10 @@ func (rest *RestOperations) AviVsCacheDel(rest_op *utils.RestOp, vsKey avicache.
// Delete the SNI Child ref
vs_cache, ok := rest.cache.VsCacheMeta.AviCacheGet(vsKey)
if ok {
vs_cache_obj, found := vs_cache.(*avicache.AviVsCache)
vsCacheObj, found := vs_cache.(*avicache.AviVsCache)
if found {
hostFoundInParentPool := false
parent_vs_cache, parent_ok := rest.cache.VsCacheMeta.AviCacheGet(vs_cache_obj.ParentVSRef)
parent_vs_cache, parent_ok := rest.cache.VsCacheMeta.AviCacheGet(vsCacheObj.ParentVSRef)
if parent_ok {
parent_vs_cache_obj, parent_found := parent_vs_cache.(*avicache.AviVsCache)
if parent_found {
Expand All @@ -769,8 +769,8 @@ func (rest *RestOperations) AviVsCacheDel(rest_op *utils.RestOp, vsKey avicache.

// if we find a L7Shared pool that has the secure VS host then don't delete status
// update is also not required since the shard would not change, IP should remain same
if len(vs_cache_obj.ServiceMetadataObj.HostNames) > 0 {
hostname := vs_cache_obj.ServiceMetadataObj.HostNames[0]
if len(vsCacheObj.ServiceMetadataObj.HostNames) > 0 {
hostname := vsCacheObj.ServiceMetadataObj.HostNames[0]
hostFoundInParentPool = rest.isHostPresentInSharedPool(hostname, parent_vs_cache_obj, key)
}

Expand All @@ -779,22 +779,21 @@ func (rest *RestOperations) AviVsCacheDel(rest_op *utils.RestOp, vsKey avicache.

// try to delete the vsvip from cache only if the vs is not of type insecure passthrough
// and if controller version is >= 20.1.1
if vs_cache_obj.ServiceMetadataObj.PassthroughParentRef == "" {
if len(vs_cache_obj.VSVipKeyCollection) > 0 {
vsvip := vs_cache_obj.VSVipKeyCollection[0].Name
if vsCacheObj.ServiceMetadataObj.PassthroughParentRef == "" {
if len(vsCacheObj.VSVipKeyCollection) > 0 {
vsvip := vsCacheObj.VSVipKeyCollection[0].Name
vsvipKey := avicache.NamespaceName{Namespace: vsKey.Namespace, Name: vsvip}
utils.AviLog.Infof("key: %s, msg: deleting vsvip cache for key: %s", key, vsvipKey)
rest.cache.VSVIPCache.AviCacheDelete(vsvipKey)
}
}

switch vs_cache_obj.ServiceMetadataObj.ServiceMetadataMapping("VS") {
switch vsCacheObj.ServiceMetadataObj.ServiceMetadataMapping("VS") {
case lib.GatewayVS:
updateOptions := status.UpdateOptions{
ServiceMetadata: vs_cache_obj.ServiceMetadataObj,
ServiceMetadata: vsCacheObj.ServiceMetadataObj,
Key: key,
VSName: vs_cache_obj.Name,
Tenant: vs_cache_obj.Tenant,
VSName: vsCacheObj.Name,
Tenant: vsCacheObj.Tenant,
}
statusOption := status.StatusOptions{
ObjType: lib.Gateway,
Expand All @@ -806,25 +805,25 @@ func (rest *RestOperations) AviVsCacheDel(rest_op *utils.RestOp, vsKey avicache.
status.PublishToStatusQueue(updateOptions.ServiceMetadata.Gateway, statusOption)
// The pools would have service metadata for backend services, corresponding to which
// statuses need to be deleted.
for _, poolKey := range vs_cache_obj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vs_cache_obj.Name, key)
for _, poolKey := range vsCacheObj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vsCacheObj.Name, key)
}
case lib.ServiceTypeLBVS:
updateOptions := status.UpdateOptions{
ServiceMetadata: vs_cache_obj.ServiceMetadataObj,
ServiceMetadata: vsCacheObj.ServiceMetadataObj,
Key: key,
VirtualServiceUUID: vs_cache_obj.Uuid,
VSName: vs_cache_obj.Name,
Tenant: vs_cache_obj.Tenant,
VirtualServiceUUID: vsCacheObj.Uuid,
VSName: vsCacheObj.Name,
Tenant: vsCacheObj.Tenant,
}
statusOption := status.StatusOptions{
ObjType: utils.L4LBService,
Op: lib.DeleteStatus,
Key: key,
Options: &updateOptions,
}
utils.AviLog.Infof("key: %s Publishing to status queue, options: %v", vs_cache_obj.ServiceMetadataObj.NamespaceServiceName[0], utils.Stringify(statusOption))
status.PublishToStatusQueue(vs_cache_obj.ServiceMetadataObj.NamespaceServiceName[0], statusOption)
utils.AviLog.Infof("key: %s Publishing to status queue, options: %v", vsCacheObj.ServiceMetadataObj.NamespaceServiceName[0], utils.Stringify(statusOption))
status.PublishToStatusQueue(vsCacheObj.ServiceMetadataObj.NamespaceServiceName[0], statusOption)
case lib.ChildVS:
if !hostFoundInParentPool {
// TODO: revisit
Expand All @@ -844,17 +843,17 @@ func (rest *RestOperations) AviVsCacheDel(rest_op *utils.RestOp, vsKey avicache.
// }
// status.PublishToStatusQueue(updateOptions.ServiceMetadata.IngressName, statusOption)

for _, poolKey := range vs_cache_obj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vs_cache_obj.Name, key)
for _, poolKey := range vsCacheObj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vsCacheObj.Name, key)
}
}

status.HostRuleEventBroadcast(vs_cache_obj.Name, vs_cache_obj.ServiceMetadataObj.CRDStatus, lib.CRDMetadata{})
status.SSORuleEventBroadcast(vs_cache_obj.Name, vs_cache_obj.ServiceMetadataObj.CRDStatus, lib.CRDMetadata{})
status.HostRuleEventBroadcast(vsCacheObj.Name, vsCacheObj.ServiceMetadataObj.CRDStatus, lib.CRDMetadata{})
status.SSORuleEventBroadcast(vsCacheObj.Name, vsCacheObj.ServiceMetadataObj.CRDStatus, lib.CRDMetadata{})
default:
// insecure ingress status updates in regular AKO.
for _, poolKey := range vs_cache_obj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vs_cache_obj.Name, key)
for _, poolKey := range vsCacheObj.PoolKeyCollection {
rest.DeletePoolIngressStatus(poolKey, true, vsCacheObj.Name, key)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/rest/avi_pool_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (rest *RestOperations) AviPGCacheAdd(rest_op *utils.RestOp, vsKey avicache.
if poolsOk {
for _, poolIntf := range pools {
poolmap, _ := poolIntf.(map[string]interface{})
poolUuid := avicache.ExtractUuid(poolmap["pool_ref"].(string), "pool-.*.#")
poolUuid := avicache.ExtractUUID(poolmap["pool_ref"].(string), "pool-.*.#")
// Search the poolName using this Uuid in the poolcache.
poolName, found := rest.cache.PoolCache.AviCacheGetNameByUuid(poolUuid)
if found {
Expand Down

0 comments on commit 95a61bd

Please sign in to comment.