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

Fix application profile and NN patching #335

Merged
merged 1 commit into from
Aug 6, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,18 @@ func (am *ApplicationProfileManager) monitorContainer(ctx context.Context, conta
}

am.saveProfile(ctx, watchedContainer, container.K8s.Namespace)
return nil
return err
case errors.Is(err, utils.ContainerReachedMaxTime):
watchedContainer.SetStatus(utils.WatchedContainerStatusCompleted)
am.saveProfile(ctx, watchedContainer, container.K8s.Namespace)
return nil
return err
case errors.Is(err, utils.ObjectCompleted):
watchedContainer.SetStatus(utils.WatchedContainerStatusCompleted)
return nil
return err
case errors.Is(err, utils.TooLargeObjectError):
logger.L().Debug("ApplicationProfileManager - object is too large")
watchedContainer.SetStatus(utils.WatchedContainerStatusTooLarge)
return nil
return err
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/networkmanager/v2/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ func (nm *NetworkManager) monitorContainer(ctx context.Context, container *conta
watchedContainer.SetStatus(utils.WatchedContainerStatusCompleted)
}
nm.saveNetworkEvents(ctx, watchedContainer, container.K8s.Namespace)
return nil
return err
case errors.Is(err, utils.ContainerReachedMaxTime):
watchedContainer.SetStatus(utils.WatchedContainerStatusCompleted)
nm.saveNetworkEvents(ctx, watchedContainer, container.K8s.Namespace)
return nil
return err
case errors.Is(err, utils.ObjectCompleted):
watchedContainer.SetStatus(utils.WatchedContainerStatusCompleted)
return nil
return err
case errors.Is(err, utils.TooLargeObjectError):
watchedContainer.SetStatus(utils.WatchedContainerStatusTooLarge)
return nil
return err
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions pkg/storage/v1/applicationprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,25 @@ func (sc Storage) patchApplicationProfile(name, namespace string, operations []u
if err != nil {
return fmt.Errorf("patch application profile: %w", err)
}

// check if returned profile is full
if s, ok := profile.Annotations[helpers.StatusMetadataKey]; ok {
if s == helpers.TooLarge {
if channel != nil {
channel <- utils.TooLargeObjectError
}
if status, ok := profile.Annotations[helpers.StatusMetadataKey]; ok && status == helpers.TooLarge {
if channel != nil {
channel <- utils.TooLargeObjectError
}
return nil
}

// check if returned profile is completed
if c, ok := profile.Annotations[helpers.CompletionMetadataKey]; ok {
if s, ok := profile.Annotations[helpers.StatusMetadataKey]; ok {
if s == helpers.Complete && c == helpers.Completed {
if channel != nil {
channel <- utils.ObjectCompleted
}
if s, ok := profile.Annotations[helpers.StatusMetadataKey]; ok && s == helpers.Complete && c == helpers.Completed {
if channel != nil {
channel <- utils.ObjectCompleted
}
return nil
}
return nil
}

// check if returned profile is too big
if s, ok := profile.Annotations[helpers.ResourceSizeMetadataKey]; ok {
size, err := strconv.Atoi(s)
Expand Down
19 changes: 8 additions & 11 deletions pkg/storage/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,22 @@ func (sc Storage) patchNetworkNeighborhood(name, namespace string, operations []
return fmt.Errorf("patch application neighborhood: %w", err)
}
// check if returned neighborhood is full
if s, ok := neighborhood.Annotations[helpers.StatusMetadataKey]; ok {
if s == helpers.TooLarge {
if channel != nil {
channel <- utils.TooLargeObjectError
}
if status, ok := neighborhood.Annotations[helpers.StatusMetadataKey]; ok && status == helpers.TooLarge {
if channel != nil {
channel <- utils.TooLargeObjectError
}
return nil
}
// check if returned profile is completed
if c, ok := neighborhood.Annotations[helpers.CompletionMetadataKey]; ok {
if s, ok := neighborhood.Annotations[helpers.StatusMetadataKey]; ok {
if s == helpers.Complete && c == helpers.Completed {
if channel != nil {
channel <- utils.ObjectCompleted
}
if s, ok := neighborhood.Annotations[helpers.StatusMetadataKey]; ok && s == helpers.Complete && c == helpers.Completed {
if channel != nil {
channel <- utils.ObjectCompleted
}
return nil
}
return nil
}

// check if returned neighborhood is too big
if s, ok := neighborhood.Annotations[helpers.ResourceSizeMetadataKey]; ok {
size, err := strconv.Atoi(s)
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/v1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ func CreateStorage(namespace string) (*Storage, error) {
if err != nil {
maxApplicationProfileSize = DefaultMaxApplicationProfileSize
}
logger.L().Debug("maxApplicationProfileSize", helpers.Int("size", maxApplicationProfileSize))

maxNetworkNeighborhoodSize, err := strconv.Atoi(os.Getenv("MAX_NETWORK_NEIGHBORHOOD_SIZE"))
if err != nil {
maxNetworkNeighborhoodSize = DefaultMaxNetworkNeighborhoodSize
}
logger.L().Debug("maxNetworkNeighborhoodSize", helpers.Int("size", maxNetworkNeighborhoodSize))

// wait for storage to be ready
if err := backoff.RetryNotify(func() error {
Expand Down
Loading