make getModifiedRookImagePath be generic and use it for isgw too

Signed-off-by: Dmitry Yusupov <dmitry.yusupov@nexenta.com>
This commit is contained in:
Dmitry Yusupov committed 2019-07-22 10:07:22 -07:00
1 parent 6ce0532768
commit a3d02fb6ea
3 files changed
+30 -30

No files matched your search

+27
View File
@@ -17,6 +17,7 @@ package v1beta1
import (
"fmt"
"strings"
)
func ByteCountBinary(b uint64) string {
@@ -31,3 +32,29 @@ func ByteCountBinary(b uint64) string {
}
return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp])
}
// GetModifiedRookImagePath takes current edgefs path to provide modified path to specific images
// I.e in case of original edgefs path: edgefs/edgefs:1.2.25 then edgefs ui path should be
// edgefs/edgefs-ui:1.2.25 and edgefs-restapi should be edgefs/edgefs-restapi:1.2.25
// addon param is edgefs image suffix. To get restapi image path getModifiedRookImagePath(edgefsImage, "restapi")
func GetModifiedRookImagePath(originRookImage, addon string) string {
imageParts := strings.Split(originRookImage, "/")
latestImagePartIndex := len(imageParts) - 1
modifiedImageName := "edgefs"
modifiedImageTag := "latest"
latestImagePart := imageParts[latestImagePartIndex]
imageVersionParts := strings.Split(latestImagePart, ":")
if len(imageVersionParts) > 1 {
modifiedImageTag = imageVersionParts[1]
}
if len(addon) > 0 {
modifiedImageName = fmt.Sprintf("%s-%s", imageVersionParts[0], addon)
} else {
modifiedImageName = fmt.Sprintf("%s", imageVersionParts[0])
}
imageParts[latestImagePartIndex] = fmt.Sprintf("%s:%s", modifiedImageName, modifiedImageTag)
return strings.Join(imageParts, "/")
}
+2 -29
View File
@@ -21,7 +21,6 @@ import (
"fmt"
"net"
"strconv"
"strings"
"github.com/coreos/pkg/capnslog"
edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1"
@@ -286,32 +285,6 @@ func (c *Cluster) makeUIService(name string) *v1.Service {
return svc
}
// getModifiedRookImagePath takes current edgefs path to provide modified path to specific images
// I.e in case of original edgefs path: edgefs/edgefs:1.1.215 then edgefs ui path should be
// edgefs/edgefs-ui:1.1.215 and edgefs-restapi should be edgefs/edgefs-restapi:1.1.215
// addon param is edgefs image suffix. To get restapi image path getModifiedRookImagePath(edgefsImage, "restapi")
func getModifiedRookImagePath(originRookImage, addon string) string {
imageParts := strings.Split(originRookImage, "/")
latestImagePartIndex := len(imageParts) - 1
modifiedImageName := "edgefs"
modifiedImageTag := "latest"
latestImagePart := imageParts[latestImagePartIndex]
imageVersionParts := strings.Split(latestImagePart, ":")
if len(imageVersionParts) > 1 {
modifiedImageTag = imageVersionParts[1]
}
if len(addon) > 0 {
modifiedImageName = fmt.Sprintf("%s-%s", imageVersionParts[0], addon)
} else {
modifiedImageName = fmt.Sprintf("%s", imageVersionParts[0])
}
imageParts[latestImagePartIndex] = fmt.Sprintf("%s:%s", modifiedImageName, modifiedImageTag)
return strings.Join(imageParts, "/")
}
func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas int32) *apps.Deployment {
volumes := []v1.Volume{}
@@ -345,9 +318,9 @@ func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas i
Spec: v1.PodSpec{
ServiceAccountName: c.serviceAccount,
Containers: []v1.Container{
c.mgmtContainer(name, getModifiedRookImagePath(rookImage, "restapi")),
c.mgmtContainer(name, edgefsv1beta1.GetModifiedRookImagePath(rookImage, "restapi")),
c.mgrContainer("grpc", rookImage),
c.uiContainer("ui", getModifiedRookImagePath(rookImage, "ui")),
c.uiContainer("ui", edgefsv1beta1.GetModifiedRookImagePath(rookImage, "ui")),
},
RestartPolicy: v1.RestartPolicyAlways,
Volumes: volumes,
+1 -1
View File
@@ -208,7 +208,7 @@ func (c *ISGWController) makeDeployment(svcname, namespace, rookImage string, is
Labels: getLabels(name, svcname, namespace),
},
Spec: v1.PodSpec{
Containers: []v1.Container{c.isgwContainer(svcname, name, rookImage, isgwSpec)},
Containers: []v1.Container{c.isgwContainer(svcname, name, edgefsv1beta1.GetModifiedRookImagePath(rookImage, "isgw"), isgwSpec)},
RestartPolicy: v1.RestartPolicyAlways,
Volumes: volumes,
HostIPC: true,