Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #211 from IBM/release_v1.2.0
Browse files Browse the repository at this point in the history
Release v1.2.0
  • Loading branch information
shay-berman authored Sep 16, 2018
2 parents 8e2cb6e + 9350ac9 commit f45eba3
Show file tree
Hide file tree
Showing 56 changed files with 4,953 additions and 2,607 deletions.
7 changes: 3 additions & 4 deletions Dockerfile.Flex
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
FROM golang:1.9.1
WORKDIR /go/src/github.com/IBM/ubiquity-k8s/
COPY . .
RUN go get -v github.com/Masterminds/glide
ADD glide.yaml .
RUN glide up --strip-vendor
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -tags netgo -v -a --ldflags '-w -linkmode external -extldflags "-static"' -installsuffix cgo -o ubiquity-k8s-flex cmd/flex/main/cli.go


FROM alpine:3.7
RUN apk --no-cache add ca-certificates=20171114-r0
RUN apk --update add logrotate
ENV UBIQUITY_PLUGIN_VERIFY_CA=/var/lib/ubiquity/ssl/public/ubiquity-trusted-ca.crt
WORKDIR /root/
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/deploy/k8s_deployments/ubiquity_logrotate /etc/logrotate.d/
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/ubiquity-k8s-flex .
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/deploy/k8s_deployments/setup_flex.sh .
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/scripts/setup_flex.sh .
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/LICENSE .
COPY --from=0 /go/src/github.com/IBM/ubiquity-k8s/scripts/notices_file_for_ibm_storage_enabler_for_containers ./NOTICES
3 changes: 2 additions & 1 deletion Dockerfile.Provisioner
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM golang:1.9.1
WORKDIR /go/src/github.com/IBM/ubiquity-k8s/
COPY . .
RUN go get -v github.com/Masterminds/glide
ADD glide.yaml .
RUN glide up --strip-vendor
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -tags netgo -v -a --ldflags '-w -linkmode external -extldflags "-static"' -installsuffix cgo -o ubiquity-k8s-provisioner cmd/provisioner/main/main.go


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This project includes components for managing [Kubernetes persistent storage](ht
Currently, the following storage systems use Ubiquity:
* IBM block storage.

The IBM block storage is supported for Kubernetes via IBM Spectrum Connect (3.4.0), previously known as IBM Spectrum Control Base Edition. Ubiquity communicates with the IBM storage systems through Spectrum Connect. Spectrum Connect creates a storage profile (for example, gold, silver or bronze) and makes it available for Kubernetes. For details about supported storage systems, refer to the latest Spectrum Connect release notes.
The IBM block storage is supported for Kubernetes via IBM Spectrum Connect. Ubiquity communicates with the IBM storage systems through Spectrum Connect. Spectrum Connect creates a storage profile (for example, gold, silver or bronze) and makes it available for Kubernetes. For details about supported storage systems, refer to the latest Spectrum Connect release notes.

The IBM official solution for Kubernetes, based on the Ubiquity project, is referred to as IBM Storage Enabler for Containers. You can download the installation package and its documentation from [IBM Fix Central](https://www.ibm.com/support/fixcentral/swg/selectFixes?parent=Software%2Bdefined%2Bstorage&product=ibm/StorageSoftware/IBM+Spectrum+Connect&release=All&platform=Linux&function=all). For details on the IBM Storage Enabler for Containers, see the relevant sections in the Spectrum Connect user guide.

Expand Down
62 changes: 40 additions & 22 deletions cmd/flex/main/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ import (
"flag"
"fmt"
"os"
"path"

"github.com/BurntSushi/toml"
"github.com/IBM/ubiquity-k8s/controller"
flags "github.com/jessevdk/go-flags"

"strconv"

k8sresources "github.com/IBM/ubiquity-k8s/resources"
"github.com/IBM/ubiquity/resources"
"github.com/IBM/ubiquity/remote"
"github.com/IBM/ubiquity/resources"
"github.com/IBM/ubiquity/utils"
"github.com/IBM/ubiquity/utils/logs"
"strconv"
k8sutils "github.com/IBM/ubiquity-k8s/utils"
)

var configFile = flag.String(
Expand Down Expand Up @@ -88,6 +89,9 @@ type AttachCommand struct {
func (a *AttachCommand) Execute(args []string) error {
var version string
var hostname string

requestContext := logs.GetNewRequestContext("Attach")

if len(args) < 1 {

response := k8sresources.FlexVolumeResponse{
Expand Down Expand Up @@ -119,7 +123,7 @@ func (a *AttachCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)

if err != nil {
Expand All @@ -135,7 +139,7 @@ func (a *AttachCommand) Execute(args []string) error {
return printResponse(response)
}

attachRequest := k8sresources.FlexVolumeAttachRequest{Name: volumeName, Host: hostname, Opts: attachRequestOpts, Version: version}
attachRequest := k8sresources.FlexVolumeAttachRequest{Name: volumeName, Host: hostname, Opts: attachRequestOpts, Version: version, Context: requestContext}

attachResponse := controller.Attach(attachRequest)
return printResponse(attachResponse)
Expand All @@ -148,6 +152,7 @@ type WaitForAttachCommand struct {
}

func (wfa *WaitForAttachCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("WaitForAttach")
if len(args) < 2 {

response := k8sresources.FlexVolumeResponse{
Expand All @@ -160,11 +165,11 @@ func (wfa *WaitForAttachCommand) Execute(args []string) error {
if err != nil {
response := k8sresources.FlexVolumeResponse{
Status: "Failure",
Message: fmt.Sprintf("Failed to read config in waitForAttach volume %#v", err),
Message: fmt.Sprintf("Failed to read config in waitForAttach volume %#v ", err),
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)
opts := make(map[string]string)
err = json.Unmarshal([]byte(args[1]), &opts)
Expand All @@ -175,7 +180,7 @@ func (wfa *WaitForAttachCommand) Execute(args []string) error {
}
return printResponse(response)
}
waitForAttachRequest := k8sresources.FlexVolumeWaitForAttachRequest{Name: args[0], Opts: opts}
waitForAttachRequest := k8sresources.FlexVolumeWaitForAttachRequest{Name: args[0], Opts: opts, Context: requestContext}
response := controller.WaitForAttach(waitForAttachRequest)
return printResponse(response)
}
Expand All @@ -187,6 +192,7 @@ type IsAttachedCommand struct {
}

func (d *IsAttachedCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("IsAttached")
if len(args) < 2 {

response := k8sresources.FlexVolumeResponse{
Expand All @@ -203,7 +209,7 @@ func (d *IsAttachedCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)
opts := make(map[string]string)
err = json.Unmarshal([]byte(args[0]), &opts)
Expand All @@ -214,7 +220,7 @@ func (d *IsAttachedCommand) Execute(args []string) error {
}
return printResponse(response)
}
isAttachedRequest := k8sresources.FlexVolumeIsAttachedRequest{Opts: opts, Host: args[1]}
isAttachedRequest := k8sresources.FlexVolumeIsAttachedRequest{Opts: opts, Host: args[1], Context: requestContext}
response := controller.IsAttached(isAttachedRequest)
return printResponse(response)
}
Expand All @@ -227,6 +233,7 @@ type DetachCommand struct {
}

func (d *DetachCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("Detach")
var hostname string
var version string
if len(args) < 1 {
Expand All @@ -253,14 +260,14 @@ func (d *DetachCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)

if err != nil {
panic("backend not found")
}

detachRequest := k8sresources.FlexVolumeDetachRequest{Name: mountDevice, Host: hostname, Version: version}
detachRequest := k8sresources.FlexVolumeDetachRequest{Name: mountDevice, Host: hostname, Version: version, Context: requestContext}
detachResponse := controller.Detach(detachRequest)
return printResponse(detachResponse)
}
Expand All @@ -272,6 +279,7 @@ type MountDeviceCommand struct {
}

func (d *MountDeviceCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("MountDevice")
if len(args) < 3 {

response := k8sresources.FlexVolumeResponse{
Expand All @@ -288,7 +296,7 @@ func (d *MountDeviceCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)
opts := make(map[string]string)
err = json.Unmarshal([]byte(args[2]), &opts)
Expand All @@ -299,7 +307,7 @@ func (d *MountDeviceCommand) Execute(args []string) error {
}
return printResponse(response)
}
mountDeviceRequest := k8sresources.FlexVolumeMountDeviceRequest{Path: args[0], Name: args[1], Opts: opts}
mountDeviceRequest := k8sresources.FlexVolumeMountDeviceRequest{Path: args[0], Name: args[1], Opts: opts, Context: requestContext}
response := controller.MountDevice(mountDeviceRequest)
return printResponse(response)
}
Expand All @@ -311,6 +319,7 @@ type UnmountDeviceCommand struct {
}

func (d *UnmountDeviceCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("UnmountDevice")
if len(args) < 1 {

response := k8sresources.FlexVolumeResponse{
Expand All @@ -327,10 +336,10 @@ func (d *UnmountDeviceCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)

unmountDeviceRequest := k8sresources.FlexVolumeUnmountDeviceRequest{Name: args[0]}
unmountDeviceRequest := k8sresources.FlexVolumeUnmountDeviceRequest{Name: args[0], Context: requestContext}
response := controller.UnmountDevice(unmountDeviceRequest)
return printResponse(response)
}
Expand All @@ -349,6 +358,8 @@ func (m *MountCommand) Execute(args []string) error {
var ok bool
var version string

requestContext := logs.GetNewRequestContext("Mount")

//should error out when not enough args
if len(args) < 2 {

Expand Down Expand Up @@ -394,9 +405,10 @@ func (m *MountCommand) Execute(args []string) error {

mountRequest := k8sresources.FlexVolumeMountRequest{
MountPath: targetMountDir,
MountDevice: volumeName,
MountDevice: volumeName, // The PV name
Opts: mountOpts,
Version: version,
Context: requestContext,
}

config, err := readConfig(*configFile)
Expand All @@ -408,13 +420,14 @@ func (m *MountCommand) Execute(args []string) error {
return printResponse(response)
}

defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()
defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)

if err != nil {
panic("backend not found")
}
mountResponse := controller.Mount(mountRequest)

return printResponse(mountResponse)
}

Expand All @@ -425,6 +438,7 @@ type UnmountCommand struct {
}

func (u *UnmountCommand) Execute(args []string) error {
requestContext := logs.GetNewRequestContext("Unmount")
if len(args) < 1 {

response := k8sresources.FlexVolumeResponse{
Expand All @@ -443,7 +457,8 @@ func (u *UnmountCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()

defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)

if err != nil {
Expand All @@ -452,6 +467,7 @@ func (u *UnmountCommand) Execute(args []string) error {

unmountRequest := k8sresources.FlexVolumeUnmountRequest{
MountPath: mountDir,
Context: requestContext,
}
unmountResponse := controller.Unmount(unmountRequest)
return printResponse(unmountResponse)
Expand All @@ -470,7 +486,8 @@ func (i *TestUbiquityCommand) Execute(args []string) error {
}
return printResponse(response)
}
defer logs.InitFileLogger(logs.GetLogLevelFromString(config.LogLevel), path.Join(config.LogPath, k8sresources.UbiquityFlexLogFileName))()

defer k8sutils.InitFlexLogger(config)()
controller, err := createController(config)
if err != nil {
response := k8sresources.FlexVolumeResponse{
Expand Down Expand Up @@ -567,8 +584,8 @@ func readConfig(configFile string) (resources.UbiquityPluginConfig, error) {

}
// Create environment variables for some of the config params
os.Setenv(remote.KeyUseSsl, strconv.FormatBool(config.SslConfig.UseSsl))
os.Setenv(resources.KeySslMode, config.SslConfig.SslMode)
os.Setenv(remote.KeyUseSsl, strconv.FormatBool(config.SslConfig.UseSsl))
os.Setenv(resources.KeySslMode, config.SslConfig.SslMode)
os.Setenv(remote.KeyVerifyCA, config.SslConfig.VerifyCa)
return config, nil
}
Expand All @@ -581,3 +598,4 @@ func printResponse(f k8sresources.FlexVolumeResponse) error {
fmt.Printf("%s", string(responseBytes[:]))
return nil
}

4 changes: 1 addition & 3 deletions cmd/provisioner/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/IBM/ubiquity-k8s/volume"
"github.com/IBM/ubiquity/remote"
"github.com/IBM/ubiquity/utils"
"github.com/IBM/ubiquity/utils/logs"
"github.com/kubernetes-incubator/external-storage/lib/controller"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
Expand All @@ -51,7 +50,7 @@ func main() {
panic(fmt.Errorf("Failed to setup log dir"))
}

defer logs.InitStdoutLogger(logs.GetLogLevelFromString(ubiquityConfig.LogLevel))()
defer k8sutils.InitProvisionerLogger(ubiquityConfig)()
logger := utils.SetupOldLogger(k8sresources.UbiquityProvisionerName)

logger.Printf("Provisioner %s specified", provisioner)
Expand Down Expand Up @@ -100,4 +99,3 @@ func main() {
pc := controller.NewProvisionController(clientset, provisioner, flexProvisioner, serverVersion.GitVersion)
pc.Run(wait.NeverStop)
}

40 changes: 40 additions & 0 deletions contribution-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contribution guide
The Ubiquity team accepts contributions from IBM employees using GitHub pull requests.
Pushing to master is not allowed. Any direct push to master might interfere with our CI process.

If you want to make a change, create your own branch out of `dev` branch, make your changes. Once you are done, submit a pull request to the `dev` branch. When accepted, the changes will make their way into `master` after we merge.

Verify your changes before submitting a pull request by running the unit, integration and acceptance tests. See the testing section for details. In addition, make sure that your changes are covered by existing or new unit testing.

# Build prerequisites
* Install [golang](https://golang.org/) (>=1.9.1).
* Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
* Install gcc.
* Configure go. GOPATH environment variable must be set correctly before starting the build process. Create a new directory and set it as GOPATH.

### Download and build source code
* Configure ssh-keys for github.com. go tools require passwordless ssh access to github. If you have not set up ssh keys for your github profile, follow these [instructions](https://help.github.com/enterprise/2.7/user/articles/generating-an-ssh-key/) before you proceed.
* Build Ubiquity Provisioner and FlexVolume from source.
```bash
mkdir -p $HOME/workspace
export GOPATH=$HOME/workspace
mkdir -p $GOPATH/src/github.com/IBM
cd $GOPATH/src/github.com/IBM
git clone [email protected]:IBM/ubiquity-k8s.git
cd ubiquity-k8s
./scripts/run_glide_up
./scripts/build_provisioner
./scripts/build_flex_driver
```
# Testing Ubiquity Provisioner and FlexVolume

Run the tests:
```bash
./scripts/run_glide_up
./scripts/run_units.sh
```

# Squash and merge

Upon the merge (by either you or your reviewer), all commits on the review branch must represent meaningful milestones or units of work. Use commit message to detail the development and review process.
Before merging a PR, squash any fix review feedback, typo, and rebased sorts of commits.
Loading

0 comments on commit f45eba3

Please sign in to comment.