|
1 | 1 | use futures::{StreamExt as _, TryStreamExt}; |
2 | 2 | use indexmap::IndexMap; |
| 3 | +use reqwest::StatusCode; |
3 | 4 | use serde::{Deserialize, Serialize}; |
4 | 5 | use snafu::{ResultExt, Snafu}; |
5 | 6 | use tokio::task::JoinError; |
6 | | -use tracing::{Instrument, Span, info, instrument}; |
| 7 | +use tracing::{Instrument, Span, debug, info, instrument}; |
7 | 8 | use tracing_indicatif::span_ext::IndicatifSpanExt as _; |
8 | 9 | #[cfg(feature = "openapi")] |
9 | 10 | use utoipa::ToSchema; |
@@ -181,18 +182,38 @@ impl ReleaseSpec { |
181 | 182 | } |
182 | 183 | }; |
183 | 184 |
|
184 | | - let request_url = &format!( |
| 185 | + let request_url_string = &format!( |
185 | 186 | "https://raw.githubusercontent.com/stackabletech/{product_name}-operator/{release_branch}/deploy/helm/{product_name}-operator/crds/crds.yaml" |
186 | 187 | ); |
187 | | - let request_url = request_url.into_path_or_url().context(ParsePathOrUrlSnafu { |
188 | | - path_or_url: request_url.clone(), |
| 188 | + let request_url = request_url_string.into_path_or_url().context(ParsePathOrUrlSnafu { |
| 189 | + path_or_url: request_url_string, |
189 | 190 | })?; |
190 | 191 |
|
191 | 192 | // Get CRD manifests from request_url |
192 | | - let crd_manifests: String = transfer_client |
| 193 | + let crd_manifests = transfer_client |
193 | 194 | .get(&request_url, &Text) |
194 | | - .await |
195 | | - .context(FileTransferSnafu)?; |
| 195 | + .await; |
| 196 | + let crd_manifests = match crd_manifests { |
| 197 | + Ok(crd_manifests) => crd_manifests, |
| 198 | + Err(crate::xfer::Error::FetchRemoteContent{source: reqwest_error}) |
| 199 | + if reqwest_error.status() == Some(StatusCode::NOT_FOUND) => { |
| 200 | + // Ignore 404, as CRD versioning is rolled out to operators. |
| 201 | + // Starting with secret-operator 25.11.0, the CRD is maintained by the operator, |
| 202 | + // making this entire functionality obsolete. |
| 203 | + // As only some of the operators are migrated yet, some operator crds.yaml's |
| 204 | + // return a 404, others don't. |
| 205 | + debug!( |
| 206 | + product = product_name, |
| 207 | + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-client-span |
| 208 | + url.full = request_url_string, |
| 209 | + "Skipped updating CRD, as it doesn't exist in the upstream GitHub repo because the operator most likely uses CRD versioning" |
| 210 | + ); |
| 211 | + return Ok(()); |
| 212 | + }, |
| 213 | + Err(err) => { |
| 214 | + return Err(Error::FileTransfer { source: err }); |
| 215 | + }, |
| 216 | + }; |
196 | 217 |
|
197 | 218 | // Upgrade CRDs |
198 | 219 | k8s_client |
|
0 commit comments