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 devflags empty object #659

Merged
merged 1 commit into from
Dec 14, 2023
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 apis/dscinitialization/v1/dscinitialization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type DSCInitializationSpec struct {
// This is not recommended to be used in production environment.
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=4
// +optional
DevFlags DevFlags `json:"devFlags,omitempty"`
DevFlags *DevFlags `json:"devFlags,omitempty"`
}

type Monitoring struct {
Expand Down
8 changes: 6 additions & 2 deletions apis/dscinitialization/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ func (c *CodeFlare) ReconcileComponent(ctx context.Context, cli client.Client, r
return err
}
if enabled {
// Download manifests and update paths
if err = c.OverrideManifests(string(platform)); err != nil {
return err
if c.DevFlags != nil {
// Download manifests and update paths
if err = c.OverrideManifests(string(platform)); err != nil {
return err
}
}

// check if the CodeFlare operator is installed: it should not be installed
dependentOperator := CodeflareOperator
// overwrite dependent operator if downstream not match upstream
Expand All @@ -88,7 +89,7 @@ func (c *CodeFlare) ReconcileComponent(ctx context.Context, cli client.Client, r
}

// Update image parameters only when we do not have customized manifests set
if dscispec.DevFlags.ManifestsUri == "" && len(c.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (c.DevFlags == nil || len(c.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(CodeflarePath+"/bases", c.SetImageParamsMap(imageParamMap), true); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Component struct {
// Add developer fields
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=2
DevFlags DevFlags `json:"devFlags,omitempty"`
DevFlags *DevFlags `json:"devFlags,omitempty"`
}

func (c *Component) GetManagementState() operatorv1.ManagementState {
Expand Down
12 changes: 6 additions & 6 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
if err := d.cleanOauthClient(cli, dscispec, currentComponentExist); err != nil {
return err
}

// Download manifests and update paths
if err := d.OverrideManifests(string(platform)); err != nil {
return err
if d.DevFlags != nil {
// Download manifests and update paths
if err := d.OverrideManifests(string(platform)); err != nil {
return err
}
}

if platform == deploy.OpenDataHub || platform == "" {
err := cluster.UpdatePodSecurityRolebinding(cli, dscispec.ApplicationsNamespace, "odh-dashboard")
if err != nil {
Expand Down Expand Up @@ -137,7 +137,7 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
}

// Update image parameters (ODH does not use this solution, only downstream)
if dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (d.DevFlags == nil || len(d.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(PathSupported, d.SetImageParamsMap(imageParamMap), false); err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
return err
}
if enabled {
// Download manifests and update paths
if err = d.OverrideManifests(string(platform)); err != nil {
return err
if d.DevFlags != nil {
// Download manifests and update paths
if err = d.OverrideManifests(string(platform)); err != nil {
return err
}
}

// skip check if the dependent operator has beeninstalled, this is done in dashboard

// Update image parameters only when we do not have customized manifests set
if dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (d.DevFlags == nil || len(d.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(Path, d.SetImageParamsMap(imageParamMap), false); err != nil {
return err
}
Expand Down
61 changes: 30 additions & 31 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,32 @@ type Kserve struct {

func (k *Kserve) OverrideManifests(_ string) error {
// Download manifests if defined by devflags
if len(k.DevFlags.Manifests) != 0 {
// Go through each manifests and set the overlays if defined
for _, subcomponent := range k.DevFlags.Manifests {
if strings.Contains(subcomponent.URI, DependentComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "base"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
DependentPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath)
// Go through each manifests and set the overlays if defined
for _, subcomponent := range k.DevFlags.Manifests {
if strings.Contains(subcomponent.URI, DependentComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "base"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
DependentPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath)
}

if strings.Contains(subcomponent.URI, ComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "overlays/odh"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
if strings.Contains(subcomponent.URI, ComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "overlays/odh"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
}

Expand Down Expand Up @@ -104,11 +102,12 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client, resC
return err
}
} else {
// Download manifests and update paths
if err = k.OverrideManifests(string(platform)); err != nil {
return err
if k.DevFlags != nil {
// Download manifests and update paths
if err = k.OverrideManifests(string(platform)); err != nil {
return err
}
}

// check on dependent operators if all installed in cluster
dependOpsErrors := checkDepedentOps(cli).ErrorOrNil()
if dependOpsErrors != nil {
Expand All @@ -120,7 +119,7 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client, resC
}

// Update image parameters only when we do not have customized manifests set
if dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (k.DevFlags == nil || len(k.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(Path, k.SetImageParamsMap(imageParamMap), false); err != nil {
return err
}
Expand All @@ -137,7 +136,7 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client, resC
return err
}
// Update image parameters for odh-model-controller
if dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (k.DevFlags == nil || len(k.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(DependentPath, k.SetImageParamsMap(dependentParamMap), false); err != nil {
return err
}
Expand Down
13 changes: 7 additions & 6 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (m *ModelMeshServing) OverrideManifests(_ string) error {
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
}

return nil
}

Expand Down Expand Up @@ -101,9 +100,11 @@ func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,

// Update Default rolebinding
if enabled {
// Download manifests and update paths
if err = m.OverrideManifests(string(platform)); err != nil {
return err
if m.DevFlags != nil {
// Download manifests and update paths
if err = m.OverrideManifests(string(platform)); err != nil {
return err
}
}

if err := cluster.UpdatePodSecurityRolebinding(cli, dscispec.ApplicationsNamespace,
Expand All @@ -114,7 +115,7 @@ func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,
return err
}
// Update image parameters
if dscispec.DevFlags.ManifestsUri == "" && len(m.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (m.DevFlags == nil || len(m.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(Path, m.SetImageParamsMap(imageParamMap), false); err != nil {
return err
}
Expand All @@ -133,7 +134,7 @@ func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,
return err
}
// Update image parameters for odh-model-controller
if dscispec.DevFlags.ManifestsUri == "" {
if dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "" {
if err := deploy.ApplyParams(DependentPath, m.SetImageParamsMap(dependentImageParamMap), false); err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions components/ray/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ func (r *Ray) ReconcileComponent(ctx context.Context, cli client.Client, resConf
}

if enabled {
// Download manifests and update paths
if err = r.OverrideManifests(string(platform)); err != nil {
return err
if r.DevFlags != nil {
// Download manifests and update paths
if err = r.OverrideManifests(string(platform)); err != nil {
return err
}
}

if dscispec.DevFlags.ManifestsUri == "" || len(r.DevFlags.Manifests) == 0 {
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (r.DevFlags == nil || len(r.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(RayPath, r.SetImageParamsMap(imageParamMap), true); err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, re
}

if enabled {
// Download manifests and update paths
if err = t.OverrideManifests(string(platform)); err != nil {
return err
if t.DevFlags != nil {
// Download manifests and update paths
if err = t.OverrideManifests(string(platform)); err != nil {
return err
}
}

if dscispec.DevFlags.ManifestsUri == "" {
if dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "" {
if err := deploy.ApplyParams(Path, t.SetImageParamsMap(imageParamMap), false); err != nil {
return err
}
Expand Down
Loading
Loading