Skip to content

Commit

Permalink
INSIGHTS-547 - Add OPA v1 deprecation log to insights agent (#985)
Browse files Browse the repository at this point in the history
* INSIGHTS-547 Add OPA v1 deprecation log to insights agent

* INSIGHTS-547 Add OPA v1 deprecation log to insights agent

* INSIGHTS-547 Add OPA v1 deprecation log to insights agent
  • Loading branch information
jdesouza authored Dec 11, 2024
1 parent d06a52e commit d14f77f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fairwinds-insights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ images:
- quay.io/fairwinds/nova:v3.11
- us-docker.pkg.dev/fairwinds-ops/oss/pluto:v5.20
- us-docker.pkg.dev/fairwinds-ops/oss/goldilocks:v4.13
- quay.io/fairwinds/insights-admission-controller:1.17.7
- quay.io/fairwinds/insights-admission-controller:1.17.8
- quay.io/fairwinds/aws-costs:1.4.2
- quay.io/fairwinds/insights-ci:5.7.14
- quay.io/fairwinds/cloud-costs:0.3.11
Expand All @@ -18,7 +18,7 @@ images:
- quay.io/fairwinds/kubectl:0.20.8
- quay.io/fairwinds/fw-kubesec:1.4.12
- quay.io/fairwinds/kyverno:0.3.3
- quay.io/fairwinds/fw-opa:2.5.5
- quay.io/fairwinds/fw-opa:2.5.6
- quay.io/fairwinds/postgres-partman:16.0.1
- quay.io/fairwinds/prometheus-collector:1.5.6
- quay.io/fairwinds/rbac-reporter:1.3.22
Expand Down
3 changes: 3 additions & 0 deletions plugins/admission/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.17.8
* OPA v1 deprecation message

## 1.17.7
* bumped alpine to 3.21

Expand Down
5 changes: 5 additions & 0 deletions plugins/admission/pkg/opa/opa.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ func ProcessOPA(ctx context.Context, obj map[string]any, req admission.Request,

opaCustomChecks, opaCustomLibs := opa.GetOPACustomChecksAndLibraries(configuration.OPA.CustomChecks)
logrus.Infof("Found %d checks, %d instances and %d libs", len(opaCustomChecks), len(configuration.OPA.CustomCheckInstances), len(opaCustomLibs))
anyChekIsV1 := false
for _, check := range opaCustomChecks {
logrus.Debugf("Check %s is version %.1f\n", check.Name, check.Version)
switch check.Version {
case 1.0:
anyChekIsV1 = true
newActionItems, err := ProcessOPAV1(ctx, obj, req.AdmissionRequest.Name, req.AdmissionRequest.RequestKind.Group, req.AdmissionRequest.RequestKind.Kind, req.AdmissionRequest.Namespace, check, configuration.OPA.CustomCheckInstances, &requestInfo)
actionItems = append(actionItems, newActionItems...)
if err != nil {
Expand All @@ -49,6 +51,9 @@ func ProcessOPA(ctx context.Context, obj map[string]any, req admission.Request,
allErrs = multierror.Append(allErrs, fmt.Errorf("CustomCheck %s is an unexpected version %.1f and will not be run - this could cause admission control to be blocked", check.Name, check.Version))
}
}
if anyChekIsV1 {
logrus.Info("OPA v1 will be deprecated after Mar 31, 2025. Visit: https://insights.docs.fairwinds.com/features/insights-cli/#opa-v1-deprecation for more information.")
}
results := map[string]any{
"ActionItems": actionItems,
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/admission/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.7
1.17.8
3 changes: 3 additions & 0 deletions plugins/opa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.5.6
* OPA v1 deprecation message

## 2.5.5
* bumped alpine to 3.21

Expand Down
5 changes: 5 additions & 0 deletions plugins/opa/pkg/opa/opa.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func processAllChecks(ctx context.Context, checkInstances []CheckSetting, checks

opaCustomChecks, opaCustomLibs := GetOPACustomChecksAndLibraries(checksAndLibs)
logrus.Infof("Found %d checks, %d instances and %d libs", len(opaCustomChecks), len(checkInstances), len(opaCustomLibs))
anyChekIsV1 := false
for _, check := range opaCustomChecks {
logrus.Debugf("Check %s is version %.1f", check.Name, check.Version)
switch check.Version {
case 1.0:
anyChekIsV1 = true
for _, checkInstance := range checkInstances {
if check.Name == checkInstance.CheckName {
logrus.Debugf("Found instance %s to match check %s", checkInstance.AdditionalData.Name, check.Name)
Expand All @@ -78,6 +80,9 @@ func processAllChecks(ctx context.Context, checkInstances []CheckSetting, checks
allErrs = multierror.Append(allErrs, fmt.Errorf("CustomCheck %s is an unexpected version %.1f and will not be run", check.Name, check.Version))
}
}
if anyChekIsV1 {
logrus.Info("OPA v1 will be deprecated after Mar 31, 2025. Visit: https://insights.docs.fairwinds.com/features/insights-cli/#opa-v1-deprecation for more information.")
}
return actionItems, allErrs
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/opa/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.5
2.5.6

0 comments on commit d14f77f

Please sign in to comment.