Skip to content

Commit

Permalink
Merge pull request #2893 from golemfactory/fix-removed-asnom-repo
Browse files Browse the repository at this point in the history
Reference our own fork of asnom in market resolver
  • Loading branch information
nieznanysprawiciel authored Nov 20, 2023
2 parents f106866 + b05bb9f commit 9fd8d06
Show file tree
Hide file tree
Showing 12 changed files with 904 additions and 796 deletions.
1,648 changes: 879 additions & 769 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ ya-service-api-interfaces = { path = "core/serv-api/interfaces" }
ya-service-api-web = { path = "core/serv-api/web" }

## SERVICE BUS
ya-service-bus = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "190f0d772f7ed0830d54a2cef77d7a177f276c68" }
ya-sb-proto = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "190f0d772f7ed0830d54a2cef77d7a177f276c68" }
ya-sb-router = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "190f0d772f7ed0830d54a2cef77d7a177f276c68" }
ya-sb-util = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "190f0d772f7ed0830d54a2cef77d7a177f276c68" }
ya-service-bus = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "44c942c72f639c91aa22bdf107842c28433a7feb" }
ya-sb-proto = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "44c942c72f639c91aa22bdf107842c28433a7feb" }
ya-sb-router = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "44c942c72f639c91aa22bdf107842c28433a7feb" }
ya-sb-util = { git = "https://github.com/golemfactory/ya-service-bus.git", rev = "44c942c72f639c91aa22bdf107842c28433a7feb" }

#ya-service-bus = { path = "../ya-service-bus" }
#ya-sb-proto = { path = "../ya-service-bus/crates/proto" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, Duration, NaiveDateTime, Utc};
use chrono::{DateTime, Duration, NaiveDateTime, TimeZone, Utc};

use ya_agreement_utils::{Error, OfferDefinition};

