-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cspi conditions): add cspi condition to represent the pool oper…
…ations (#31) This PR adds the conditions to represent pool operations in status part - Failure in Pool Import is represent in PoolLost condition - PoolExpansion process is represented in PoolExpansion condition - DiskReplacement process is represented in disk replacement process Signed-off-by: mittachaitu <[email protected]>
- Loading branch information
sai chaithanya
authored
Apr 29, 2020
1 parent
3d04441
commit e675b34
Showing
12 changed files
with
654 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
apiVersion: cstor.openebs.io/v1 | ||
kind: CStorPoolInstance | ||
metadata: | ||
name: cspi-stripe | ||
namespace: openebs | ||
spec: | ||
pools: | ||
- nodeSelector: | ||
kubernetes.io/hostname: "gke-cstor-demo-default-pool-3385ab41-5swq" | ||
dataRaidGroups: | ||
- blockDevices: | ||
- blockDeviceName: "sparse-1e3a8da94af49e16d937d867777699b0" | ||
poolConfig: | ||
defaultRaidGroupType: "stripe" | ||
|
||
- nodeSelector: | ||
kubernetes.io/hostname: "gke-cstor-demo-default-pool-3385ab41-j90d" | ||
dataRaidGroups: | ||
- blockDevices: | ||
- blockDeviceName: "sparse-8935fde3557f1d04dd8c01a635f3c51f" | ||
poolConfig: | ||
defaultRaidGroupType: "stripe" | ||
|
||
- nodeSelector: | ||
kubernetes.io/hostname: "gke-cstor-demo-default-pool-3385ab41-sr33" | ||
dataRaidGroups: | ||
- blockDevices: | ||
- blockDeviceName: "sparse-a0f9a34f5d9133078b4a6b7f341133ea" | ||
poolConfig: | ||
defaultRaidGroupType: "stripe" | ||
kind: CStorPoolInstance | ||
metadata: | ||
labels: | ||
kubernetes.io/hostname: 127.0.0.1 | ||
openebs.io/cas-type: cstor | ||
openebs.io/cstor-pool-cluster: cstor-sparse-pool | ||
openebs.io/version: 1.9.0 | ||
name: cstor-mirror-pool | ||
namespace: openebs | ||
spec: | ||
dataRaidGroups: | ||
- blockDevices: | ||
- blockDeviceName: sparse-5a92ced3e2ee21eac7b930f670b5eab5 | ||
- blockDeviceName: sparse-37a7de580322f43a13338bf2467343f5 | ||
- blockDevices: | ||
- blockDeviceName: sparse-72971f3b2e173c1b79db9a43e4cb841f | ||
- blockDeviceName: sparse-a205e38ff5ec89c223654fdf1361f182 | ||
hostName: 127.0.0.1 | ||
nodeSelector: | ||
kubernetes.io/hostname: 127.0.0.1 | ||
poolConfig: | ||
auxResources: null | ||
compression: "" | ||
dataRaidGroupType: mirror | ||
priorityClassName: "" | ||
resources: null | ||
roThresholdLimit: null | ||
thickProvision: false | ||
tolerations: null | ||
writeCacheGroupType: "" | ||
writeCacheRaidGroups: null |
This file was deleted.
Oops, something went wrong.
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
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,86 @@ | ||
/* | ||
Copyright 2020 The OpenEBS Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cspicontroller | ||
|
||
import ( | ||
"time" | ||
|
||
cstor "github.com/openebs/api/pkg/apis/cstor/v1" | ||
cspiutil "github.com/openebs/cstor-operators/pkg/controllers/cspi-controller/util" | ||
"github.com/pkg/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/klog" | ||
) | ||
|
||
//TODO: Update the code to use patch instead of Update call | ||
|
||
// UpdateStatusConditionEventually updates the CSPI in etcd with provided | ||
// condition. Below function retries for three times to update the CSPI with | ||
// provided conditions | ||
func (c *CStorPoolInstanceController) UpdateStatusConditionEventually( | ||
cspi *cstor.CStorPoolInstance, | ||
condition cstor.CStorPoolInstanceCondition) (*cstor.CStorPoolInstance, error) { | ||
maxRetry := 3 | ||
cspiCopy := cspi.DeepCopy() | ||
updatedCSPI, err := c.UpdateStatusCondition(cspiCopy, condition) | ||
if err != nil { | ||
klog.Errorf( | ||
"failed to update CSPI %s status with condition %s will retry %d times at 2s interval: {%s}", | ||
cspi.Name, condition.Type, maxRetry, err.Error()) | ||
|
||
for maxRetry > 0 { | ||
newCSPI, err := c.clientset. | ||
CstorV1(). | ||
CStorPoolInstances(cspi.Namespace). | ||
Get(cspi.Name, metav1.GetOptions{}) | ||
if err != nil { | ||
// This is possible due to etcd unavailability so do not retry more here | ||
return cspi, errors.Wrapf(err, "failed to update cspi status") | ||
} | ||
updatedCSPI, err = c.UpdateStatusCondition(newCSPI, condition) | ||
if err != nil { | ||
maxRetry = maxRetry - 1 | ||
klog.Errorf( | ||
"failed to update CSPI %s status with condition %s will retry %d times at 2s interval: {%s}", | ||
cspi.Name, condition.Type, maxRetry, err.Error()) | ||
time.Sleep(2 * time.Second) | ||
continue | ||
} | ||
return updatedCSPI, nil | ||
} | ||
// When retries are completed and still failed to update in etcd | ||
// then it will return original object | ||
return cspi, err | ||
} | ||
return updatedCSPI, nil | ||
} | ||
|
||
func (c *CStorPoolInstanceController) UpdateStatusCondition( | ||
cspi *cstor.CStorPoolInstance, | ||
condition cstor.CStorPoolInstanceCondition) (*cstor.CStorPoolInstance, error) { | ||
cspiutil.SetCSPICondition(&cspi.Status, condition) | ||
updatedCSPI, err := c.clientset. | ||
CstorV1(). | ||
CStorPoolInstances(cspi.Namespace). | ||
Update(cspi) | ||
if err != nil { | ||
// cspi object has already updated with the conditions so returning | ||
// same object may or maynot make sense | ||
return nil, errors.Wrapf(err, "failed to update cspi conditions") | ||
} | ||
return updatedCSPI, nil | ||
} |
Oops, something went wrong.