Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add health status reporter for storageclient #6

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/workflows/conf/commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"action",
"api",
"bundle",
"csi",
"ci",
"console",
"controllers",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.17", "1.18"]
go: ["1.18", "1.19"]
steps:
- uses: actions/setup-go@v2
with:
Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.17", "1.18"]
go: ["1.18", "1.19"]
steps:
- uses: actions/setup-go@v2
with:
Expand All @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.17", "1.18"]
go: ["1.18", "1.19"]
steps:
- uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.19'

- uses: actions/checkout@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.17", "1.18"]
go: ["1.18", "1.19"]
steps:
- uses: actions/setup-go@v2
with:
Expand All @@ -39,7 +39,7 @@ jobs:
#
# The weird NO_FUTURE thing is a workaround suggested here:
# https://github.com/golangci/golangci-lint-action/issues/119#issuecomment-981090648
args: "--out-${NO_FUTURE}format=colored-line-number"
args: "--timeout=5m --out-${NO_FUTURE}format=colored-line-number"

# Optional: show only new issues if it's a pull request.
# The default value is `false`.
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.17 as builder
FROM golang:1.19 as builder

WORKDIR /workspace

Expand All @@ -10,12 +10,15 @@ COPY go.mod go.sum ./
COPY vendor/ vendor/

# Copy the project source
COPY main.go Makefile ./
COPY main.go Makefile images.yaml ./
COPY hack/ hack/
COPY api/ api/
COPY controllers/ controllers/
COPY config/ config/

COPY csi/ csi/
COPY pkg/ pkg/
COPY templates/ templates/
COPY status-report/ status-report/
# Run tests and linting
RUN make go-test

Expand All @@ -27,6 +30,6 @@ RUN make go-build
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/bin/manager .
COPY --from=builder /workspace/bin/status-reporter .
COPY --from=builder /workspace/images.yaml /etc/ocs-client-operator/images.yaml
USER 65532:65532

ENTRYPOINT ["/manager"]
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lint: ## Run golangci-lint against code.
docker run --rm -v $(PROJECT_DIR):/app:Z -w /app $(GO_LINT_IMG) golangci-lint run ./...

godeps-update: ## Run go mod tidy & vendor
go mod tidy -compat=1.17 && go mod vendor
go mod tidy && go mod vendor

test-setup: godeps-update generate fmt vet ## Run setup targets for tests

Expand All @@ -64,6 +64,7 @@ e2e-test: ginkgo ## TODO: Run end to end functional tests.
##@ Build

build: container-build ## Build manager binary
go build -o ./bin/manager main.go

go-build: ## Run go build against code.
@GOBIN=${GOBIN} ./hack/go-build.sh
Expand All @@ -88,6 +89,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit set image rbac-proxy=$(RBAC_PROXY_IMG)
sed -i 's|value: controller|value: ${IMG}|g' "config/manager/manager.yaml"
$(KUSTOMIZE) build config/default | kubectl apply -f -

remove: ## Remove controller from the K8s cluster specified in ~/.kube/config.
Expand All @@ -105,6 +107,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd config/default && $(KUSTOMIZE) edit set image rbac-proxy=$(RBAC_PROXY_IMG)
sed -i 's|value: controller|value: ${IMG}|g' "config/manager/manager.yaml"
cd config/manifests/bases && $(KUSTOMIZE) edit add annotation --force 'olm.skipRange':"$(SKIP_RANGE)" && \
$(KUSTOMIZE) edit add patch --name ocs-client-operator.v0.0.0 --kind ClusterServiceVersion\
--patch '[{"op": "replace", "path": "/spec/replaces", "value": "$(REPLACES)"}]'
Expand Down
19 changes: 19 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,23 @@ plugins:
scorecard.sdk.operatorframework.io/v2: {}
projectName: ocs-client-operator
repo: github.com/red-hat-storage/ocs-client-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: ocs
kind: StorageClient
path: github.com/red-hat-storage/ocs-client-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: ocs
kind: StorageClassClaim
path: github.com/red-hat-storage/ocs-client-operator/api/v1alpha1
version: v1alpha1
version: "3"
8 changes: 4 additions & 4 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the odf v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=odf.openshift.io
// Package v1alpha1 contains API Schema definitions for the ocs v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=ocs.openshift.io
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "odf.openshift.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "ocs.openshift.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
85 changes: 85 additions & 0 deletions api/v1alpha1/storageclassclaim_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2022 Red Hat, Inc.

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 v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type storageClassClaimState string

