Skip to content

Commit 390dc49

Browse files
committed
Merge branch 'incubation' into ossm-authz-mvp
2 parents 037b571 + f3e6a13 commit 390dc49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+709
-612
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ odh-manifests/
5555

5656
cover.out
5757

58+
config/manager/kustomization.yaml
59+
5860
# Ignore any local.mk files that would be consumed by the Makefile
5961
local.mk
6062

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ linters-settings:
5555
linters:
5656
enable-all: true
5757
disable:
58-
- containedctx # detects struct contained context.Context field
5958
- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
6059
- exhaustruct # Prevents empty struct. We use a lot of these so I think it is safe to disable.c
6160
- forbidigo
@@ -75,7 +74,6 @@ linters:
7574
# Need to check
7675
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
7776
- err113 # [too strict] checks the errors handling expressions
78-
- contextcheck # Requires to pass context to all function.
7977

8078
# To be fixed
8179
- gocognit # https://github.com/opendatahub-io/opendatahub-operator/issues/709

apis/datasciencecluster/v1/datasciencecluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package v1
1818

1919
import (
2020
"errors"
21-
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2221
"reflect"
2322

2423
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
@@ -37,6 +36,7 @@ import (
3736
"github.com/opendatahub-io/opendatahub-operator/v2/components/trainingoperator"
3837
"github.com/opendatahub-io/opendatahub-operator/v2/components/trustyai"
3938
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
39+
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
4040
)
4141

4242
// DataScienceClusterSpec defines the desired state of the cluster.

apis/dscinitialization/v1/dscinitialization_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ limitations under the License.
1717
package v1
1818

1919
import (
20-
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2120
operatorv1 "github.com/openshift/api/operator/v1"
2221
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
2322
corev1 "k8s.io/api/core/v1"
2423
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2524

2625
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
26+
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2727
)
2828

2929
// +operator-sdk:csv:customresourcedefinitions:order=1

components/codeflare/codeflare.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ type CodeFlare struct {
3636
components.Component `json:""`
3737
}
3838

39-
func (c *CodeFlare) OverrideManifests(_ string) error {
39+
func (c *CodeFlare) OverrideManifests(ctx context.Context, _ string) error {
4040
// If devflags are set, update default manifests path
4141
if len(c.DevFlags.Manifests) != 0 {
4242
manifestConfig := c.DevFlags.Manifests[0]
43-
if err := deploy.DownloadManifests(ComponentName, manifestConfig); err != nil {
43+
if err := deploy.DownloadManifests(ctx, ComponentName, manifestConfig); err != nil {
4444
return err
4545
}
4646
// If overlay is defined, update paths
@@ -75,15 +75,15 @@ func (c *CodeFlare) ReconcileComponent(
7575
if enabled {
7676
if c.DevFlags != nil {
7777
// Download manifests and update paths
78-
if err := c.OverrideManifests(string(platform)); err != nil {
78+
if err := c.OverrideManifests(ctx, string(platform)); err != nil {
7979
return err
8080
}
8181
}
8282
// check if the CodeFlare operator is installed: it should not be installed
8383
// Both ODH and RHOAI should have the same operator name
8484
dependentOperator := CodeflareOperator
8585

86-
if found, err := cluster.OperatorExists(cli, dependentOperator); err != nil {
86+
if found, err := cluster.OperatorExists(ctx, cli, dependentOperator); err != nil {
8787
return fmt.Errorf("operator exists throws error %w", err)
8888
} else if found {
8989
return fmt.Errorf("operator %s is found. Please uninstall the operator before enabling %s component",
@@ -99,7 +99,7 @@ func (c *CodeFlare) ReconcileComponent(
9999
}
100100

101101
// Deploy Codeflare
102-
if err := deploy.DeployManifestsFromPath(cli, owner, //nolint:revive,nolintlint
102+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, //nolint:revive,nolintlint
103103
CodeflarePath,
104104
dscispec.ApplicationsNamespace,
105105
ComponentName, enabled); err != nil {
@@ -120,7 +120,7 @@ func (c *CodeFlare) ReconcileComponent(
120120
if err := c.UpdatePrometheusConfig(cli, enabled && monitoringEnabled, ComponentName); err != nil {
121121
return err
122122
}
123-
if err := deploy.DeployManifestsFromPath(cli, owner,
123+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
124124
filepath.Join(deploy.DefaultManifestPath, "monitoring", "prometheus", "apps"),
125125
dscispec.Monitoring.Namespace,
126126
"prometheus", true); err != nil {

components/component.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c *Component) GetManagementState() operatorv1.ManagementState {
4545
return c.ManagementState
4646
}
4747

48-
func (c *Component) Cleanup(_ client.Client, _ *dsciv1.DSCInitializationSpec) error {
48+
func (c *Component) Cleanup(_ context.Context, _ client.Client, _ *dsciv1.DSCInitializationSpec) error {
4949
// noop
5050
return nil
5151
}
@@ -82,10 +82,10 @@ type ManifestsConfig struct {
8282
type ComponentInterface interface {
8383
ReconcileComponent(ctx context.Context, cli client.Client, logger logr.Logger,
8484
owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool, c capabilities.PlatformCapabilities) error
85-
Cleanup(cli client.Client, DSCISpec *dsciv1.DSCInitializationSpec) error
85+
Cleanup(ctx context.Context, cli client.Client, DSCISpec *dsciv1.DSCInitializationSpec) error
8686
GetComponentName() string
8787
GetManagementState() operatorv1.ManagementState
88-
OverrideManifests(platform string) error
88+
OverrideManifests(ctx context.Context, platform string) error
8989
UpdatePrometheusConfig(cli client.Client, enable bool, component string) error
9090
ConfigComponentLogger(logger logr.Logger, component string, dscispec *dsciv1.DSCInitializationSpec) logr.Logger
9191
}

components/dashboard/dashboard.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ type Dashboard struct {
5252
components.Component `json:""`
5353
}
5454

55-
func (d *Dashboard) OverrideManifests(platform string) error {
55+
func (d *Dashboard) OverrideManifests(ctx context.Context, platform string) error {
5656
// If devflags are set, update default manifests path
5757
if len(d.DevFlags.Manifests) != 0 {
5858
manifestConfig := d.DevFlags.Manifests[0]
59-
if err := deploy.DownloadManifests(ComponentName, manifestConfig); err != nil {
59+
if err := deploy.DownloadManifests(ctx, ComponentName, manifestConfig); err != nil {
6060
return err
6161
}
6262
// If overlay is defined, update paths
@@ -115,12 +115,12 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
115115
}
116116
if d.DevFlags != nil {
117117
// Download manifests and update paths
118-
if err := d.OverrideManifests(string(platform)); err != nil {
118+
if err := d.OverrideManifests(ctx, string(platform)); err != nil {
119119
return err
120120
}
121121
}
122122
// 1. Deploy CRDs
123-
if err := d.deployCRDsForPlatform(cli, owner, dscispec.ApplicationsNamespace, platform); err != nil {
123+
if err := d.deployCRDsForPlatform(ctx, cli, owner, dscispec.ApplicationsNamespace, platform); err != nil {
124124
return fmt.Errorf("failed to deploy Dashboard CRD: %w", err)
125125
}
126126

@@ -156,12 +156,12 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
156156
return fmt.Errorf("failed to create access-secret for anaconda: %w", err)
157157
}
158158
// overlay which including ../../base + anaconda-ce-validator
159-
if err := deploy.DeployManifestsFromPath(cli, owner, PathSupported, dscispec.ApplicationsNamespace, ComponentNameSupported, enabled); err != nil {
159+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, PathSupported, dscispec.ApplicationsNamespace, ComponentNameSupported, enabled); err != nil {
160160
return fmt.Errorf("failed to apply manifests from %s: %w", PathSupported, err)
161161
}
162162

163163
// Apply RHOAI specific configs, e.g anaconda screct and cronjob and ISV
164-
if err := d.applyRHOAISpecificConfigs(cli, owner, dscispec.ApplicationsNamespace, platform); err != nil {
164+
if err := d.applyRHOAISpecificConfigs(ctx, cli, owner, dscispec.ApplicationsNamespace, platform); err != nil {
165165
return err
166166
}
167167
// consolelink
@@ -183,7 +183,7 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
183183
if err := d.UpdatePrometheusConfig(cli, enabled && monitoringEnabled, ComponentNameSupported); err != nil {
184184
return err
185185
}
186-
if err := deploy.DeployManifestsFromPath(cli, owner,
186+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
187187
filepath.Join(deploy.DefaultManifestPath, "monitoring", "prometheus", "apps"),
188188
dscispec.Monitoring.Namespace,
189189
"prometheus", true); err != nil {
@@ -194,11 +194,11 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
194194
return nil
195195
default:
196196
// base
197-
if err := deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
197+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
198198
return err
199199
}
200200
// ISV
201-
if err := deploy.DeployManifestsFromPath(cli, owner, PathISV, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
201+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, PathISV, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
202202
return err
203203
}
204204
// consolelink
@@ -210,16 +210,16 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
210210
}
211211
}
212212

213-
func (d *Dashboard) deployCRDsForPlatform(cli client.Client, owner metav1.Object, namespace string, platform cluster.Platform) error {
213+
func (d *Dashboard) deployCRDsForPlatform(ctx context.Context, cli client.Client, owner metav1.Object, namespace string, platform cluster.Platform) error {
214214
componentName := ComponentName
215215
if platform == cluster.SelfManagedRhods || platform == cluster.ManagedRhods {
216216
componentName = ComponentNameSupported
217217
}
218218
// we only deploy CRD, we do not remove CRD
219-
return deploy.DeployManifestsFromPath(cli, owner, PathCRDs, namespace, componentName, true)
219+
return deploy.DeployManifestsFromPath(ctx, cli, owner, PathCRDs, namespace, componentName, true)
220220
}
221221

222-
func (d *Dashboard) applyRHOAISpecificConfigs(cli client.Client, owner metav1.Object, namespace string, platform cluster.Platform) error {
222+
func (d *Dashboard) applyRHOAISpecificConfigs(ctx context.Context, cli client.Client, owner metav1.Object, namespace string, platform cluster.Platform) error {
223223
enabled := d.ManagementState == operatorv1.Managed
224224

225225
// set proper group name
@@ -232,15 +232,15 @@ func (d *Dashboard) applyRHOAISpecificConfigs(cli client.Client, owner metav1.Ob
232232
if err := common.ReplaceStringsInFile(dashboardConfig, map[string]string{"<admin_groups>": adminGroups}); err != nil {
233233
return err
234234
}
235-
if err := deploy.DeployManifestsFromPath(cli, owner, PathODHDashboardConfig, namespace, ComponentNameSupported, enabled); err != nil {
235+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, PathODHDashboardConfig, namespace, ComponentNameSupported, enabled); err != nil {
236236
return fmt.Errorf("failed to create OdhDashboardConfig from %s: %w", PathODHDashboardConfig, err)
237237
}
238238
// ISV
239239
path := PathISVSM
240240
if platform == cluster.ManagedRhods {
241241
path = PathISVAddOn
242242
}
243-
if err := deploy.DeployManifestsFromPath(cli, owner, path, namespace, ComponentNameSupported, enabled); err != nil {
243+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, path, namespace, ComponentNameSupported, enabled); err != nil {
244244
return fmt.Errorf("failed to set dashboard ISV from %s : %w", Path, err)
245245
}
246246
return nil
@@ -280,7 +280,7 @@ func (d *Dashboard) deployConsoleLink(ctx context.Context, cli client.Client, ow
280280
}
281281

282282
enabled := d.ManagementState == operatorv1.Managed
283-
if err := deploy.DeployManifestsFromPath(cli, owner, PathConsoleLink, namespace, componentName, enabled); err != nil {
283+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, PathConsoleLink, namespace, componentName, enabled); err != nil {
284284
return fmt.Errorf("failed to set dashboard consolelink %s : %w", pathConsoleLink, err)
285285
}
286286

components/datasciencepipelines/datasciencepipelines.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ type DataSciencePipelines struct {
4242
components.Component `json:""`
4343
}
4444

45-
func (d *DataSciencePipelines) OverrideManifests(_ string) error {
45+
func (d *DataSciencePipelines) OverrideManifests(ctx context.Context, _ string) error {
4646
// If devflags are set, update default manifests path
4747
if len(d.DevFlags.Manifests) != 0 {
4848
manifestConfig := d.DevFlags.Manifests[0]
49-
if err := deploy.DownloadManifests(ComponentName, manifestConfig); err != nil {
49+
if err := deploy.DownloadManifests(ctx, ComponentName, manifestConfig); err != nil {
5050
return err
5151
}
5252
// If overlay is defined, update paths
@@ -99,7 +99,7 @@ func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
9999
if enabled {
100100
if d.DevFlags != nil {
101101
// Download manifests and update paths
102-
if err := d.OverrideManifests(string(platform)); err != nil {
102+
if err := d.OverrideManifests(ctx, string(platform)); err != nil {
103103
return err
104104
}
105105
}
@@ -121,7 +121,7 @@ func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
121121
if platform == cluster.OpenDataHub || platform == "" {
122122
manifestsPath = filepath.Join(OverlayPath, "odh")
123123
}
124-
if err := deploy.DeployManifestsFromPath(cli, owner, manifestsPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
124+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, manifestsPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
125125
return err
126126
}
127127
l.Info("apply manifests done")
@@ -140,7 +140,7 @@ func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
140140
if err := d.UpdatePrometheusConfig(cli, enabled && monitoringEnabled, ComponentName); err != nil {
141141
return err
142142
}
143-
if err := deploy.DeployManifestsFromPath(cli, owner,
143+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
144144
filepath.Join(deploy.DefaultManifestPath, "monitoring", "prometheus", "apps"),
145145
dscispec.Monitoring.Namespace,
146146
"prometheus", true); err != nil {

components/kserve/kserve.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ type Kserve struct {
5757
DefaultDeploymentMode DefaultDeploymentMode `json:"defaultDeploymentMode,omitempty"`
5858
}
5959

60-
func (k *Kserve) OverrideManifests(_ string) error {
60+
func (k *Kserve) OverrideManifests(ctx context.Context, _ string) error {
6161
// Download manifests if defined by devflags
6262
// Go through each manifest and set the overlays if defined
6363
for _, subcomponent := range k.DevFlags.Manifests {
6464
if strings.Contains(subcomponent.URI, DependentComponentName) {
6565
// Download subcomponent
66-
if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil {
66+
if err := deploy.DownloadManifests(ctx, DependentComponentName, subcomponent); err != nil {
6767
return err
6868
}
6969
// If overlay is defined, update paths
@@ -76,7 +76,7 @@ func (k *Kserve) OverrideManifests(_ string) error {
7676

7777
if strings.Contains(subcomponent.URI, ComponentName) {
7878
// Download subcomponent
79-
if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil {
79+
if err := deploy.DownloadManifests(ctx, ComponentName, subcomponent); err != nil {
8080
return err
8181
}
8282
// If overlay is defined, update paths
@@ -110,17 +110,17 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
110110
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
111111

112112
if !enabled {
113-
if err := k.removeServerlessFeatures(dscispec); err != nil {
113+
if err := k.removeServerlessFeatures(ctx, dscispec); err != nil {
114114
return err
115115
}
116116
} else {
117117
// Configure dependencies
118-
if err := k.configureServerless(dscispec); err != nil {
118+
if err := k.configureServerless(ctx, dscispec); err != nil {
119119
return err
120120
}
121121
if k.DevFlags != nil {
122122
// Download manifests and update paths
123-
if err := k.OverrideManifests(string(platform)); err != nil {
123+
if err := k.OverrideManifests(ctx, string(platform)); err != nil {
124124
return err
125125
}
126126
}
@@ -133,11 +133,11 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
133133
}
134134
}
135135

136-
if err := k.configureServiceMesh(cli, dscispec); err != nil {
136+
if err := k.configureServiceMesh(ctx, cli, dscispec); err != nil {
137137
return fmt.Errorf("failed configuring service mesh while reconciling kserve component. cause: %w", err)
138138
}
139139

140-
if err := deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
140+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
141141
return fmt.Errorf("failed to apply manifests from %s : %w", Path, err)
142142
}
143143

@@ -160,7 +160,7 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
160160
}
161161
}
162162

163-
if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
163+
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, DependentPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
164164
if !strings.Contains(err.Error(), "spec.selector") || !strings.Contains(err.Error(), "field is immutable") {
165165
// explicitly ignore error if error contains keywords "spec.selector" and "field is immutable" and return all other error.
166166
return err
@@ -186,10 +186,10 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
186186
return nil
187187
}
188188

189-
func (k *Kserve) Cleanup(cli client.Client, dscispec *dsciv1.DSCInitializationSpec) error {
190-
if removeServerlessErr := k.removeServerlessFeatures(dscispec); removeServerlessErr != nil {
189+
func (k *Kserve) Cleanup(ctx context.Context, cli client.Client, instance *dsciv1.DSCInitializationSpec) error {
190+
if removeServerlessErr := k.removeServerlessFeatures(ctx, instance); removeServerlessErr != nil {
191191
return removeServerlessErr
192192
}
193193

194-
return k.removeServiceMeshConfigurations(cli, dscispec)
194+
return k.removeServiceMeshConfigurations(ctx, cli, instance)
195195
}

0 commit comments

Comments
 (0)