Skip to content

Commit 9452b3a

Browse files
committed
sync the log types on container updates
1 parent 5d6e47d commit 9452b3a

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

pkg/app/app.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,5 +625,10 @@ func (a *App) doUpdate(filterOptions container.FilterOptions) error {
625625
}
626626
}
627627

628+
// Update tedge-agent log types
629+
if err := a.client.SyncLogTypes(tedgeClient.Target); err != nil {
630+
slog.Warn("Failed to send tedge-agent sync request to update the log types", "err", err)
631+
}
632+
628633
return nil
629634
}

pkg/tedge/tedge.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ func (c *Client) Publish(topic string, qos byte, retained bool, payload any) err
241241
return tok.Error()
242242
}
243243

244+
// SyncLogTypes sends a signal to the tedge-agent to refresh the list of log types
245+
// so that it will include any new containers which may of been added
246+
func (c *Client) SyncLogTypes(target Target) error {
247+
topic := GetTopic(*c.Target.Service("tedge-agent"), "signal", "sync_log_upload")
248+
return c.Publish(topic, 0, false, "{}")
249+
}
250+
244251
// Deregister a thin-edge.io entity
245252
// Clear the status health topic as well as the registration topic
246253
func (c *Client) DeregisterEntity(target Target, retainedTopicPartials ...string) error {

tests/container-logs.robot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ Get Container Logs with only last N lines
3535
Get Container Logs By Operation
3636
# Run dummy container then exit
3737
DeviceLibrary.Execute Command cmd=tedge-container tools container-remove app14 ||: ; tedge-container engine docker run --name app14 httpd:2.4.61-alpine sh -c 'echo hello inside container stdout; echo hello inside container stderr >&2;'
38-
39-
# FIXME: Remove once tedge-agent supports an official interface to reload the config
40-
Execute Command cmd=touch /usr/share/tedge/log-plugins/container
41-
4238
Cumulocity.Should Contain Supported Log Types app14::container
4339
${operation}= Cumulocity.Get Log File app14::container
4440
Operation Should Be SUCCESSFUL ${operation}

tests/operations.robot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Install/uninstall container package
7575
Device Should Not Have Installed Software webserver
7676
Cumulocity.Should Have Services name=webserver service_type=container min_count=0 max_count=0
7777

78+
# container's log type should be removed
79+
Cumulocity.Should Not Contain Supported Log Types webserver::container
7880

7981
Install/uninstall container package from file
8082
${binary_url}= Cumulocity.Create Inventory Binary app3 container file=${CURDIR}/data/apps/app3.tar
@@ -101,6 +103,9 @@ Manual container creation/deletion
101103
Should Contain ${operation.to_json()["c8y_Command"]["result"]} It works!
102104
Cumulocity.Should Have Services name=manualapp1 service_type=container status=up
103105

106+
# container's log type should of been added
107+
Cumulocity.Should Contain Supported Log Types manualapp1::container
108+
104109
# Pause
105110
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker pause manualapp1;
106111
Operation Should Be SUCCESSFUL ${operation}
@@ -116,6 +121,8 @@ Manual container creation/deletion
116121
Operation Should Be SUCCESSFUL ${operation}
117122
Cumulocity.Should Have Services name=manualapp1 service_type=container min_count=0 max_count=0 timeout=10
118123

124+
# container's log type should be removed
125+
Cumulocity.Should Not Contain Supported Log Types manualapp1::container
119126

120127
Manual container creation/deletion with error on run
121128
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run -d --name manualapp2 httpd:2.4 --invalid-arg || exit 0

tests/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
robotframework~=7.0.0
2-
robotframework-c8y @ git+https://github.com/reubenmiller/robotframework-c8y.git@0.47.0
3-
robotframework-devicelibrary[docker] @ git+https://github.com/reubenmiller/[email protected].0
2+
robotframework-c8y @ git+https://github.com/reubenmiller/robotframework-c8y.git@0.50.0
3+
robotframework-devicelibrary[docker] @ git+https://github.com/reubenmiller/[email protected].1
44
robotframework-debuglibrary~=2.5.0

0 commit comments

Comments
 (0)