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 repository field for stacks, clean up clippy wanrings #517

Merged
merged 12 commits into from
Feb 1, 2024

Conversation

nhudson
Copy link
Collaborator

@nhudson nhudson commented Jan 29, 2024

  • Add new field repository to the Stack struct to allow setting a different repository if wanted.

    • Update stack templates
  • Clean up clippy warnings

fixes: TEM-2538

@nhudson nhudson self-assigned this Jan 29, 2024
@@ -405,7 +405,7 @@ async fn check_for_extensions_enabled_with_load(
for extension in trunk_installed_extensions_not_in_all_actually_installed_extensions.clone()
{
let found =
check_for_so_files(cdb, ctx.clone(), &*pod_name, extension.name.clone()).await?;
check_for_so_files(cdb, ctx.clone(), &pod_name, extension.name.clone()).await?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -430,7 +430,7 @@ async fn check_for_extensions_enabled_with_load(
found = true;
for desired_location in desired_extension.locations {
let location_status = ExtensionInstallLocationStatus {
enabled: Some(desired_location.enabled.clone()),
enabled: Some(desired_location.enabled),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -277,7 +277,7 @@ pub async fn get_trunk_project_metadata_for_version(
let response_body = response.text().await?;
let project_metadata: Vec<TrunkProjectMetadata> = serde_json::from_str(&response_body)?;
// There will only be one index here, so we can safely assume index 0
let project_metadata = match project_metadata.get(0) {
let project_metadata = match project_metadata.first() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -367,7 +367,7 @@ pub async fn is_control_file_absent(
// where there are multiple extensions
let control_file_absent = project_metadata
.extensions
.get(0)
.first()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

Comment on lines +414 to +418
let loadable_library_name = extension_metadata
.loadable_libraries
.as_ref()
.and_then(|loadable_libraries| loadable_libraries.iter().find(|l| l.requires_restart))
.map(|loadable_library| loadable_library.library_name.clone());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

Comment on lines +492 to +493
let a = semver::Version::parse(a).unwrap();
let b = semver::Version::parse(b).unwrap();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -550,17 +543,17 @@ mod tests {
let extension_name = "auto_explain".to_string();
let result = extension_name_matches_trunk_project(extension_name).await;
assert!(result.is_ok());
assert_eq!(result.unwrap(), true);
assert!(result.unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning


let extension_name = "pgml".to_string();
let result = extension_name_matches_trunk_project(extension_name).await;
assert!(result.is_ok());
assert_eq!(result.unwrap(), false);
assert!(!result.unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning


let extension_name = "vector".to_string();
let result = extension_name_matches_trunk_project(extension_name).await;
assert!(result.is_ok());
assert_eq!(result.unwrap(), false);
assert!(!result.unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -592,7 +585,7 @@ mod tests {
let version = "15.3.0".to_string();
let result = is_control_file_absent(trunk_project, version).await;
assert!(result.is_ok());
assert_eq!(result.unwrap(), true);
assert!(result.unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -618,11 +611,11 @@ mod tests {
fn test_is_semver() {
let version = "1.2.3".to_string();
let result = is_semver(version);
assert_eq!(result, true);
assert!(result);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning


let version = "1.2".to_string();
let result = is_semver(version);
assert_eq!(result, false);
assert!(!result);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

Comment on lines +615 to +620
} else if has_extension {
println!(
"CoreDB {} has extension {} enabled in status",
name, extension
);
return Ok(());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -2332,7 +2329,7 @@ mod test {
});
let params = PatchParams::apply("tembo-integration-test");
let patch = Patch::Apply(&coredb_json);
let coredb_resource = coredbs.patch(name, &params, &patch).await.unwrap();
let _coredb_resource = coredbs.patch(name, &params, &patch).await.unwrap();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@@ -2346,7 +2343,7 @@ mod test {
// Check status.extensions.locations is not empty
let coredb_resource = coredbs.get(name).await.unwrap();
for extension in coredb_resource.status.unwrap().extensions.unwrap() {
assert!(extension.locations.len() > 0);
assert!(!extension.locations.is_empty());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix clippy warning

@nhudson nhudson marked this pull request as ready for review January 29, 2024 22:52
Copy link
Contributor

@sjmiller609 sjmiller609 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my concerns. There is one other thing that I think would be nice to do, maybe reducing one duplication of configuration and helping test image updates in stack yamls.

}

pub fn default_llm_image() -> String {
"quay.io/tembo/ml-cnpg:15.3.0-1-63e32a1".to_owned()
"ml-cnpg:15.3.0-1-63e32a1".to_owned()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for the values in this file to come from the stack yamls? So it's like if someone updates the image in a stack yaml, then the operator tests run in CI and it's using the new image from the stack yaml for which there are operator tests?

If we don't do that, then our operator tests use the image configured here in the defaults, but a future change to stack yaml, then following that to update in control plane, can result in us use image defaults that have not been tested by the functional testing in the operator code

Comment on lines 144 to 163

// Watch for deletion
let wp = WatchParams {
field_selector: Some(format!("metadata.name={}", name)),
..WatchParams::default()
};
let stream = coredb_api
.watch(&wp, "0")
.await
.map_err(ConductorError::KubeError)?;

let mut pinned_stream = Box::pin(stream);

while let Some(status) = pinned_stream.try_next().await? {
if let WatchEvent::Deleted(_) = status {
info!("CoreDB {} deleted", name);
return Ok(());
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a WatchEvent to conductor. This will ensure that the function will not return unless there is an error or if the CoreDB CR is actually deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be an issue with this, because any waiting logic in conductor blocks the processing of other events. This means in the future event that a namespace takes awhile to delete, then this replica of conductor will stop processing all other events including new instances, update instances, and so on. That's why I think it is problematic to do "wait" style logic in conductor or operator, rather "requeue" style, so that waits instead handled like interrupts.

Comment on lines 213 to 231

// Watch for deletion
let wp = WatchParams {
field_selector: Some(format!("metadata.name={}", name)),
..WatchParams::default()
};
let stream = ns_api
.watch(&wp, "0")
.await
.map_err(ConductorError::KubeError)?;

let mut pinned_stream = Box::pin(stream);

while let Some(status) = pinned_stream.try_next().await? {
if let WatchEvent::Deleted(_) = status {
info!("Namespace {} deleted", name);
return Ok(());
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a WatchEvent to conductor. This will ensure that the function will not return unless there is an error or if the Namespace is actually deleted.

@sjmiller609 sjmiller609 self-requested a review January 31, 2024 23:09
@nhudson nhudson merged commit 763aca7 into main Feb 1, 2024
19 checks passed
@nhudson nhudson deleted the nhudson/TEM-2538 branch February 1, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants