This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from darkowlzz/fix-cluster-status-update
cluster: fix cluster status update
- Loading branch information
Showing
16 changed files
with
1,702 additions
and
1,595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package storageoscluster | ||
|
||
import ( | ||
storageosv1alpha1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" | ||
"github.com/storageos/cluster-operator/pkg/storageos" | ||
) | ||
|
||
// StorageOSCluster stores the current cluster's information. It binds the | ||
// cluster and the deployment together, ensuring deployment interacts with the | ||
// right cluster resource. | ||
type StorageOSCluster struct { | ||
cluster *storageosv1alpha1.StorageOSCluster | ||
// deployment implements storageoscluster.Deployment interface. This is | ||
// cached for a cluster to avoid recreating it without any change to the | ||
// cluster object. Every new cluster will create its unique deployment. | ||
deployment Deployment | ||
} | ||
|
||
// NewStorageOSCluster creates a new StorageOSCluster object. | ||
func NewStorageOSCluster(cluster *storageosv1alpha1.StorageOSCluster) *StorageOSCluster { | ||
return &StorageOSCluster{cluster: cluster} | ||
} | ||
|
||
// SetDeployment creates a new StorageOS Deployment and sets it for the current | ||
// StorageOSCluster. | ||
func (c *StorageOSCluster) SetDeployment(r *ReconcileStorageOSCluster) { | ||
// updateIfExists is set to false because we don't update any existing | ||
// resources for now. May change in future. | ||
// TODO: Change this after resolving the conflict between two way | ||
// binding and upgrade. | ||
updateIfExists := false | ||
c.deployment = storageos.NewDeployment(r.client, c.cluster, r.recorder, r.scheme, r.k8sVersion, updateIfExists) | ||
} | ||
|
||
// IsCurrentCluster compares the cluster attributes to check if the given | ||
// cluster is the same as the current cluster. | ||
func (c *StorageOSCluster) IsCurrentCluster(cluster *storageosv1alpha1.StorageOSCluster) bool { | ||
if (c.cluster.GetName() == cluster.GetName()) && | ||
(c.cluster.GetNamespace() == cluster.GetNamespace()) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// Deploy deploys the StorageOS cluster. | ||
func (c *StorageOSCluster) Deploy(r *ReconcileStorageOSCluster) error { | ||
if c.deployment == nil { | ||
c.SetDeployment(r) | ||
} | ||
return c.deployment.Deploy() | ||
} | ||
|
||
// DeleteDeployment deletes the StorageOS Cluster deployment. | ||
func (c *StorageOSCluster) DeleteDeployment() error { | ||
return c.deployment.Delete() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package storageoscluster | ||
|
||
// Deployment is an interface for deployment of a cluster. | ||
type Deployment interface { | ||
// Deploy deploys a cluster. | ||
Deploy() error | ||
// Delete deletes a deployed cluster. | ||
Delete() error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.