Expand Down Expand Up @@ -147,7 +147,7 @@ fn read_utc_timestamp(pointer: &str, proposal: &ProposalView) -> anyhow::Result<
let nsecs = 1_000_000 * (val % 1000) as u32;
let naive = NaiveDateTime::from_timestamp_opt(secs, nsecs)
.ok_or_else(|| anyhow::anyhow!("Cannot make DateTime from {secs} and {nsecs}"))?;
Ok(DateTime::from_naive_utc_and_offset(naive, Utc))
Ok(Utc.from_utc_datetime(&naive))
}
Err(err) => Err(err.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion core/market/resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
ya-agreement-utils = "0.5.0"

asnom = { git = "https://github.com/golemfactory/asnom.git" }
asnom = { git = "https://github.com/golemfactory/asnom" }
bigdecimal = "0.2"
chrono = "0.4"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions core/market/resolver/src/resolver/properties.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::str;

use bigdecimal::BigDecimal;
use chrono::{DateTime, Utc};
use chrono::{DateTime, TimeZone, Utc};
use regex::Regex;
use semver::Version;
use std::collections::HashMap;
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'a> PropertyValue<'a> {
fn parse_date_from_rfc3339(dt_str: &str) -> Result<DateTime<Utc>, chrono::ParseError> {
match DateTime::parse_from_rfc3339(dt_str) {
Ok(parsed_value) => {
let dt = DateTime::<Utc>::from_naive_utc_and_offset(parsed_value.naive_utc(), Utc);
let dt = Utc.from_utc_datetime(&parsed_value.naive_utc());
Ok(dt)
}
Err(err) => Err(err),
Expand Down
8 changes: 3 additions & 5 deletions core/market/src/db/model/agreement.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use chrono::{NaiveDateTime, TimeZone, Utc};
use diesel::sql_types::Text;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -168,10 +168,8 @@ impl Agreement {
agreement_id: self.id.into_client(),
demand,
offer,
valid_to: DateTime::<Utc>::from_naive_utc_and_offset(self.valid_to, Utc),
approved_date: self
.approved_ts
.map(|d| DateTime::<Utc>::from_naive_utc_and_offset(d, Utc)),
valid_to: Utc.from_utc_datetime(&self.valid_to),
approved_date: self.approved_ts.map(|d| Utc.from_utc_datetime(&d)),
state: self.state.into(),
timestamp: Utc.from_utc_datetime(&self.creation_ts),
app_session_id: self.session_id,
Expand Down
4 changes: 2 additions & 2 deletions core/market/src/db/model/agreement_events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{NaiveDateTime, TimeZone, Utc};
use diesel::sql_types::Text;
use std::fmt;
use std::fmt::Debug;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl NewAgreementEvent {
impl AgreementEvent {
pub fn into_client(self) -> ClientEvent {
let agreement_id = self.agreement_id.into_client();
let event_date = DateTime::<Utc>::from_naive_utc_and_offset(self.timestamp, Utc);
let event_date = Utc.from_utc_datetime(&self.timestamp);
let reason = self.reason.map(|reason| reason.0);

match self.event_type {
Expand Down
6 changes: 3 additions & 3 deletions core/market/src/db/model/negotiation_events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{NaiveDateTime, TimeZone, Utc};
use diesel::sql_types::Text;
use thiserror::Error;

Expand Down Expand Up @@ -115,7 +115,7 @@ impl MarketEvent {
self,
db: &DbMixedExecutor,
) -> Result<RequestorEvent, EventError> {
let event_date = DateTime::<Utc>::from_naive_utc_and_offset(self.timestamp, Utc);
let event_date = Utc.from_utc_datetime(&self.timestamp);
match self.event_type {
EventType::RequestorNewProposal => Ok(RequestorEvent::ProposalEvent {
event_date,
Expand Down Expand Up @@ -166,7 +166,7 @@ impl MarketEvent {
self,
db: &DbMixedExecutor,
) -> Result<ProviderEvent, EventError> {
let event_date = DateTime::<Utc>::from_naive_utc_and_offset(self.timestamp, Utc);
let event_date = Utc.from_utc_datetime(&self.timestamp);
match self.event_type {
EventType::ProviderNewProposal => Ok(ProviderEvent::ProposalEvent {
event_date,
Expand Down
4 changes: 2 additions & 2 deletions core/market/src/market.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use actix_web::web::Data;
use chrono::{DateTime, Utc};
use chrono::{DateTime, TimeZone, Utc};
use lazy_static::lazy_static;
use metrics::counter;
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -251,7 +251,7 @@ impl MarketService {
.map_err(|e| AgreementError::Internal(e.to_string()))?;

let mut result = Vec::new();
let naive_to_utc = |ts| DateTime::<Utc>::from_naive_utc_and_offset(ts, Utc);
let naive_to_utc = |ts| Utc.from_utc_datetime(&ts);

for agreement in agreements {
let role = match agreement.id.owner() {
Expand Down
4 changes: 2 additions & 2 deletions core/market/src/market/agreement.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, Utc};
use chrono::{TimeZone, Utc};
use ya_client::model::market::{Agreement as ClientAgreement, AgreementListEntry, Role};
use ya_core_model::market::{GetAgreement, ListAgreements, RpcMessageError};
use ya_service_bus::typed::ServiceBinder;
Expand Down Expand Up @@ -34,7 +34,7 @@ async fn list_agreements(
.map_err(|e| RpcMessageError::Market(e.to_string()))?;

let mut result = Vec::new();
let naive_to_utc = |ts| DateTime::<Utc>::from_naive_utc_and_offset(ts, Utc);
let naive_to_utc = |ts| Utc.from_utc_datetime(&ts);

for agreement in agreements {
let role = match agreement.id.owner() {
Expand Down
4 changes: 2 additions & 2 deletions core/net/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt::Display;
use std::str::FromStr;
use std::time::Duration;

use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use humantime::format_duration;
use structopt::*;
use ya_client_model::NodeId;
Expand Down Expand Up @@ -232,7 +232,7 @@ fn to_mib(value: usize, is_json: bool) -> serde_json::Value {
fn find_node_to_output(response: model::FindNodeResponse) -> anyhow::Result<CommandOutput> {
let naive = NaiveDateTime::from_timestamp_opt(response.seen.into(), 0)
.context("Failed on out-of-range number of seconds")?;
let seen: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive, Utc);
let seen: DateTime<Utc> = Utc.from_utc_datetime(&naive);

CommandOutput::object(serde_json::json!({
"identities": response.identities.into_iter().map(|n| n.to_string()).collect::<Vec<_>>(),
Expand Down
4 changes: 2 additions & 2 deletions utils/manifest-utils/src/keystore/x509_keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::{
RemoveResponse, SignatureVerifier,
};
use anyhow::bail;
use chrono::{DateTime, Duration, NaiveDateTime, Utc};
use chrono::{DateTime, Duration, NaiveDateTime, TimeZone, Utc};
use golem_certificate::schemas::certificate::Fingerprint;
use openssl::{
asn1::{Asn1Time, Asn1TimeRef},
Expand Down Expand Up @@ -62,7 +62,7 @@ fn asn1_time_to_date_time(time: &Asn1TimeRef) -> anyhow::Result<DateTime<Utc>> {
let not_after = NaiveDateTime::from_timestamp_millis(0).unwrap()
+ Duration::days(time_diff.days as i64)
+ Duration::seconds(time_diff.secs as i64);
Ok(DateTime::<Utc>::from_naive_utc_and_offset(not_after, Utc))
Ok(Utc.from_utc_datetime(&not_after))
}

pub(super) struct AddX509Response {
Expand Down

0 comments on commit 9fd8d06

Please sign in to comment.