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

[release-4.16] OCPBUGS-42441: Add O-RAN v3.0 Compliant API to PTP Event Producer #537

Open
wants to merge 5 commits into
base: release-4.16
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# VERSION defines the project version for the bundle.
# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 4.16

# CHANNELS define the bundle channels used in the bundle.
# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=preview,fast,stable)
Expand All @@ -14,7 +14,7 @@ ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif

# DEFAULT_CHANNEL defines the default channel used in the bundle.
# DEFAULT_CHANNEL defines the default channel used in the bundle.
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
# To re-generate a bundle for any other default channel without changing the default setup, you can:
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
Expand Down Expand Up @@ -92,12 +92,15 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: fmt
fmt: ## Go fmt your code
hack/gofmt.sh

.PHONY: fmt-code
fmt-code: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

Expand Down Expand Up @@ -152,7 +155,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CONTROLLER_TOOLS_VERSION ?= v0.15.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand All @@ -171,14 +174,19 @@ $(CONTROLLER_GEN): $(LOCALBIN)
GOFLAGS=-mod=mod GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: operator-sdk
ifeq ($(OS), Darwin)
OPERATOR_SDK ?= $(LOCALBIN)/x86_64/operator-sdk
else
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
endif
OPERATOR_SDK_VERSION_INSTALLED = $(shell $(OPERATOR_SDK) version 2>/dev/null | sed 's/^operator-sdk version: "\([^"]*\).*/\1/')
operator-sdk: ## Download operator-sdk locally if necessary.
ifneq ($(OPERATOR_SDK_VERSION),$(OPERATOR_SDK_VERSION_INSTALLED))
ifeq ($(OS), Darwin)
curl https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/operator-sdk/4.11.0/operator-sdk-darwin-x86_64.tar.gz? | tar -xz -C bin/x86_64/
mkdir -p $(LOCALBIN)/x86_64/
curl -L https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/operator-sdk/4.11.0/operator-sdk-darwin-x86_64.tar.gz? | tar -xz -C bin/x86_64/
else
curl https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/operator-sdk/4.11.0/operator-sdk-linux-x86_64.tar.gz? | tar -xz -C bin/
curl -L https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/operator-sdk/4.11.0/operator-sdk-linux-x86_64.tar.gz? | tar -xz -C bin/
endif
endif

Expand All @@ -199,12 +207,16 @@ endif

.PHONY: bundle-build ## Build the bundle image.
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(CONTAINER_TOOL) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)

.PHONY: bundle-check
bundle-check: common-deps-update generate manifests bundle
hack/check-git-tree.sh

.PHONY: opm
OPM = ./bin/opm
opm: ## Download opm locally if necessary.
Expand Down Expand Up @@ -239,15 +251,15 @@ endif
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
$(OPM) index add --container-tool $(CONTAINER_TOOL) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

# custom
deps-update:
.PHONY: common-deps-update
common-deps-update: controller-gen kustomize
go mod tidy && \
go mod vendor

Expand All @@ -256,7 +268,7 @@ bin:
hack/build.sh

image:
docker build -t openshift.io/ptp-operator -f Dockerfile.rhel7 .
$(CONTAINER_TOOL) build -t openshift.io/ptp-operator -f Dockerfile.rhel7 .

clean:
rm -rf build/_output/bin/ptp-operator
Expand All @@ -270,5 +282,6 @@ test-validation-only:
buildtest:
PATH=${PATH}:${GOBIN} ginkgo build ./test/conformance
cp ./test/conformance/conformance.test ./bin/testptp

buildimage: buildtest
./scripts/image.sh
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ items:
spec:
ptpEventConfig:
enableEventPublisher: true
# For AMQP transport, transportHost: "amqp://amq-router.amq-router.svc.cluster.local"
transportHost: "http://ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043"
storageType: local-sc
daemonNodeSelector:
Expand Down
8 changes: 6 additions & 2 deletions api/v1/ptpoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ type PtpEventConfig struct {
EnableEventPublisher bool `json:"enableEventPublisher,omitempty"`
// TransportHost format is <protocol>://<transport-service>.<namespace>.svc.cluster.local:<transport-port>
// Example HTTP transport: "http://ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043"
// Example AMQP transport: "amqp://amq-router-service-name.amq-namespace.svc.cluster.local"
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Transport Host",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
TransportHost string `json:"transportHost,omitempty"`
// StorageType is the name of StorageClass providing persist storage used by HTTP transport to store subscription data
// StorageType is the type of storage to store subscription data
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Storage Type",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
StorageType string `json:"storageType,omitempty"`
// ApiVersion is used to determine which API is used for the event service
// 1.0: default version. event service is mapped to internal REST-API.
// 2.x: event service is mapped to O-RAN v3.0 Compliant O-Cloud Notification REST-API.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="ApiVersion",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
ApiVersion string `json:"apiVersion,omitempty"`
}

