forked from nephio-project/nephio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
De duplication logic to NF Deploy Fn Param Ref (nephio-project#494)
These changes will ensure we have nf deploy fn to apply de dupulication logic to NF Deploy Param Ref 1. Changes to Add Dependency to check if it already exist before adding. Thanks @gvbalaji for the code snippet in chat. 2. Added test cases to handle dependency, if same file is present multiple times. Its not in our use case, but its better to add that too. 3. Added changes to pipeline tests to ensure, if I run the NF Deploy Fn multiples after that, it doesn't break the idempotency principle. Docker image I used for testing - [docker.io/lostbrain/nfdeployfn:test-5](http://docker.io/lostbrain/nfdeployfn:test-5)
- Loading branch information
1 parent
e3e705c
commit 5b32639
Showing
11 changed files
with
309 additions
and
10 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
34 changes: 34 additions & 0 deletions
34
krm-functions/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/Kptfile
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,34 @@ | ||
apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: cluster01-amf | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: amf package example | ||
pipeline: {} | ||
status: | ||
conditions: | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Capacity.dataplane | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.DataNetwork.internet | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Interface.n2 | ||
- message: update for condition | ||
status: "False" | ||
type: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Dependency.upf | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Dependency.upf_duplicate |
156 changes: 156 additions & 0 deletions
156
...tions/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/_expected.yaml
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,156 @@ | ||
apiVersion: config.kubernetes.io/v1 | ||
kind: ResourceList | ||
items: | ||
- apiVersion: infra.nephio.org/v1alpha1 | ||
kind: WorkloadCluster | ||
metadata: | ||
name: cluster01 | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
spec: | ||
clusterName: cluster01 | ||
cnis: | ||
- macvlan | ||
- ipvlan | ||
- sriov | ||
masterInterface: eth1 | ||
- apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: cluster01-amf | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: amf package example | ||
readinessGates: | ||
- conditionType: nephio.org.Specializer.specialize | ||
pipeline: {} | ||
status: | ||
conditions: | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Capacity.dataplane | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.DataNetwork.internet | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Interface.n2 | ||
- message: update done | ||
status: "True" | ||
type: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Dependency.upf | ||
- message: update condition for initial resource | ||
reason: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
status: "True" | ||
type: req.nephio.org/v1alpha1.Dependency.upf_duplicate | ||
- reason: Ready | ||
status: "True" | ||
type: nephio.org.Specializer.specialize | ||
- apiVersion: req.nephio.org/v1alpha1 | ||
kind: Capacity | ||
metadata: | ||
name: dataplane | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
maxUplinkThroughput: 0 | ||
maxSubscribers: 1000 | ||
maxDownlinkThroughput: 0 | ||
- apiVersion: req.nephio.org/v1alpha1 | ||
kind: DataNetwork | ||
metadata: | ||
name: internet | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
prefix: 10.0.0.0/8 | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
status: {} | ||
- apiVersion: req.nephio.org/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: upf | ||
annotations: | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
specializer.nephio.org/namespace: free5gc-cp | ||
spec: | ||
packageName: free5gc-upf | ||
injectors: | ||
- apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
status: | ||
injected: | ||
- name: amf-regional-upf-edge02 | ||
namespace: free5gc-cp | ||
apiVersion: ref.nephio.org/v1alpha1 | ||
kind: Config | ||
- apiVersion: req.nephio.org/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: upf_duplicate | ||
annotations: | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
specializer.nephio.org/namespace: free5gc-cp | ||
spec: | ||
packageName: free5gc-upf | ||
injectors: | ||
- apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
status: | ||
injected: | ||
- name: amf-regional-upf-edge02 | ||
namespace: free5gc-cp | ||
apiVersion: ref.nephio.org/v1alpha1 | ||
kind: Config | ||
- apiVersion: req.nephio.org/v1alpha1 | ||
kind: Interface | ||
metadata: | ||
name: n2 | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
networkInstance: | ||
name: vpc-ran | ||
cniType: sriov | ||
attachmentType: vlan | ||
status: | ||
ipClaimStatus: | ||
- prefix: 10.0.0.3/24 | ||
gateway: 10.0.0.1 | ||
vlanClaimStatus: | ||
vlanID: 100 | ||
- apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
metadata: | ||
name: amf-cluster01 | ||
annotations: | ||
specializer.nephio.org/debug: "true" | ||
spec: | ||
provider: amf.free5gc.io | ||
interfaces: | ||
- name: n2 | ||
ipv4: | ||
address: 10.0.0.3/24 | ||
gateway: 10.0.0.1 | ||
vlanID: 100 | ||
networkInstances: | ||
- name: vpc-ran | ||
interfaces: | ||
- n2 | ||
parametersRefs: | ||
- name: amf-regional-upf-edge02 | ||
apiVersion: ref.nephio.org/v1alpha1 | ||
kind: Config | ||
capacity: | ||
maxDownlinkThroughput: "0" | ||
maxSubscribers: 1000 | ||
maxUplinkThroughput: "0" |
11 changes: 11 additions & 0 deletions
11
...ctions/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/capacity.yaml
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,11 @@ | ||
apiVersion: req.nephio.org/v1alpha1 | ||
kind: Capacity | ||
metadata: | ||
name: dataplane | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
maxUplinkThroughput: 0 | ||
maxSubscribers: 1000 | ||
maxDownlinkThroughput: 0 |
18 changes: 18 additions & 0 deletions
18
...ions/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/dependency.yaml
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,18 @@ | ||
apiVersion: req.nephio.org/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: upf | ||
annotations: | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
specializer.nephio.org/namespace: free5gc-cp | ||
spec: | ||
packageName: free5gc-upf | ||
injectors: | ||
- apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
status: | ||
injected: | ||
- name: amf-regional-upf-edge02 | ||
namespace: free5gc-cp | ||
apiVersion: ref.nephio.org/v1alpha1 | ||
kind: Config |
18 changes: 18 additions & 0 deletions
18
...ns/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/dependency_1.yaml
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,18 @@ | ||
apiVersion: req.nephio.org/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: upf_duplicate | ||
annotations: | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
specializer.nephio.org/namespace: free5gc-cp | ||
spec: | ||
packageName: free5gc-upf | ||
injectors: | ||
- apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
status: | ||
injected: | ||
- name: amf-regional-upf-edge02 | ||
namespace: free5gc-cp | ||
apiVersion: ref.nephio.org/v1alpha1 | ||
kind: Config |
10 changes: 10 additions & 0 deletions
10
krm-functions/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/dnn.yaml
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,10 @@ | ||
apiVersion: req.nephio.org/v1alpha1 | ||
kind: DataNetwork | ||
metadata: | ||
name: internet | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
prefix: 10.0.0.0/8 | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
status: {} |
18 changes: 18 additions & 0 deletions
18
...ns/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/interface-n2.yaml
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,18 @@ | ||
apiVersion: req.nephio.org/v1alpha1 | ||
kind: Interface | ||
metadata: | ||
name: n2 | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
specializer.nephio.org/owner: workload.nephio.org/v1alpha1.NFDeployment.amf-cluster01 | ||
spec: | ||
networkInstance: | ||
name: vpc-ran | ||
cniType: sriov | ||
attachmentType: vlan | ||
status: | ||
ipClaimStatus: | ||
- prefix: 10.0.0.3/24 | ||
gateway: 10.0.0.1 | ||
vlanClaimStatus: | ||
vlanID: 100 |
8 changes: 8 additions & 0 deletions
8
...ns/nfdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/nfdeployment.yaml
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,8 @@ | ||
apiVersion: workload.nephio.org/v1alpha1 | ||
kind: NFDeployment | ||
metadata: | ||
name: amf-cluster01 | ||
annotations: | ||
specializer.nephio.org/debug: "true" | ||
spec: | ||
provider: amf.free5gc.io |
13 changes: 13 additions & 0 deletions
13
...fdeploy-fn/fn/testdata/golden/nfdeployment_witthduplicatedependency/workload_cluster.yaml
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,13 @@ | ||
apiVersion: infra.nephio.org/v1alpha1 | ||
kind: WorkloadCluster | ||
metadata: | ||
name: cluster01 | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
spec: | ||
clusterName: cluster01 | ||
cnis: | ||
- macvlan | ||
- ipvlan | ||
- sriov | ||
masterInterface: eth1 |