Skip to content

Commit

Permalink
Merge pull request #500 from MUzairS15/MUzairS15/deployment
Browse files Browse the repository at this point in the history
[Deployments] Support configuring upgrades during provisioning.
  • Loading branch information
Mohd Uzair authored Jun 3, 2024
2 parents 91538ac + 11d3bd5 commit 37f19fa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions models/meshmodel/core/v1beta1/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func (h *Host) AfterFind(tx *gorm.DB) error {
// Each host from where meshmodels can be generated needs to implement this interface
// HandleDependents, contains host specific logic for provisioning required CRDs/operators for corresponding components.
type IHost interface {
HandleDependents(comp Component, kc *kubernetes.Client, isDeploy bool) (string, error)
HandleDependents(comp Component, kc *kubernetes.Client, isDeploy, performUpgrade bool) (string, error)
String() string
}

type ArtifactHub struct{}

func (ah ArtifactHub) HandleDependents(comp Component, kc *kubernetes.Client, isDeploy bool) (summary string, err error) {
func (ah ArtifactHub) HandleDependents(comp Component, kc *kubernetes.Client, isDeploy, performUpgrade bool) (summary string, err error) {
source_uri := comp.Annotations[fmt.Sprintf("%s.model.source_uri", MesheryAnnotationPrefix)]
act := kubernetes.UNINSTALL
if isDeploy {
Expand All @@ -116,11 +116,11 @@ func (ah ArtifactHub) HandleDependents(comp Component, kc *kubernetes.Client, is

if source_uri != "" {
err = kc.ApplyHelmChart(kubernetes.ApplyHelmChartConfig{
URL: source_uri,
Namespace: comp.Namespace,
CreateNamespace: true,
Action: act,
SkipUpgradeIfInstalled: true,
URL: source_uri,
Namespace: comp.Namespace,
CreateNamespace: true,
Action: act,
UpgradeIfInstalled: performUpgrade,
})
if err != nil {
if !isDeploy {
Expand All @@ -145,7 +145,7 @@ func (ah ArtifactHub) String() string {

type Kubernetes struct{}

func (k Kubernetes) HandleDependents(comp Component, kc *kubernetes.Client, isDeploy bool) (summary string, err error) {
func (k Kubernetes) HandleDependents(comp Component, kc *kubernetes.Client, isDeploy, performUpgrade bool) (summary string, err error) {
return summary, err
}

Expand Down
2 changes: 1 addition & 1 deletion models/meshmodel/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (rm *RegistryManager) RegisterEntity(h v1beta1.Host, en entity.Entity) erro
return nil
}

// UpdateEntityIgnoreStatus updates the ignore status of an entity based on the provided parameters.
// UpdateEntityStatus updates the ignore status of an entity based on the provided parameters.
// By default during models generation ignore is set to false
func (rm *RegistryManager) UpdateEntityStatus(ID string, status string, entityType string) error {
// Convert string UUID to google UUID
Expand Down
6 changes: 3 additions & 3 deletions utils/kubernetes/apply-helm-chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type ApplyHelmChartConfig struct {
// SkipCRDs while installation
SkipCRDs bool

// Skip upgrade, if release is already installed
SkipUpgradeIfInstalled bool
// Upgrade the release if already installed
UpgradeIfInstalled bool

// URL is the url for charts
//
Expand Down Expand Up @@ -268,7 +268,7 @@ func (client *Client) ApplyHelmChart(cfg ApplyHelmChartConfig) error {

// Before installing a helm chart, check if it already exists in the cluster
// this is a workaround make the helm chart installation idempotent
if cfg.Action == INSTALL && !cfg.SkipUpgradeIfInstalled {
if cfg.Action == INSTALL && cfg.UpgradeIfInstalled {
if err := updateActionIfReleaseFound(actionConfig, &cfg, *helmChart); err != nil {
return ErrApplyHelmChart(err)
}
Expand Down

0 comments on commit 37f19fa

Please sign in to comment.