func init() {
Expand Down
20 changes: 1 addition & 19 deletions api/v1/ptpoperatorconfig_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ limitations under the License.
package v1

import (
"context"
"errors"
storagev1 "k8s.io/api/storage/v1"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -74,20 +73,3 @@ func (r *PtpOperatorConfig) ValidateDelete() (admission.Warnings, error) {
ptpoperatorconfiglog.Info("validate delete", "name", r.Name)
return admission.Warnings{}, nil
}

func (r *PtpOperatorConfig) checkStorageClass(scName string) bool {

scList := &storagev1.StorageClassList{}
opts := []client.ListOption{}
err := k8sclient.List(context.TODO(), scList, opts...)
if err != nil {
return false
}

for _, sc := range scList.Items {
if sc.Name == scName {
return true
}
}
return false
}
7 changes: 4 additions & 3 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 1 addition & 24 deletions bindata/linuxptp/ptp-daemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
- "--metrics-addr=127.0.0.1:9091"
- "--store-path=/store"
- "--transport-host={{ .EventTransportHost }}"
- "--api-version={{ .EventApiVersion }}"
- "--api-port=9085"
volumeMounts:
- name: config-volume
Expand Down Expand Up @@ -134,12 +135,7 @@ spec:
secretName: linuxptp-daemon-secret
{{ if (eq .EnableEventPublisher true) }}
- name: pubsubstore
{{ if or (eq .StorageType "emptyDir") (hasPrefix "amqp" .EventTransportHost) }}
emptyDir: {}
{{ else }}
persistentVolumeClaim:
claimName: cloud-event-proxy-store-{{ .StorageType }}
{{ end }}
- name: event-bus-socket
emptyDir: {}
{{ end }}
Expand Down Expand Up @@ -258,22 +254,3 @@ spec:
labels:
severity: warning
{{ end }}

# special storageType "emptyDir" is used for developer tests to map pubsubstore volume to emptyDir
{{ if and (eq .EnableEventPublisher true) (ne .StorageType "emptyDir") }}
{{ if not (hasPrefix "amqp" .EventTransportHost) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cloud-event-proxy-store-{{ .StorageType }}
namespace: openshift-ptp
spec:
storageClassName: {{ .StorageType }}
resources:
requests:
storage: 10Mi
accessModes:
- ReadWriteOnce
{{ end }}
{{ end }}
37 changes: 10 additions & 27 deletions bundle/manifests/ptp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,21 @@ spec:
kind: PtpOperatorConfig
name: ptpoperatorconfigs.ptp.openshift.io
specDescriptors:
- description: StorageType is the name of StorageClass providing persist storage
used by HTTP transport to store subscription data
- description: 'ApiVersion is used to determine which API is used for the event
service 1.0: default version. event service is mapped to internal REST-API.
2.x: event service is mapped to O-RAN v3.0 Compliant O-Cloud Notification
REST-API.'
displayName: ApiVersion
path: ptpEventConfig.apiVersion
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: StorageType is the type of storage to store subscription data
displayName: Storage Type
path: ptpEventConfig.storageType
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: 'TransportHost format is <protocol>://<transport-service>.<namespace>.svc.cluster.local:<transport-port>
Example HTTP transport: "http://ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043"
Example AMQP transport: "amqp://amq-router-service-name.amq-namespace.svc.cluster.local"'
Example HTTP transport: "http://ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043"'
displayName: Transport Host
path: ptpEventConfig.transportHost
x-descriptors:
Expand Down Expand Up @@ -270,18 +276,6 @@ spec:
- rolebindings
verbs:
- '*'
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- '*'
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- '*'
- apiGroups:
- config.openshift.io
resources:
Expand All @@ -290,17 +284,6 @@ spec:
- get
- list
- watch
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ptp.openshift.io
resources:
Expand Down
25 changes: 15 additions & 10 deletions bundle/manifests/ptp.openshift.io_nodeptpdevices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
name: nodeptpdevices.ptp.openshift.io
spec:
Expand All @@ -20,14 +20,19 @@ spec:
description: NodePtpDevice is the Schema for the nodeptpdevices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand All @@ -38,9 +43,9 @@ spec:
description: NodePtpDeviceStatus defines the observed state of NodePtpDevice
properties:
devices:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
items:
properties:
name:
Expand Down
Loading