Skip to content

Commit

Permalink
NETOBSERV-1737 consolePlugin fails to get deployed on 4.17 cluster (#718
Browse files Browse the repository at this point in the history
)

* openshift api vendor

* update console plugin api

* restore envtest openshift manifests
  • Loading branch information
jpinsonneau authored Jul 24, 2024
1 parent 41ae323 commit bbcc16d
Show file tree
Hide file tree
Showing 205 changed files with 52,194 additions and 7,491 deletions.
40 changes: 24 additions & 16 deletions controllers/consoleplugin/consoleplugin_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"time"

osv1alpha1 "github.com/openshift/api/console/v1alpha1"
osv1 "github.com/openshift/api/console/v1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -70,29 +70,37 @@ func newBuilder(info *reconcilers.Instance, desired *flowslatest.FlowCollectorSp
}
}

func (b *builder) consolePlugin() *osv1alpha1.ConsolePlugin {
return &osv1alpha1.ConsolePlugin{
func (b *builder) consolePlugin() *osv1.ConsolePlugin {
return &osv1.ConsolePlugin{
ObjectMeta: metav1.ObjectMeta{
Name: constants.PluginName,
},
Spec: osv1alpha1.ConsolePluginSpec{
Spec: osv1.ConsolePluginSpec{
DisplayName: displayName,
Service: osv1alpha1.ConsolePluginService{
Name: constants.PluginName,
Namespace: b.info.Namespace,
Port: *b.advanced.Port,
BasePath: "/",
},
Proxy: []osv1alpha1.ConsolePluginProxy{{
Type: osv1alpha1.ProxyTypeService,
Alias: proxyAlias,
Authorize: true,
Service: osv1alpha1.ConsolePluginProxyServiceConfig{
Backend: osv1.ConsolePluginBackend{
Type: osv1.Service,
Service: &osv1.ConsolePluginService{
Name: constants.PluginName,
Namespace: b.info.Namespace,
Port: *b.advanced.Port,
BasePath: "/"},
},
Proxy: []osv1.ConsolePluginProxy{
{
Endpoint: osv1.ConsolePluginProxyEndpoint{
Type: osv1.ProxyTypeService,
Service: &osv1.ConsolePluginProxyServiceConfig{
Name: constants.PluginName,
Namespace: b.info.Namespace,
Port: *b.advanced.Port}},
Alias: proxyAlias,
Authorization: osv1.UserToken,
CACertificate: "",
},
}},
},
I18n: osv1.ConsolePluginI18n{
LoadType: osv1.Lazy,
},
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/consoleplugin/consoleplugin_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"reflect"

osv1alpha1 "github.com/openshift/api/console/v1alpha1"
osv1 "github.com/openshift/api/console/v1"
operatorsv1 "github.com/openshift/api/operator/v1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -157,7 +157,7 @@ func (r *CPReconciler) reconcilePermissions(ctx context.Context, builder *builde

func (r *CPReconciler) reconcilePlugin(ctx context.Context, builder *builder, desired *flowslatest.FlowCollectorSpec) error {
// Console plugin is cluster-scope (it's not deployed in our namespace) however it must still be updated if our namespace changes
oldPlg := osv1alpha1.ConsolePlugin{}
oldPlg := osv1.ConsolePlugin{}
pluginExists := true
err := r.Get(ctx, types.NamespacedName{Name: constants.PluginName}, &oldPlg)
if err != nil {
Expand Down Expand Up @@ -248,7 +248,7 @@ func (r *CPReconciler) reconcileHPA(ctx context.Context, builder *builder, desir
)
}

func pluginNeedsUpdate(plg *osv1alpha1.ConsolePlugin, desired *pluginSpec) bool {
func pluginNeedsUpdate(plg *osv1.ConsolePlugin, desired *pluginSpec) bool {
advancedConfig := helper.GetAdvancedPluginConfig(desired.Advanced)
return plg.Spec.Service.Port != *advancedConfig.Port
return plg.Spec.Backend.Service.Port != *advancedConfig.Port
}
4 changes: 2 additions & 2 deletions controllers/flowcollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

osv1alpha1 "github.com/openshift/api/console/v1alpha1"
osv1 "github.com/openshift/api/console/v1"
securityv1 "github.com/openshift/api/security/v1"
appsv1 "k8s.io/api/apps/v1"
ascv2 "k8s.io/api/autoscaling/v2"
Expand Down Expand Up @@ -60,7 +60,7 @@ func Start(ctx context.Context, mgr *manager.Manager) error {
builder.Owns(&securityv1.SecurityContextConstraints{})
}
if mgr.HasConsolePlugin() {
builder.Owns(&osv1alpha1.ConsolePlugin{})
builder.Owns(&osv1.ConsolePlugin{})
} else {
log.Info("Console not detected: the console plugin is not available")
}
Expand Down
9 changes: 9 additions & 0 deletions controllers/flowcollector_controller_console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
configv1 "github.com/openshift/api/config/v1"
operatorsv1 "github.com/openshift/api/operator/v1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -59,6 +60,14 @@ func flowCollectorConsolePluginSpecs() {
Spec: operatorsv1.ConsoleSpec{
OperatorSpec: operatorsv1.OperatorSpec{
ManagementState: operatorsv1.Unmanaged,
LogLevel: operatorsv1.Normal,
},
Providers: operatorsv1.ConsoleProviders{},
Route: operatorsv1.ConsoleConfigRoute{
Hostname: "",
Secret: configv1.SecretNameReference{
Name: "",
},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/netobserv/flowlogs-pipeline v1.6.1-crc0
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/openshift/api v0.0.0-20220112145620-704957ce4980
github.com/openshift/api v0.0.0-20240722135205-ae4f370f361f
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
github.com/prometheus/common v0.48.0
github.com/stretchr/testify v1.9.0
Expand Down
Loading

0 comments on commit bbcc16d

Please sign in to comment.