-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug which should delete node from store when there is node not fo…
…und error When node is deleted, the phase node.ObjectMeta.DeletionTimestamp being not zero is intermittent, and it is more possible the node is not found, we should delete the node from store.
- Loading branch information
1 parent
c729a64
commit 1b7be35
Showing
7 changed files
with
113 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package mock | ||
|
||
import ( | ||
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/sites/enforcement_points" | ||
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" | ||
"k8s.io/client-go/tools/cache" | ||
|
||
"github.com/vmware-tanzu/nsx-operator/pkg/config" | ||
"github.com/vmware-tanzu/nsx-operator/pkg/nsx" | ||
servicecommon "github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/common" | ||
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/node" | ||
) | ||
|
||
type NodeStore struct { | ||
servicecommon.ResourceStore | ||
} | ||
|
||
type NodeService struct { | ||
servicecommon.Service | ||
NodeStore *NodeStore | ||
} | ||
|
||
type fakeHostTransportNodesClient struct { | ||
enforcement_points.HostTransportNodesClient | ||
} | ||
|
||
func (f *fakeHostTransportNodesClient) Get(param1 string, param2 string, param3 string) (model.HostTransportNode, error) { | ||
// Do nothing | ||
return model.HostTransportNode{}, nil | ||
} | ||
|
||
func (f *fakeHostTransportNodesClient) List(param1 string, param2 string, param3 *string, param4 *string, param5 *bool, param6 *string, param7 *string, param8 *string, param9 *int64, param10 *bool, param11 *string, param12 *string) (model.HostTransportNodeListResult, error) { | ||
nodeName := "test-node" | ||
mockNode := &model.HostTransportNode{ | ||
UniqueId: servicecommon.String("test-node"), | ||
NodeDeploymentInfo: &model.FabricHostNode{ | ||
Fqdn: &nodeName, | ||
}, | ||
} | ||
return model.HostTransportNodeListResult{ | ||
Results: []model.HostTransportNode{*mockNode}, | ||
}, nil | ||
} | ||
|
||
func (f *fakeHostTransportNodesClient) Update(param1 string, param2 string, param3 string, param4 model.HostTransportNode, _ *string, _ *string, | ||
_ *bool, _ *string, _ *bool, _ *string, _ *string) (model.HostTransportNode, error) { | ||
// Do nothing | ||
return model.HostTransportNode{}, nil | ||
} | ||
|
||
func CreateMockNodeService() *NodeService { | ||
return &NodeService{ | ||
Service: servicecommon.Service{ | ||
NSXClient: &nsx.Client{ | ||
HostTransPortNodesClient: &fakeHostTransportNodesClient{}, | ||
NsxConfig: &config.NSXOperatorConfig{ | ||
CoeConfig: &config.CoeConfig{ | ||
Cluster: "k8scl-one:test", | ||
}, | ||
}, | ||
}, | ||
}, | ||
NodeStore: &NodeStore{ | ||
ResourceStore: servicecommon.ResourceStore{ | ||
Indexer: cache.NewIndexer( | ||
node.KeyFunc, | ||
cache.Indexers{ | ||
servicecommon.IndexKeyNodeName: node.NodeIndexByNodeName, | ||
}, | ||
), | ||
BindingType: model.HostTransportNodeBindingType(), | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters