-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shubham <[email protected]>
- Loading branch information
1 parent
76a9616
commit b101a67
Showing
1,643 changed files
with
213,676 additions
and
143,685 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,82 @@ | ||
/* | ||
Copyright 2021 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 executor | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/openebs/maya/pkg/util" | ||
"github.com/spf13/cobra" | ||
"k8s.io/klog" | ||
|
||
upgrade "github.com/openebs/upgrade/pkg/upgrade" | ||
"github.com/openebs/upgrade/pkg/version" | ||
errors "github.com/pkg/errors" | ||
) | ||
|
||
var ( | ||
jivaVolumeUpgradeCmdHelpText = ` | ||
This command upgrades the jiva volume | ||
Usage: upgrade jiva-volume --options... <volume-name>... | ||
` | ||
) | ||
|
||
// NewUpgradeJivaVolumeJob upgrades Jiva Volumes | ||
func NewUpgradeJivaVolumeJob() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "jiva-volume", | ||
Short: "Upgrade Jiva Volume", | ||
Long: jivaVolumeUpgradeCmdHelpText, | ||
Example: `upgrade jiva-volume <spc-name>...`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
util.Fatal("failed to upgrade: no volume name provided") | ||
} | ||
for _, name := range args { | ||
options.resourceKind = "jivaVolume" | ||
util.CheckErr(options.RunPreFlightChecks(cmd), util.Fatal) | ||
util.CheckErr(options.InitializeDefaults(cmd), util.Fatal) | ||
util.CheckErr(options.RunJivaVolumeUpgrade(cmd, name), util.Fatal) | ||
} | ||
}, | ||
} | ||
return cmd | ||
} | ||
|
||
// RunJivaVolumeUpgrade upgrades the given Jiva Volume. | ||
func (u *UpgradeOptions) RunJivaVolumeUpgrade(cmd *cobra.Command, name string) error { | ||
|
||
if version.IsCurrentVersionValid(u.fromVersion) && version.IsDesiredVersionValid(u.toVersion) { | ||
klog.Infof("Upgrading %s to %s", name, u.toVersion) | ||
err := upgrade.Exec(u.fromVersion, u.toVersion, | ||
u.resourceKind, | ||
name, | ||
u.openebsNamespace, | ||
u.imageURLPrefix, | ||
u.toVersionImageTag) | ||
if err != nil { | ||
klog.Error(err) | ||
return errors.Errorf("Failed to upgrade JivaVolume %v", name) | ||
} | ||
klog.Infof("Successfully upgraded %s to %s", name, u.toVersion) | ||
} else { | ||
fmt.Println(version.IsCurrentVersionValid(u.fromVersion), version.IsDesiredVersionValid(u.toVersion)) | ||
return errors.Errorf("Invalid from version %s or to version %s", u.fromVersion, u.toVersion) | ||
} | ||
return nil | ||
} |
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,78 @@ | ||
# 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. | ||
|
||
# This is an example YAML for upgrading cstor volume. | ||
# Some of the values below needs to be changed to | ||
# match your openebs installation. The fields are | ||
# indicated with VERIFY | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
# VERIFY that you have provided a unique name for this upgrade job. | ||
# The name can be any valid K8s string for name. | ||
name: jiva-volume-upgrade | ||
|
||
# VERIFY the value of namespace is same as the namespace where openebs components | ||
# are installed. You can verify using the command: | ||
# `kubectl get pods -n <openebs-namespace> -l openebs.io/component-name=maya-apiserver` | ||
# The above command should return status of the openebs-apiserver. | ||
namespace: openebs | ||
spec: | ||
template: | ||
spec: | ||
# VERIFY the value of serviceAccountName is pointing to service account | ||
# created within openebs namespace. Use the non-default account. | ||
# by running `kubectl get sa -n <openebs-namespace>` | ||
serviceAccountName: openebs-maya-operator | ||
containers: | ||
- name: upgrade | ||
args: | ||
- "jiva-volume" | ||
|
||
# --from-version is the current version of the volume | ||
- "--from-version=2.6.0" | ||
|
||
# --to-version is the version desired upgrade version | ||
- "--to-version=2.7.0" | ||
# if required the image prefix of the volume deployments can be | ||
# changed using the flag below, defaults to whatever was present on old | ||
# deployments. | ||
#- "--to-version-image-prefix=openebs/" | ||
# if required the image tags for volume deployments can be changed | ||
# to a custom image tag using the flag below, | ||
# defaults to the --to-version mentioned above. | ||
#- "--to-version-image-tag=ci" | ||
|
||
# VERIFY that you have provided the correct list of volume Names | ||
- "pvc-1d4f7cf6-9da6-433a-a2f6-b22bdeb592f0" | ||
|
||
# Following are optional parameters | ||
# Log Level | ||
- "--v=4" | ||
# DO NOT CHANGE BELOW PARAMETERS | ||
env: | ||
- name: OPENEBS_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
tty: true | ||
|
||
# the image version should be same as the --to-version mentioned above | ||
# in the args of the job | ||
image: openebs/upgrade:<same-as-to-version> | ||
imagePullPolicy: IfNotPresent | ||
restartPolicy: OnFailure | ||
--- | ||
|
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.