Skip to content
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

fix(adapters): Update NP status on SecurityIntent update and deletion #75

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/adapter/nimbus-kubearmor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/5GSEC/nimbus/pkg/adapter/nimbus-kubearmor
go 1.21

require (
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f
github.com/go-logr/logr v1.4.1
github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20240125171707-8e6641511fe3
k8s.io/apimachinery v0.29.1
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/nimbus-kubearmor/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad h1:vr8/EtADzXyAYOsZbG8KhSO7ClELdQMjWEfHde5C3yA=
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad/go.mod h1:YgeRR5ijLJHHeapCUekTfLJXMVrqOMVT2rCsqHlKLdU=
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f h1:FOwBcqhGFm8RXXjgJTdBhjhb3k5UbaDOJ6TpK+5Zmvk=
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f/go.mod h1:FflBHoOu8LpzZJucobgLdGG4j+22A97JX8cXlNY1fXc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down
18 changes: 6 additions & 12 deletions pkg/adapter/nimbus-kubearmor/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,9 @@ func createOrUpdateKsp(ctx context.Context, npName, npNamespace string) {
logger.Info("KubeArmorPolicy configured", "KubeArmorPolicy.Name", existingKsp.Name, "KubeArmorPolicy.Namespace", existingKsp.Namespace)
}

//TODO: Due to adapters' dependency on nimbus module, the docker image build is
// failing. The relevant code is commented out below (lines 153-155). We shall
// uncomment this code in a subsequent PR.
//if err = adapterutil.UpdateNpStatus(ctx, k8sClient, "KubeArmorPolicy/"+ksp.Name, np.Name, np.Namespace, false); err != nil {
// logger.Error(err, "failed to update KubeArmorPolicies status in NimbusPolicy")
//}
if err = adapterutil.UpdateNpStatus(ctx, k8sClient, "KubeArmorPolicy/"+ksp.Name, np.Name, np.Namespace, false); err != nil {
logger.Error(err, "failed to update KubeArmorPolicies status in NimbusPolicy")
}
}
}

Expand Down Expand Up @@ -213,12 +210,9 @@ func deleteDanglingKsps(ctx context.Context, np intentv1.NimbusPolicy, logger lo
continue
}

//TODO: Due to adapters' dependency on nimbus module, the docker image build is
// failing. The relevant code is commented out below (lines 217-219). We shall
// uncomment this code in a subsequent PR.
//if err := adapterutil.UpdateNpStatus(ctx, k8sClient, "KubeArmorPolicy/"+ksp.Name, np.Name, np.Namespace, true); err != nil {
// logger.Error(err, "failed to update KubeArmorPolicy status in NimbusPolicy")
//}
if err := adapterutil.UpdateNpStatus(ctx, k8sClient, "KubeArmorPolicy/"+ksp.Name, np.Name, np.Namespace, true); err != nil {
logger.Error(err, "failed to update KubeArmorPolicy status in NimbusPolicy")
}
logger.Info("Dangling KubeArmorPolicy deleted", "KubeArmorPolicy.Name", ksp.Name, "KubeArmorPolicy.Namespace", ksp.Namespace)
}
}
2 changes: 1 addition & 1 deletion pkg/adapter/nimbus-netpol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/5GSEC/nimbus/pkg/adapter/nimbus-netpol
go 1.21

require (
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f
github.com/go-logr/logr v1.4.1
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/nimbus-netpol/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad h1:vr8/EtADzXyAYOsZbG8KhSO7ClELdQMjWEfHde5C3yA=
github.com/5GSEC/nimbus v0.0.0-20240220040009-4cc97b1338ad/go.mod h1:YgeRR5ijLJHHeapCUekTfLJXMVrqOMVT2rCsqHlKLdU=
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f h1:FOwBcqhGFm8RXXjgJTdBhjhb3k5UbaDOJ6TpK+5Zmvk=
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f/go.mod h1:FflBHoOu8LpzZJucobgLdGG4j+22A97JX8cXlNY1fXc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down
20 changes: 8 additions & 12 deletions pkg/adapter/nimbus-netpol/manager/netpols_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ func createOrUpdateNetworkPolicy(ctx context.Context, npName, npNamespace string
}
logger.Info("NetworkPolicy configured", "NetworkPolicy.Name", netpol.Name, "NetworkPolicy.Namespace", netpol.Namespace)
}
//TODO: Due to adapters' dependency on nimbus module, the docker image build is
// failing. The relevant code is commented out below (lines 150-152). We shall
// uncomment this code in a subsequent PR.
//if err = adapterutil.UpdateNpStatus(ctx, k8sClient, "NetworkPolicy/"+netpol.Name, np.Name, np.Namespace, false); err != nil {
// logger.Error(err, "failed to update NetworkPolicies status in NimbusPolicy")
//}

if err = adapterutil.UpdateNpStatus(ctx, k8sClient, "NetworkPolicy/"+netpol.Name, np.Name, np.Namespace, false); err != nil {
logger.Error(err, "failed to update NetworkPolicies status in NimbusPolicy")
}
}
}

Expand Down Expand Up @@ -211,12 +209,10 @@ func deleteDanglingNetpols(ctx context.Context, np intentv1.NimbusPolicy, logger
logger.Error(err, "failed to delete dangling NetworkPolicy", "NetworkPolicy.Name", netpol.Namespace, "NetworkPolicy.Namespace", netpol.Namespace)
continue
}
//TODO: Due to adapters' dependency on nimbus module, the docker image build is
// failing. The relevant code is commented out below (lines 215-217). We shall
// uncomment this code in a subsequent PR.
//if err := adapterutil.UpdateNpStatus(ctx, k8sClient, "NetworkPolicy/"+netpol.Name, np.Name, np.Namespace, true); err != nil {
// logger.Error(err, "failed to update NetworkPolicy status in NimbusPolicy")
//}

if err := adapterutil.UpdateNpStatus(ctx, k8sClient, "NetworkPolicy/"+netpol.Name, np.Name, np.Namespace, true); err != nil {
logger.Error(err, "failed to update NetworkPolicy status in NimbusPolicy")
}
logger.Info("Dangling NetworkPolicy deleted", "NetworkPolicy.Name", netpol.Name, "NetworkPolicy.Namespace", netpol.Namespace)
}
}
Loading