const (
// StorageClassClaimInitializing represents Initializing state of StorageClassClaim
StorageClassClaimInitializing storageClassClaimState = "Initializing"
// StorageClassClaimValidating represents Validating state of StorageClassClaim
StorageClassClaimValidating storageClassClaimState = "Validating"
// StorageClassClaimFailed represents Failed state of StorageClassClaim
StorageClassClaimFailed storageClassClaimState = "Failed"
// StorageClassClaimCreating represents Configuring state of StorageClassClaim
StorageClassClaimCreating storageClassClaimState = "Creating"
// StorageClassClaimConfiguring represents Configuring state of StorageClassClaim
StorageClassClaimConfiguring storageClassClaimState = "Configuring"
// StorageClassClaimReady represents Ready state of StorageClassClaim
StorageClassClaimReady storageClassClaimState = "Ready"
// StorageClassClaimDeleting represents Deleting state of StorageClassClaim
StorageClassClaimDeleting storageClassClaimState = "Deleting"
)

// StorageClassClaimStatus defines the observed state of StorageClassClaim
type StorageClassClaimStatus struct {
Phase storageClassClaimState `json:"phase,omitempty"`
SecretNames []string `json:"secretNames,omitempty"`
}

// StorageClassClaimSpec defines the desired state of StorageClassClaim
type StorageClassClaimSpec struct {
//+kubebuilder:validation:Enum=blockpool;sharedfilesystem
Type string `json:"type"`
EncryptionMethod string `json:"encryptionMethod,omitempty"`
StorageProfile string `json:"storageProfile,omitempty"`
ConsumerID string `json:"consumerID"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:printcolumn:name="StorageType",type="string",JSONPath=".spec.type"
//+kubebuilder:printcolumn:name="StorageProfile",type="string",JSONPath=".spec.storageProfile"
//+kubebuilder:printcolumn:name="ConsumerID",type="string",JSONPath=".spec.ConsumerID"
//+kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

// StorageClassClaim is the Schema for the storageclassclaims API
type StorageClassClaim struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec StorageClassClaimSpec `json:"spec,omitempty"`
Status StorageClassClaimStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// StorageClassClaimList contains a list of StorageClassClaim
type StorageClassClaimList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []StorageClassClaim `json:"items"`
}

func init() {
SchemeBuilder.Register(&StorageClassClaim{}, &StorageClassClaimList{})
}
82 changes: 82 additions & 0 deletions api/v1alpha1/storageclient_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
Copyright 2022 Red Hat, Inc.

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 v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type storageClientPhase string

const (
// StorageClientInitializing represents Initializing state of storageClient
StorageClientInitializing storageClientPhase = "Initializing"
// StorageClientOnboarding represents Onboarding state of storageClient
StorageClientOnboarding storageClientPhase = "Onboarding"
// StorageClientOnboardingProgressing represents OnboardingProgressing state of storageClient
StorageClientOnboardingProgressing storageClientPhase = "Progressing"
// StorageClientConnected represents Onboarding state of storageClient
StorageClientConnected storageClientPhase = "Connected"
// StorageClientOffboarding represents Onboarding state of storageClient
StorageClientOffboarding storageClientPhase = "Offboarding"
// StorageClientFailed represents Failed state of storageClient
StorageClientFailed storageClientPhase = "Failed"
)

// StorageClientSpec defines the desired state of StorageClient
type StorageClientSpec struct {
// StorageProviderEndpoint holds info to establish connection with the storage providing cluster.
StorageProviderEndpoint string `json:"storageProviderEndpoint"`

// OnboardingTicket holds an identity information required for consumer to onboard.
OnboardingTicket string `json:"onboardingTicket"`
}

// StorageClientStatus defines the observed state of StorageClient
type StorageClientStatus struct {
Phase storageClientPhase `json:"phase,omitempty"`

// ConsumerID will hold the identity of this cluster inside the attached provider cluster
ConsumerID string `json:"id,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="StorageType",type="string",JSONPath=".spec.type"
//+kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

// StorageClient is the Schema for the storageclients API
type StorageClient struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec StorageClientSpec `json:"spec,omitempty"`
Status StorageClientStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// StorageClientList contains a list of StorageClient
type StorageClientList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []StorageClient `json:"items"`
}

func init() {
SchemeBuilder.Register(&StorageClient{}, &StorageClientList{})
}
Loading