Skip to content

Commit

Permalink
Remove fleetshard add-on and cleanup standalone provider (#1486)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer authored Nov 21, 2023
1 parent 2596c3c commit 0bb2e48
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 1,677 deletions.
59 changes: 0 additions & 59 deletions internal/dinosaur/pkg/clusters/ocm_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/stackrox/acs-fleet-manager/internal/dinosaur/pkg/clusters/types"
"github.com/stackrox/acs-fleet-manager/pkg/client/ocm"

"github.com/golang/glog"
clustersmgmtv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/pkg/errors"
"github.com/stackrox/acs-fleet-manager/pkg/api"
Expand Down Expand Up @@ -100,64 +99,6 @@ func (o *OCMProvider) GetClusterDNS(clusterSpec *types.ClusterSpec) (string, err
return clusterDNS, nil
}

// InstallDinosaurOperator ...
func (o *OCMProvider) InstallDinosaurOperator(clusterSpec *types.ClusterSpec) (bool, error) {
return o.installAddon(clusterSpec, o.ocmConfig.CentralOperatorAddonID)
}

// InstallFleetshard ...
func (o *OCMProvider) InstallFleetshard(clusterSpec *types.ClusterSpec, params []types.Parameter) (bool, error) {
return o.installAddonWithParams(clusterSpec, o.ocmConfig.FleetshardAddonID, params)
}

func (o *OCMProvider) installAddon(clusterSpec *types.ClusterSpec, addonID string) (bool, error) {
clusterID := clusterSpec.InternalID
addonInstallation, err := o.ocmClient.GetAddon(clusterID, addonID)
if err != nil {
return false, errors.Wrapf(err, "failed to get addon %s for cluster %s", addonID, clusterSpec.InternalID)
}

// Addon needs to be installed if addonInstallation doesn't exist
if addonInstallation.ID() == "" {
addonInstallation, err = o.ocmClient.CreateAddon(clusterID, addonID)
if err != nil {
return false, errors.Wrapf(err, "failed to create addon %s for cluster %s", addonID, clusterSpec.InternalID)
}
}

// The cluster is ready when the state reports ready
if addonInstallation.State() == clustersmgmtv1.AddOnInstallationStateReady {
return true, nil
}

return false, nil
}

func (o *OCMProvider) installAddonWithParams(clusterSpec *types.ClusterSpec, addonID string, params []types.Parameter) (bool, error) {
addonInstallation, addonErr := o.ocmClient.GetAddon(clusterSpec.InternalID, addonID)
if addonErr != nil {
return false, errors.Wrapf(addonErr, "failed to get addon %s for cluster %s", addonID, clusterSpec.InternalID)
}

if addonInstallation != nil && addonInstallation.ID() == "" {
glog.V(5).Infof("No existing %s addon found, create a new one", addonID)
addonInstallation, addonErr = o.ocmClient.CreateAddonWithParams(clusterSpec.InternalID, addonID, params)
if addonErr != nil {
return false, errors.Wrapf(addonErr, "failed to create addon %s for cluster %s", addonID, clusterSpec.InternalID)
}
}

if addonInstallation != nil && addonInstallation.State() == clustersmgmtv1.AddOnInstallationStateReady {
addonInstallation, addonErr = o.ocmClient.UpdateAddonParameters(clusterSpec.InternalID, addonInstallation.ID(), params)
if addonErr != nil {
return false, errors.Wrapf(addonErr, "failed to update parameters for addon %s on cluster %s", addonInstallation.ID(), clusterSpec.InternalID)
}
return true, nil
}

return false, nil
}

// GetCloudProviders ...
func (o *OCMProvider) GetCloudProviders() (*types.CloudProviderInfoList, error) {
list := types.CloudProviderInfoList{}
Expand Down
4 changes: 0 additions & 4 deletions internal/dinosaur/pkg/clusters/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ type Provider interface {
GetCloudProviders() (*types.CloudProviderInfoList, error)
// GetCloudProviderRegions Get the regions information for the given cloud provider from the cluster provider
GetCloudProviderRegions(providerInf types.CloudProviderInfo) (*types.CloudProviderRegionInfoList, error)
// InstallDinosaurOperator Install the dinosaur operator in a given cluster
InstallDinosaurOperator(clusterSpec *types.ClusterSpec) (bool, error)
// InstallFleetshard Install the cluster logging operator for a given cluster
InstallFleetshard(clusterSpec *types.ClusterSpec, params []types.Parameter) (bool, error)
}

// ProviderFactory used to return an instance of Provider implementation
Expand Down
95 changes: 0 additions & 95 deletions internal/dinosaur/pkg/clusters/provider_moq.go

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

Loading

0 comments on commit 0bb2e48

Please sign in to comment.