Skip to content

Commit

Permalink
feat(naming): make it easier to use custom names
Browse files Browse the repository at this point in the history
Would still require a lot of manual changes though as values are spread on many
.yaml files, ie values.yaml product.yaml doc.yaml...
A script would be the required to make all changes.

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed May 16, 2024
1 parent fb09c7a commit 4a3bc23
Show file tree
Hide file tree
Showing 27 changed files with 220 additions and 132 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions call-home/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name = "obs-callhome-stats"
path = "src/bin/stats/main.rs"

[dependencies]
constants = { path = "../constants" }
openapi = {path = "../dependencies/control-plane/openapi"}
kube = { version = "0.85.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.19.0", features = ["v1_20"] }
Expand Down
2 changes: 1 addition & 1 deletion call-home/src/bin/callhome/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async fn generate_report(
aggregator_url: Option<Url>,
) -> Report {
let mut report = Report {
product_name: PRODUCT.to_string(),
product_name: product(),
k8s_cluster_id,
deploy_namespace,
product_version,
Expand Down
2 changes: 1 addition & 1 deletion call-home/src/bin/callhome/transmitter/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Receiver {
.header("CAStor-Cluster-Id", &self.cluster_id)
.header("CAStor-Version", release_version())
.header("CAStor-Report-Type", "health_report")
.header("CAStor-Product", PRODUCT)
.header("CAStor-Product", product())
.header("CAStor-Time", Utc::now().to_string())
.header("Content-Type", "text/PGP; charset=binary")
.body(body)
Expand Down
13 changes: 6 additions & 7 deletions call-home/src/common/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use std::{
use utils::version_info;

/// PRODUCT is the name of the project for which this call-home component is deployed.
pub const PRODUCT: &str = "Mayastor";

/// Label for release name.
pub const HELM_RELEASE_NAME_LABEL: &str = "openebs.io/release";
pub fn product() -> String {
::constants::product_pascal()
}

/// Defines the default helm chart release name.
pub const DEFAULT_RELEASE_NAME: &str = "mayastor";
pub const DEFAULT_RELEASE_NAME: &str = ::constants::DEFAULT_RELEASE_NAME;

/// Defines the Label select for mayastor REST API.
pub const API_REST_LABEL_SELECTOR: &str = "app=api-rest";
Expand All @@ -34,7 +33,7 @@ pub const POOL_STATS: &str = "Pool stats";
/// Defines the help argument for nexus stats need for promethueus library.
pub const NEXUS_STATS: &str = "Nexus stats";

/// Variable label for promethueus library.
/// Variable label for prometheus library.
pub const ACTION: &str = "action";

/// Create action for events.
Expand Down Expand Up @@ -112,7 +111,7 @@ pub fn key_filepath() -> PathBuf {
}

/// RECEIVER_API_ENDPOINT is the URL to anonymous call-home metrics collection endpoint.
pub const RECEIVER_ENDPOINT: &str = "https://openebs.phonehome.datacore.com/openebs/report";
pub const RECEIVER_ENDPOINT: &str = ::constants::CALL_HOME_ENDPOINT;

/// CALL_HOME_FREQUENCY_IN_HOURS is the frequency of call-home metrics transmission, in hours.
/// The function call_home_frequency() returns the frequency as an std::time::Duration.
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ loki-stack:
# -- The Loki address to post logs to
- url: http://{{ .Release.Name }}-loki:3100/loki/api/v1/push
snippets:
# Promtail will export logs to loki only based on based on below
# Promtail will export logs to loki only based on below
# configuration, below scrape config will export only our services
# which are labeled with openebs.io/logging=true
scrapeConfigs: |
Expand Down
10 changes: 10 additions & 0 deletions constants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "constants"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
utils = {path = "../dependencies/control-plane/utils/utils-lib" }
convert_case = "0.4.0"
51 changes: 51 additions & 0 deletions constants/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use convert_case::Casing;
use utils::constants::PRODUCT_DOMAIN_NAME;
pub use utils::PRODUCT_NAME;

/// Name of the product.
pub fn product_pascal() -> String {
PRODUCT_NAME.to_case(convert_case::Case::Pascal)
}

/// Helm release name label's key.
pub fn helm_release_name_key() -> String {
format!("{PRODUCT_DOMAIN_NAME}/release")
}

/// Upgrade job container image name.
pub fn upgrade_job_img() -> String {
format!("{PRODUCT_NAME}-upgrade-job")
}
/// Upgrade job container image name.
pub fn upgrade_job_container_name() -> String {
format!("{PRODUCT_NAME}-upgrade-job")
}
/// UPGRADE_EVENT_REASON is the reason field in upgrade job.
pub fn upgrade_event_reason() -> String {
format!("{}Upgrade", product_pascal())
}
/// Upgrade job container image repository.
pub const UPGRADE_JOB_IMAGE_REPO: &str = "openebs";
/// This is the user docs URL for the Umbrella chart.
pub const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str =
"https://openebs.io/docs/user-guides/upgrade#mayastor-upgrade";

/// Defines the default helm chart release name.
pub const DEFAULT_RELEASE_NAME: &str = PRODUCT_NAME;

/// Installed release version.
pub fn helm_release_version_key() -> String {
format!("{PRODUCT_DOMAIN_NAME}/version")
}

/// Loki Logging key.
pub fn loki_logging_key() -> String {
format!("{PRODUCT_DOMAIN_NAME}/logging")
}

/// This is the name of the Helm chart which included the core chart as a sub-chart.
/// Under the hood, this installs the Core Helm chart (see below).
pub const UMBRELLA_CHART_NAME: &str = "openebs";

/// RECEIVER_API_ENDPOINT is the URL to anonymous call-home metrics collection endpoint.
pub const CALL_HOME_ENDPOINT: &str = "https://openebs.phonehome.datacore.com/openebs/report";
2 changes: 1 addition & 1 deletion dependencies/control-plane
Submodule control-plane updated 65 files
+3 −0 Cargo.lock
+1 −1 MAINTAINERS
+20 −1 control-plane/agents/src/bin/core/controller/io_engine/mod.rs
+49 −0 control-plane/agents/src/bin/core/controller/io_engine/types.rs
+1 −0 control-plane/agents/src/bin/core/controller/io_engine/v0/mod.rs
+39 −0 control-plane/agents/src/bin/core/controller/io_engine/v0/snap_rebuild.rs
+11 −1 control-plane/agents/src/bin/core/controller/io_engine/v1/mod.rs
+173 −0 control-plane/agents/src/bin/core/controller/io_engine/v1/snap_rebuild.rs
+26 −0 control-plane/agents/src/bin/core/controller/io_engine/v1/translation.rs
+5 −5 control-plane/agents/src/bin/core/controller/resources/migration.rs
+2 −2 control-plane/agents/src/bin/core/tests/controller/mod.rs
+7 −7 control-plane/agents/src/bin/core/tests/deserializer.rs
+1 −3 control-plane/agents/src/bin/core/volume/specs.rs
+5 −2 control-plane/agents/src/bin/ha/cluster/etcd.rs
+2 −2 control-plane/agents/src/bin/ha/cluster/switchover.rs
+3 −2 control-plane/agents/src/bin/ha/cluster/volume.rs
+3 −2 control-plane/agents/src/bin/ha/node/path_provider.rs
+3 −2 control-plane/agents/src/bin/ha/node/server.rs
+0 −18 control-plane/agents/src/common/errors.rs
+3 −4 control-plane/csi-driver/src/bin/controller/controller.rs
+4 −3 control-plane/csi-driver/src/bin/controller/identity.rs
+1 −1 control-plane/csi-driver/src/bin/controller/pvwatcher.rs
+4 −4 control-plane/csi-driver/src/bin/node/dev.rs
+4 −3 control-plane/csi-driver/src/bin/node/identity.rs
+2 −2 control-plane/csi-driver/src/bin/node/main_.rs
+1 −4 control-plane/csi-driver/src/bin/node/node.rs
+15 −7 control-plane/csi-driver/src/lib.rs
+11 −11 control-plane/rest/openapi-specs/v0_api_spec.yaml
+1 −0 control-plane/stor-port/Cargo.toml
+0 −3 control-plane/stor-port/src/lib.rs
+32 −3 control-plane/stor-port/src/types/v0/transport/nvme_nqn.rs
+2 −2 default.nix
+2 −2 deployer/src/infra/io_engine.rs
+3 −5 k8s/operators/src/pool/context.rs
+2 −2 k8s/operators/src/pool/diskpool/client.rs
+1 −1 k8s/operators/src/pool/diskpool/crd/migration.rs
+5 −0 k8s/operators/src/pool/diskpool/crd/mod.rs
+6 −0 nix/config.nix
+6 −2 nix/overlay.nix
+2 −2 nix/pkgs/images/default.nix
+1 −0 rpc/build.rs
+9 −0 rpc/src/lib.rs
+3 −2 scripts/release.sh
+11 −0 tests/bdd/common/__init__.py
+3 −1 tests/bdd/common/etcd.py
+3 −2 tests/bdd/features/csi/controller/test_controller.py
+2 −1 tests/bdd/features/csi/controller/test_identity.py
+3 −2 tests/bdd/features/csi/node/test_csi.py
+2 −1 tests/bdd/features/csi/node/test_identity.py
+2 −1 tests/bdd/features/csi/node/test_node.py
+2 −1 tests/bdd/features/ha/node-agent/test_path_replacement.py
+2 −1 tests/bdd/features/snapshot/csi/controller/test_operations.py
+8 −7 tests/bdd/features/volume/topology/test_feature.py
+31 −30 tests/bdd/features/volume/topology/test_node_topology.py
+13 −10 tests/bdd/features/volume/topology/test_pool_topology.py
+1 −0 tests/io-engine/Cargo.toml
+14 −9 tests/io-engine/tests/reservations.rs
+2 −1 tests/io-engine/tests/upgrade.rs
+1 −1 utils/dependencies
+7 −0 utils/deployer-cluster/src/lib.rs
+1 −0 utils/pstor/Cargo.toml
+1 −3 utils/pstor/src/products/v2.rs
+46 −7 utils/utils-lib/src/constants.rs
+1 −1 utils/utils-lib/src/lib.rs
+2 −2 utils/utils-lib/src/test_constants.rs
1 change: 1 addition & 0 deletions k8s/plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tls = [ "openapi/tower-client-tls", "rest-plugin/tls" ]
[dependencies]
openapi = { path = "../../dependencies/control-plane/openapi", default-features = false, features = [ "tower-trace" ] }
utils = { path = "../../dependencies/control-plane/utils/utils-lib" }
constants = { path = "../../constants" }
rest-plugin = { path = "../../dependencies/control-plane/control-plane/plugin", default-features = false }
console-logger = { path = "../../console-logger" }
supportability = { path = "../supportability" }
Expand Down
2 changes: 2 additions & 0 deletions k8s/supportability/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ platform = { path = "../../dependencies/control-plane/utils/platform" }
openapi = { path = "../../dependencies/control-plane/openapi", default-features = false, features = [ "tower-client", "tower-trace" ] }
kube-proxy = { path = "../proxy" }
rest-plugin = { path = "../../dependencies/control-plane/control-plane/plugin", default-features = false }
utils = { path = "../../dependencies/control-plane/utils/utils-lib" }
constants = { path = "../../constants" }
6 changes: 4 additions & 2 deletions k8s/supportability/src/collect/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ pub(crate) const MAYASTOR_SERVICE: &str = "io-engine";
/// Defines the name of mayastor-io container(dataplane container)
pub(crate) const DATA_PLANE_CONTAINER_NAME: &str = "io-engine";

/// Defines the logging label(key-value pair) on mayastor services
pub(crate) const LOGGING_LABEL_SELECTOR: &str = "openebs.io/logging=true";
/// Defines the logging label(key-value pair) on services.
pub(crate) fn logging_label_selector() -> String {
format!("{}=true", ::constants::loki_logging_key())
}

/// Defines the name of upgrade service
pub(crate) const UPGRADE_SERVICE: &str = "upgrade";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use std::{
iter::FromIterator,
path::{Path, PathBuf},
};

const MAYASTOR_CSI_DRIVER: &str = "io.openebs.csi-mayastor";
use utils::csi_plugin_name;

/// K8s resource dumper client
#[derive(Clone)]
Expand Down Expand Up @@ -333,7 +332,7 @@ async fn get_k8s_vs_classes(
) -> Result<(), K8sResourceDumperError> {
log("\t Collecting Kubernetes VolumeSnapshotClass resources".to_string());
match k8s_client
.list_volumesnapshot_classes(Some(MAYASTOR_CSI_DRIVER), None, None)
.list_volumesnapshot_classes(Some(&csi_plugin_name()), None, None)
.await
{
Ok(vscs) => {
Expand All @@ -356,7 +355,7 @@ async fn get_k8s_vsnapshot_contents(
) -> Result<(), K8sResourceDumperError> {
log("\t Collecting Kubernetes VolumeSnapshotContents resources".to_string());
match k8s_client
.list_volumesnapshotcontents(Some(MAYASTOR_CSI_DRIVER), None, None)
.list_volumesnapshotcontents(Some(&csi_plugin_name()), None, None)
.await
{
Ok(vscs) => {
Expand Down
14 changes: 7 additions & 7 deletions k8s/supportability/src/collect/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod loki;

use crate::collect::{
constants::{
CALLHOME_JOB_SERVICE, CONTROL_PLANE_SERVICES, DATA_PLANE_SERVICES,
HOST_NAME_REQUIRED_SERVICES, LOGGING_LABEL_SELECTOR, NATS_JOB_SERVICE, UPGRADE_JOB_SERVICE,
logging_label_selector, CALLHOME_JOB_SERVICE, CONTROL_PLANE_SERVICES, DATA_PLANE_SERVICES,
HOST_NAME_REQUIRED_SERVICES, NATS_JOB_SERVICE, UPGRADE_JOB_SERVICE,
},
k8s_resources::{
client::{ClientSet, K8sResourceError},
Expand Down Expand Up @@ -268,7 +268,7 @@ impl Logger for LogCollection {
let pods = self
.k8s_logger_client
.get_k8s_clientset()
.get_pods(LOGGING_LABEL_SELECTOR, "")
.get_pods(&logging_label_selector(), "")
.await?;

let control_plane_pods = pods
Expand All @@ -295,7 +295,7 @@ impl Logger for LogCollection {
let pods = self
.k8s_logger_client
.get_k8s_clientset()
.get_pods(LOGGING_LABEL_SELECTOR, "")
.get_pods(&logging_label_selector(), "")
.await?;
let data_plane_pods = pods
.into_iter()
Expand All @@ -321,7 +321,7 @@ impl Logger for LogCollection {
let pods = self
.k8s_logger_client
.get_k8s_clientset()
.get_pods(LOGGING_LABEL_SELECTOR, "")
.get_pods(&logging_label_selector(), "")
.await?;

let upgrade_pod = pods
Expand All @@ -348,7 +348,7 @@ impl Logger for LogCollection {
let pods = self
.k8s_logger_client
.get_k8s_clientset()
.get_pods(LOGGING_LABEL_SELECTOR, "")
.get_pods(&logging_label_selector(), "")
.await?;

let callhome_pod = pods
Expand All @@ -375,7 +375,7 @@ impl Logger for LogCollection {
let pods = self
.k8s_logger_client
.get_k8s_clientset()
.get_pods(LOGGING_LABEL_SELECTOR, "")
.get_pods(&logging_label_selector(), "")
.await?;

let nats_pods = pods
Expand Down
2 changes: 2 additions & 0 deletions k8s/upgrade/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ path = "src/lib.rs"
[dependencies]
openapi = { path = "../../dependencies/control-plane/openapi", default-features = false, features = [ "tower-trace" ] }
utils = { path = "../../dependencies/control-plane/utils/utils-lib" }
constants = { path = "../../constants" }
kube-proxy = { path = "../proxy" }
console-logger = { path = "../../console-logger" }
convert_case = "0.4.0"
kube = { version = "0.85.0", default-features = true, features = [ "derive", "runtime" ] }
anyhow = "1.0.75"
clap = { version = "4.4.6", features = ["derive", "env", "string", "color"] }
Expand Down
19 changes: 11 additions & 8 deletions k8s/upgrade/src/bin/upgrade-job/common/constants.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use semver::Version;

/// This is the name of the project that is being upgraded.
pub(crate) const PRODUCT: &str = "Mayastor";
pub use constants::product_pascal;

/// This is the name of the Helm chart which included the core chart as a sub-chart.
/// Under the hood, this installs the Core Helm chart (see below).
pub(crate) const UMBRELLA_CHART_NAME: &str = "openebs";
pub(crate) const UMBRELLA_CHART_NAME: &str = constants::UMBRELLA_CHART_NAME;

/// This is the name of the Helm chart of this project.
pub(crate) const CORE_CHART_NAME: &str = "mayastor";
pub(crate) const CORE_CHART_NAME: &str = constants::PRODUCT_NAME;

/// This is the shared Pod label of the <helm-release>-io-engine DaemonSet.
pub(crate) const IO_ENGINE_LABEL: &str = "app=io-engine";
Expand All @@ -17,20 +17,23 @@ pub(crate) const IO_ENGINE_LABEL: &str = "app=io-engine";
pub(crate) const AGENT_CORE_LABEL: &str = "app=agent-core";

/// This is the shared label across the helm chart components which carries the chart version.
pub(crate) const CHART_VERSION_LABEL_KEY: &str = "openebs.io/version";
pub(crate) use constants::helm_release_version_key;

/// This is the label set on a storage API Node resource when a 'Node Drain' is issued.
pub(crate) const DRAIN_FOR_UPGRADE: &str = "mayastor-upgrade";
pub fn drain_for_upgrade() -> String {
format!("{CORE_CHART_NAME}-upgrade")
}

/// This is the label set on a storage API Node resource when a 'Node Drain' is issued.
pub(crate) const CORDON_FOR_ANA_CHECK: &str = "mayastor-upgrade-nvme-ana-check";
pub fn cordon_ana_check() -> String {
format!("{CORE_CHART_NAME}-upgrade-nvme-ana-check")
}

/// This is the allowed upgrade to-version/to-version-range for the Umbrella chart.
pub(crate) const TO_UMBRELLA_SEMVER: &str = "4.0.1";

/// This is the user docs URL for the Umbrella chart.
pub(crate) const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str =
"https://openebs.io/docs/user-guides/upgrade#mayastor-upgrade";
pub(crate) const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str = constants::UMBRELLA_CHART_UPGRADE_DOCS_URL;

/// This is the limit for the number of objects we want to collect over the network from
/// the kubernetes api.
Expand Down
Loading

0 comments on commit 4a3bc23

Please sign in to comment.